How should I configure my Apache Hosts File to serve a different site for localhost than for my domain/publicip?

Posted by rofls on Server Fault See other posts from Server Fault or by rofls
Published on 2012-11-25T06:46:18Z Indexed on 2012/11/25 17:06 UTC
Read the original article Hit count: 159

Filed under:
|
|

I'm trying to test out a LAMP (with PHP5 specifically) setup with Django already serving a website. I want to do the PHP stuff on localhost for now, so that when I do something like this: curl http://localhost/database/script.php?var=1, I get a response from the php server. Right now I'm getting a Django error. I tried something like this in the default file in sites-available:

Listen 80
<VirtualHost aaa.bbb.ccc.ddd>
ServerName localhost
DocumentRoot /home/phpsite
</VirtualHost>

where aaa.bbb.ccc.ddd is the local ip address, and changing my actual site's settings to specify the public ip, like this:

Listen 80
<VirtualHost www.xxx.yyy.zzz>
ServerName mysite.com
DocumentRoot /srv/www/mysite
WSGIScriptAlias / /srv/www/mysite.wsgi    
</VirtualHost>

but then I start getting all kinds of errors when I start apache, such as port ::[80] is already in use or something. I noticed that the hosts file that's located in /etc/apache2/ is apparently pointing everything to mysite.com, including my local ip as well as 127.0.0.1 and 127.0.1.1; Do I need to change the configuration there too?

© Server Fault or respective owner

Related posts about django

Related posts about apache2