Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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?

share|improve this question

migrated from stackoverflow.com Nov 25 '12 at 15:35

This question came from our site for professional and enthusiast programmers.

add comment

1 Answer

up vote 2 down vote accepted

You can accomplish this with NameVirtualHost:

 NameVirtualHost *:80

 <VirtualHost *:80>
 ServerName www.example.com
 ServerAlias example.com *.example.com
 DocumentRoot /srv/www/example.com
 </VirtualHost>

 <VirtualHost *:80>
 ServerName localhost
 DocumentRoot /srv/www/localhost
 </VirtualHost>

share|improve this answer
    
ok sorry, that was a stupid question. I think I tried that but thought it wasn't working because I did curl http://localhost and got a 404, not bothering to pay attention to the fact that it was from apache, not Django. Thank you. –  rofls Nov 26 '12 at 7:00
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.