So I did this to set up a new virtual host:
cd /etc/apache2/sites-available
sudo touch test
sudo gedit test
I have saved this content inside the test file:
NameVirtualHost *:80
<VirtualHost *:80>
ServerName test.local
DocumentRoot /home/richard/projects/test
</VirtualHost>
Then I did:
mkdir /home/richard/projects/test
touch /home/richard/projects/test/index.html
sudo gedit /etc/hosts
I have edited the hosts file to look like this:
127.0.0.1 localhost
127.0.1.1 richard-desktop
127.0.0.1 test.local
127.0.0.1 test2.local
127.0.0.1 test3.local
# The following lines are desirable for IPv6 capable hosts
::1 ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
Then I did:
sudo a2ensite test
sudo a2dissite default
sudo service apache2 reload
I then go in my browser to:
http://test.local
And it doesn't work, the page is loading forever.
Ouput of netstat -plnt |grep 80:
richard@richard-desktop:/etc/apache2/sites-available$ sudo netstat -plnt |grep 80
[sudo] password for richard:
tcp6 0 0 :::80 :::* LISTEN 1265/apache2
Output of netstat -taupen | grep :80:
tcp 0 0 10.200.32.82:36199 77.67.21.59:80 ESTABLISHED 1000 88789 4410/firefox
tcp 0 0 127.0.0.1:56686 127.0.0.1:80 ESTABLISHED 1000 88490 4410/firefox
tcp 0 0 127.0.0.1:56775 127.0.0.1:80 ESTABLISHED 1000 87786 4410/firefox
tcp 0 0 10.200.32.82:35054 31.186.231.25:80 TIME_WAIT 0 0 -
tcp 0 0 10.200.32.82:37231 64.34.119.12:80 ESTABLISHED 1000 89616 4410/firefox
tcp 0 0 10.200.32.82:60212 173.194.34.99:80 ESTABLISHED 1000 87876 4410/firefox
tcp 1 0 10.200.32.82:44111 91.189.89.134:80 CLOSE_WAIT 1000 94528 2159/python
tcp 0 0 10.200.32.82:46205 173.194.34.97:80 ESTABLISHED 1000 87879 4410/firefox
tcp 0 0 127.0.0.1:56684 127.0.0.1:80 ESTABLISHED 1000 93631 4410/firefox
tcp 1 0 10.200.32.82:44112 91.189.89.134:80 CLOSE_WAIT 1000 94529 2159/python
tcp 0 0 10.200.32.82:47009 77.67.21.48:80 ESTABLISHED 1000 96368 4410/firefox
tcp 0 0 10.200.32.82:36200 77.67.21.59:80 ESTABLISHED 1000 88790 4410/firefox
tcp 0 0 10.200.32.82:35053 31.186.231.25:80 TIME_WAIT 0 0 -
tcp 0 0 10.200.32.82:33628 92.123.67.88:80 ESTABLISHED 1000 93931 4410/firefox
tcp 0 0 10.200.32.82:46999 77.67.21.48:80 ESTABLISHED 1000 88794 4410/firefox
tcp 0 0 10.200.32.82:50668 64.34.119.101:80 ESTABLISHED 1000 87923 4410/firefox
tcp 0 0 10.200.32.82:46991 77.67.21.48:80 ESTABLISHED 1000 96363 4410/firefox
tcp 0 0 127.0.0.1:56681 127.0.0.1:80 ESTABLISHED 1000 93629 4410/firefox
tcp 1 0 10.200.32.82:58695 91.189.89.144:80 CLOSE_WAIT 1000 7844 2011/ubuntu-geoip-p
tcp 0 0 10.200.32.82:34946 173.194.67.95:80 ESTABLISHED 1000 93950 4410/firefox
tcp 0 0 10.200.32.82:56595 77.67.21.56:80 ESTABLISHED 1000 93933 4410/firefox
tcp 0 0 10.200.32.82:57734 77.67.21.35:80 ESTABLISHED 1000 93956 4410/firefox
tcp 0 0 10.200.32.82:36203 77.67.21.59:80 ESTABLISHED 1000 88793 4410/firefox
tcp 0 0 127.0.0.1:56679 127.0.0.1:80 ESTABLISHED 1000 93627 4410/firefox
tcp 0 0 127.0.0.1:56677 127.0.0.1:80 ESTABLISHED 1000 86821 4410/firefox
tcp 0 0 10.200.32.82:49652 50.112.101.148:80 ESTABLISHED 1000 93939 4410/firefox
tcp 0 0 10.200.32.82:44859 184.73.242.29:80 ESTABLISHED 1000 96374 4410/firefox
tcp 0 0 10.200.32.82:47811 23.21.113.66:80 ESTABLISHED 1000 87908 4410/firefox
tcp 0 0 10.200.32.82:46996 77.67.21.48:80 ESTABLISHED 1000 88791 4410/firefox
tcp 0 0 10.200.32.82:52730 173.194.41.133:80 ESTABLISHED 1000 93958 4410/firefox
tcp 0 0 10.200.32.82:32952 64.34.119.13:80 ESTABLISHED 1000 96383 4410/firefox
tcp 0 0 127.0.0.1:56678 127.0.0.1:80 ESTABLISHED 1000 87612 4410/firefox
tcp 0 0 127.0.0.1:56897 127.0.0.1:80 ESTABLISHED 1000 93903 4410/firefox
tcp 0 0 10.200.32.82:36197 77.67.21.59:80 ESTABLISHED 1000 88787 4410/firefox
tcp 0 0 10.200.32.82:36202 77.67.21.59:80 ESTABLISHED 1000 88792 4410/firefox
tcp 0 0 10.200.32.82:36198 77.67.21.59:80 ESTABLISHED 1000 88788 4410/firefox
tcp6 0 0 :::80 :::* LISTEN 0 13912 -
tcp6 290 0 127.0.0.1:80 127.0.0.1:56678 ESTABLISHED 0 0 -
tcp6 300 0 127.0.0.1:80 127.0.0.1:56681 ESTABLISHED 0 0 -
tcp6 290 0 127.0.0.1:80 127.0.0.1:56897 ESTABLISHED 0 0 -
tcp6 289 0 127.0.0.1:80 127.0.0.1:56686 ESTABLISHED 0 0 -
tcp6 290 0 127.0.0.1:80 127.0.0.1:56775 ESTABLISHED 0 0 -
tcp6 290 0 127.0.0.1:80 127.0.0.1:56684 ESTABLISHED 0 0 -
tcp6 290 0 127.0.0.1:80 127.0.0.1:56677 ESTABLISHED 0 0 -
tcp6 290 0 127.0.0.1:80 127.0.0.1:56679 ESTABLISHED 0 0 -
I think the problem is in the Listening port. According to your output, it is listening only on IPv6 but not on IPv4 thats why the page is always loading..
According to your output of netstat command:
You have to have change your /etc/apache2/ports.conf to make it listen on the ipv4 address also.
Add the following line in
/etc/apache2/ports.conf
file:Listen 0.0.0.0:80