Don’t forget to uncomment the line:
NameVirtualHost *:80
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Check that DirectoryIndex directive contains:
index.html index.htm index.php
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Typical setup for dev environment
<VirtualHost *:80>
DocumentRoot /var/www/html/example.com/dev/html
ServerName dev.example.com
<Directory /var/www/html/example.com/dev/html>
AllowOverride All
</Directory>
AddDefaultCharset UTF-8
php_flag display_errors on
php_flag display_startup_errors on
php_value error_reporting 2047
</VirtualHost>
The AllowOverride All directive allows you to use a .htaccess file.
Typical setup for staging environment
<VirtualHost *:80>
DocumentRoot /var/www/html/example.com/staging/html
ServerName staging.example.com
<Directory /var/www/html/example.com/staging/html>
AllowOverride All
</Directory>
AddDefaultCharset UTF-8
php_flag display_errors on
php_flag display_startup_errors on
php_value error_reporting 2047
</VirtualHost>
Typical setup for live environment
<VirtualHost *:80>
DocumentRoot /var/www/html/example.com/live/html
ServerName www.example.com
ServerAlias example.com
ServerAlias example2.com
<Directory /var/www/html/example.com/live/html>
AllowOverride All
</Directory>
AddDefaultCharset UTF-8
php_flag display_errors off
php_flag display_startup_errors off
php_value error_reporting 0
</VirtualHost>
The ServerAlias directive allows to reach the website even without using www at the begin of URL
Don’t forget to uncomment the line:
NameVirtualHost *:80
There must be just ONE ServerName directive and how many ServerAlias directives you need.