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 have a working Django app hosted on my linode (Fedora 15), and I'm attempting to host a php-based site there as well. I'm using name-based virtual hosts to redirect requests based on the host name, but for some reason, every request is going to the Django app. I'm thinking perhaps mod_wsgi is overriding some defaults? Or maybe a syntax error with my virtual hosts (I've tried DocumentRoot with and without quotes)? Here are the relevant parts of my httpd config file:

Name VirtualHost *:80
<VirtualHost *:80>
ServerName pollvaultr.com
ServerAlias www.pollvaultr.com

WSGIDaemonProcess pollvaultr.com user=apache group=apache
WSGIProcessGroup pollvaultr.com

WSGIScriptAlias / "/var/www/html/PollVaultr/wsgi.py"

Alias /static/ "/var/www/html/static/"

<Directory "/var/www/html/static">
    Order allow,deny
    Allow from all
</Directory>

<Directory "/var/www/html/PollVaultr">
    <Files "wsgi.py">
    Order allow,deny
    Allow from all
    </Files>
</Directory>

</VirtualHost>

<VirtualHost *:80>
    DocumentRoot "/var/www/catfacts/"
    ServerName lexiross.com
    ServerAlias www.lexiross.com
</VirtualHost>

And here is my wsgi.py script:

import os, sys

sys.path.append('/var/www/html')
sys.path.append('/var/www/html/PollVaultr')

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "PollVaultr.settings")

import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()

Running httpd -e DEBUG does not reveal any bugs. Here is the tail of my error_log file:

[Fri Feb 24 20:36:42 2012] [info] mod_wsgi (pid=5893): Create interpreter 'lexiross.com|'.
[Fri Feb 24 20:36:42 2012] [info] mod_wsgi (pid=5893): Adding '/var/www/html/' to path.
[Fri Feb 24 20:36:42 2012] [info] [client 140.247.248.217] mod_wsgi (pid=5893, process='', application='lexiross.com|'): Loading WSGI script '/var/www/html/PollVaultr/wsgi.py'.

Any ideas what could be going on? mod_wsgi definitely shouldn't be dealing with requests made to lexiross.com - why won't those requests head to the alternate document root? I should also mention that this is my first time doing sysadmin work, so I'm very new at this! Thanks.

share|improve this question
add comment

1 Answer

up vote 1 down vote accepted

If you have not setup the second virtual host properly, or not being found, then Apache will fallback to sending requests to first virtual host it found in configuration.

Are the virtual hosts in same file, different files? If in different files and in sites-available directory, did you actually enable the second site so linked into sites-enabled?

Try adding a syntax error into second virtual host to make sure file is being read.

Also fix your "NameVirtualHost" directive in example, unless that is your problem. Shouldn't have a space in it.

share|improve this answer
    
All my vhosts are in httpd.conf. I'm using Fedora and it looks like sites-available isn't on Fedora as far as I can tell. I haven't been able to find an equivalent. Update: I changed around my file system so I have /var/www/pollvaultr.com/html, /var/www/lexiross.com/html, and /var/www/catfacts.lexiross.com/html as the three documentroots. Now both sites are down, not sure why... Thanks for your help, by the way! –  LBR Feb 25 '12 at 3:50
1  
You didn't fix 'Name VirtualHost *:80' in the example. Is that a mistake in the example or your files? –  Graham Dumpleton Feb 25 '12 at 4:14
    
Ah, that was just a mistake in the example, not the actual files. Anyway, I got it working now - was just a matter of rearranging the filesystem. Thanks! –  LBR Feb 25 '12 at 5:17
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.