Download the add-vhost.sh
file, make it executable and move it to /usr/bin/add-vhost
:
sudo chmod +x add-vhost.sh && sudo mv add-vhost.sh /usr/bin/add-vhost
Run it as root from anywhere:
sudo add-vhost
This will create a configuration file for the Apache, both for non-SSL and SSL versions, and also allow you to set different PHP versions if you have installed them as PHP-fpm services.
If you don't have PHP-fpm versions installed, remove these parts:
while ! [[ "${php_version}" =~ ^(5.6|7.2|7.3)$ ]]
do
read -p "PHP version (5.6, 7.2, 7.3): " php_version
done
... and ...
<FilesMatch \.php$>
# Apache 2.4.10+ can proxy to unix socket
SetHandler \"proxy:unix:/var/run/php/php${php_version}-fpm.sock|fcgi://localhost/\"
</FilesMatch>