-1

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?

1 Answer 1

2

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>

1
  • 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, 2012 at 7:00

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .