user2763154 user2763154 - 5 months ago 12
Linux Question

Xubuntu Linux - Why doesn't my localhost direct me to my virtual host site?

I am setting up a virtual host on my linux machine, I followed all the steps and guides, but I do not go to my site for some reason. I have LAMP installed and apache, mysql, php is all working. I have a database setup on phpmyadmin and imported a database, but for some reason I cannot get my IP directed to my site! Its literally the last step I need so I can start working on my project.

127.0.0.1 localhost
127.0.0.1 cbirc.com

<VirtualHost *:80>
ServerAdmin admin@cbirc.com
ServerName cbirc.com
ServerAlias www.cbirc.com
DocumentRoot /var/www/cbirc
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>


What am I missing here???

Answer

You can be miles away not o n the last step :). You have to check bunch of stuff:

Is apache running

sudo service apache2 status

Afterwards, test it with

netstat -na | grep 80
ping cbirc.com

Was website enabled by issuing following command?

sudo a2ensite cbirc 
file /etc/apache2/sites-enabled/cbirc.conf  (or some similar name it that folder)

Does www-data group and user has read-execute access on

ln -l /var/www/cbirc

If not, do it like this

sudo chown -R www-data:www-data /var/www/cbirc
sudo chmod -R ug+rx /var/www/cbirc

Before issuing request in browser, do it with curl or wget

wget http://cbirc.com/
curl -v http://cbirc.com/

And look for error in logifile

tail -f /var/log/apache2/error.log

Please refer to my debian cheetsheat for further help

Comments