I have a live server running Ubuntu 7.10 and Apache2. The hostname is example.com
Code:
~$ hostname
example.com
I successfully have multiple virtual hosts running. If the host header is not specified in a request a default page will be displayed. eg http://255.255.255.255/ will display the default page.
But I can not get the example.com virtual host running correctly. A request for example.com will incorrectly display the default page.
In the default page <?php echo $_SERVER['SERVER_NAME']; ?> will correctly display either the ip address or example.com
I can get it working if I change "ServerName example.com" to "ServerName test.example.com", and setup the appropriate DNS CNAME record for test.example.com pointing to example.com
Code:
:/etc/apache2/sites-available$ cat ./example.com
<VirtualHost *>
ServerAdmin webmaster@example.com
ServerName example.com
DocumentRoot /var/www/example.com/htdocs
CustomLog /var/log/apache2/vhosts/example.com.access.log combined
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/example.com/htdocs>
Options FollowSymLinks
DirectoryIndex index.php index.html
AllowOverride None
Order Allow,Deny
Allow from all
</Directory>
</VirtualHost>
Bookmarks