Apache configuration is not always easy. So, this post is dedicated to Apache the VirtualHost Directive. For now I will keep it simple and just show you how to set up a VirtualHost in your home directory since that has changed with the new version and it is not obvious what you need to do.

 1 <VirtualHost *:80>
 2      ServerName www.example.com
 3      ServerAlias example.com
 4      DocumentRoot "/var/www/example.com"
 5      <Directory   "/var/www/example.com">
 6          Order allow,deny
 7          Allow from all
 8          Require all granted
 9          Options +FollowSymLinks +Includes +Multiviews
10          AllowOverride All
11      </Directory>
12 </VirtualHost>

To explain

Line 1: Opening tag for a XML-like configuration object, *:80 just means on every IP address (*) and :80 port 80 which is the default for HTTP.

Line 2: ServerName is pretty self-explanatory. It means the host name you want to choose.

Line 3: ServerAlias is an alternative name.

Line 4: DocumentRoot is you path to where your HTML documents live. Of course you could have PHP and other dynamic scripts there too.

Line 5: <Directory ${PATH}> This can usually be the same as DocumentRoot but gives more control over the directory’s configuration.

Line 6: Prioritises allowing access.

Line 7: Allows access from all hosts which is probably what you want, since it’s a public site, but here you can restrict hosts.

Line 8: This is new. To be honest, I’m not sure what this means, but it made the VirtualHost work in my home directory, which prompted me to write this post.

Line 9:

+FollowSymlinks means to allow symbolic links
+Includes       means to allow SSIs (Server Side Includes)
+MultiViews     means to allow sample/index.html
                to be viewed as sample/
                This makes for nicer URLs.

Line 11 & 12: XML closing tags.