6
2
I have a domain name that is linked to my ip address at home. However, I want to use the same server/ip to show more than one website.
I can't get Virtual Hosts to work though.
My conf.d/virtual.conf is:
NameVirtualHost 192.168.10.151:80
My sites-available/www.mydomain.com is:
Listen 80
<VirtualHost *>
ServerAdmin admin@mydomain.com
ServerName www.mydomain.com
ServerAlias mydomain.com
#Indexes and Directory Root
DirectoryIndex index.html index.php
DocumentRoot /media/BigDisk/www/www.mydomain.com/
# Log Files
ErrorLog /media/BigDisk/www/www.mydomain.com/logs/error.log
CustomLog /media/BigDisk/www/www.mydomain.com/logs/access.log combined
</VirtualHost>
And the site was enabled using a2ensite and apache reloaded without any warnings or errors, but when I go to www.mydomain.com
I don't get anything ("Opps! Google Chrome could not connect...").
What am I doing wrong?
Update: Restarting Apache results in this:
malfist@webhost:~$ sudo /etc/init.d/apache2 restart
[sudo] password for malfist:
* Restarting web server apache2 apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1 for ServerName
[Thu Sep 01 12:16:22 2011] [warn] NameVirtualHost 192.168.10.151:80 has no VirtualHosts
[Thu Sep 01 12:16:22 2011] [warn] NameVirtualHost *:80 has no VirtualHosts
apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1 for ServerName
[Thu Sep 01 12:16:22 2011] [warn] NameVirtualHost 192.168.10.151:80 has no VirtualHosts
[Thu Sep 01 12:16:22 2011] [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.
My router supports NAT reflection, so I can point to my public IP and the router has no problem. The DNS entry for the domain is correct, and my ISP doesn't care. I was running fine (single domain on laptop) until I decided to do Virtual Hosts, and now it's not working. – Malfist – 2011-09-01T13:21:44.430
Answer updated. – RedGrittyBrick – 2011-09-01T14:00:22.103
I run a different version of chrome at work, and it gives the error message, "tcp_error", and "connection refused". Does that clarify anymore? I know the IP/DNS entry is correct, because I have port 8080 routed to another box inside the LAN, and I can reach it just fine. – Malfist – 2011-09-01T15:21:12.177
"connection refused" suggests a problem in your router configuration. If Apache is configured normally and is listening on port 80, your server won't refuse connections. Have you checked the error logs and used a network sniffer as I suggested? – RedGrittyBrick – 2011-09-01T15:27:41.760
The router allowed the connection until I switch apache to virtual hosts, and if I switch apache's configuration back, the page resolves successfully. – Malfist – 2011-09-01T15:29:12.523
There is nothing in the logs except when it was not in the vhost configuration. – Malfist – 2011-09-01T15:41:28.320
Try my
wget
suggestion, if that works, the fault is almost certainly not your Apache config. – RedGrittyBrick – 2011-09-01T15:50:40.987"Connecting to localhost|127.0.0.1|:80... failed: Connection refused." And netstat -anp | grep 80 doesn't show anything listening on port 80. – Malfist – 2011-09-01T16:14:08.107
Updated question. Apache is now throwing exceptions when trying to start. It wasn't showing this earlier, I don't know why. Also, if it means anything, the apache server is running on Ubuntu 11.04 server inside a VirtualBox instance with a bridged network connection. – Malfist – 2011-09-01T16:19:16.990
I needed a ServerName in my config.d/virtual.conf and the NameVirtualHost needed to be a wildcard. – Malfist – 2011-09-01T16:26:56.463