I'm having a little trouble configuring name based Virtual Hosts.
I can start the server with "service apache2 start" with a blank httpd.conf file, and it will run with everything pointing to /var/www, as expected.
When I fill httpd.conf with:
# Ensure that Apache listens on port 80 Listen 80 # Listen for virtual host requests on all IP addresses NameVirtualHost *:80 <VirtualHost *:80> DocumentRoot /www/kevins_playground ServerName home.coolkev.com # Other directives here </VirtualHost> <VirtualHost *:80> DocumentRoot /www/flatline_and_co ServerName www.flatline_and_co.com # Other directives here </VirtualHost>
I get this error when running "service apache2 start"
root@kevin-server:/etc/apache2# service apache2 start * Starting web server apache2 apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1 for ServerName [Thu Jul 26 20:10:01 2012] [warn] NameVirtualHost *:80 has no VirtualHosts (98)Address already in use: make_sock: could not bind to address 0.0.0.0:80 no listening sockets available, shutting down Unable to open logs Action 'start' failed. The Apache error log may have more information.
I found a solution,
- I removed all my changes to httpd.conf, for me, this left a blank file.
- I copied the existing default site file in ./sites-available/ for my two Virtual Hosts.
- I edited those two files and replaced values where it made sense, I think it should be obvious where they need changing (Website base folder, Website URL).
- I created sym-links like you are supposed to in ./sites-enabled/
- I restarted the web-server 'sudo service apache2 restart' and it worked.
I think the problem stemmed from the fact that while parsing the files, Apache discovered two files with "<VirtualHost>"s, my httpd.conf and the default website configuration in ./sites-available/