PHP 7 command line symfony console application to create Apache 2.4 virtual hosts for Ubuntu., (*2)
This is an Apache adminstrative tool whose commands mostly require sudo.
It can write configuration files to
as well as writing SSL certificates to
/etc/ssl/certs/ and keys to
so the best way to install it would be somewhere in root's path., (*3)
Download the latest release, set it executable, and move it to a good path. Here's a oneline command:, (*4)
curl -s -L https://github.com/jpuck/avhost/releases/latest | egrep -o '/jpuck/avhost/releases/download/[0-9\.]*/avhost.phar' | wget --base=http://github.com/ -i - -O avhost && chmod +x avhost && sudo mv avhost /usr/local/bin/
After installing, run without any arguments to see a list of commands:, (*5)
-h flag with any command to get help with usage:, (*6)
avhost <command> -h
Job for apache2.service failed because the control process exited with error code. See "systemctl status apache2.service" and "journalctl -xe" for details., (*7)
Looking at those logs are certainly helpful, but here are a couple things that might not be obvious the first time:, (*8)
To run an encrypted virtual host over [TLS (SSL)], you must have enabled [Apache Module mod_ssl]., (*9)
sudo a2enmod ssl
The default configuration with
avhost is to redirect all traffic to an encrypted connection when available.
This is accomplished with Apache Module mod_rewrite., (*10)
sudo a2enmod rewrite
This is recommended for many reasons.
If necessary, this can be overridden by passing the option
which makes sense in some cases, like when using a self-signed certificate that might cause trust issues.
However, since you can get a free trusted certificate from Let's Encrypt, then there's no reason to be using
a self-signed certificate on a public site anyway., (*11)
If you create the document root in some random folder, then not only must that folder and files be readable to Apache, but also every directory up to root must be executable by Apache in order for it to traverse the file system., (*12)
For example, if your site's files are in
# up to directory, folders executable chmod go+X / chmod go+X /path chmod go+X /path/to chmod go+X /path/to/private chmod go+X /path/to/private/web # in directory, folders executable, files readable chmod -R go+rX /path/to/private/web/folder
In order to add protection such as
X-Content-Type-Options "nosniff" and to
X-Powered-By information, you must enable [Apache Module mod_headers].
This is also needed to allow [Cross Origin Resource Sharing], which is not
enabled by this project - you must manually define your CORS headers if you want., (*14)
sudo a2enmod headers
For performance reasons, most file types are compressed, but you must have enabled [Apache Module mod_deflate]., (*15)
sudo a2enmod deflate