login community faq
1
1

I've read the previous question on this topic, and read the tutorial on the forum, but still something does not add up.

I'm trying to run two Django sites on one Apache instance. I've configured httpd.conf like this:

...

NameVirtualHost *:99999

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
# Virtual Hosts

<VirtualHost *:99999>
    ServerName www.mysite.net
    ServerAlias mysite.net
    KeepAlive Off
    WSGIDaemonProcess mysite.net processes=1 threads=20 inactivity-timeout=60 display-name=[wsgi-mysite]httpd
    WSGIProcessGroup mysite.net
    WSGIScriptAlias / /home/username/webapps/django/mysite.wsgi
</VirtualHost>

<VirtualHost *:99999>
    ServerName www.mysite2.net
    ServerAlias mysite2.net
    KeepAlive Off
    WSGIDaemonProcess mysite2.net processes=1 threads=20 inactivity-timeout=60 display-name=[wsgi-mysite2]httpd
    WSGIProcessGroup mysite2.net
    WSGIScriptAlias / /home/username/webapps/django/mysite2.wsgi
</VirtualHost>

Other than that, the settings are still unchanged from the defaults that used to work fine for just one site. Then, on the control panel, I have two different sites, each with their own domains and sharing the same Django app. I've restarted apache several times (stopped and started again, as well as restarted). When I access mysite2.net, however, I get the same result as accessing mysite.net (the first website).

Clearly, I've missed some setting somewhere. I have to say, this is my first time working with this kind of thing. Can anyone offer some advice?

UPDATE:

Here is the contents of my two .wsgi files:

1
2
3
4
5
6
7
import os
import sys

from django.core.handlers.wsgi import WSGIHandler

os.environ['DJANGO_SETTINGS_MODULE'] = 'mysite.settings'
application = WSGIHandler()

Mysite2:

1
2
3
4
5
6
7
import os
import sys

from django.core.handlers.wsgi import WSGIHandler

os.environ['DJANGO_SETTINGS_MODULE'] = 'mysite2.settings'
application = WSGIHandler()

I don't know what I've changed, but now I'm at least getting an error in my logs, which says the following:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
[Sun Jan 09 10:27:02 2011] [error] [client 127.0.0.1] mod_wsgi (pid=17779): Target WSGI script '/home/username/webapps/django/mysite.wsgi' cannot be loaded as Python module.
[Sun Jan 09 10:27:02 2011] [error] [client 127.0.0.1] mod_wsgi (pid=17779): Exception occurred processing WSGI script '/home/username/webapps/django/mysite.wsgi'.
[Sun Jan 09 10:27:02 2011] [error] [client 127.0.0.1] Traceback (most recent call last):
[Sun Jan 09 10:27:02 2011] [error] [client 127.0.0.1]   File "/home/username/webapps/django/mysite.wsgi", line 4, in <module>
[Sun Jan 09 10:27:02 2011] [error] [client 127.0.0.1]     from django.core.handlers.wsgi import WSGIHandler
[Sun Jan 09 10:27:02 2011] [error] [client 127.0.0.1] ImportError: No module named django.core.handlers.wsgi
[Sun Jan 09 10:27:03 2011] [error] [client 127.0.0.1] mod_wsgi (pid=17779): Target WSGI script '/home/username/webapps/django/mysite.wsgi' cannot be loaded as Python module.
[Sun Jan 09 10:27:03 2011] [error] [client 127.0.0.1] mod_wsgi (pid=17779): Exception occurred processing WSGI script '/home/username/webapps/django/mysite.wsgi'.
[Sun Jan 09 10:27:03 2011] [error] [client 127.0.0.1] Traceback (most recent call last):
[Sun Jan 09 10:27:03 2011] [error] [client 127.0.0.1]   File "/home/username/webapps/django/mysite.wsgi", line 4, in <module>
[Sun Jan 09 10:27:03 2011] [error] [client 127.0.0.1]     from django.core.handlers.wsgi import WSGIHandler
[Sun Jan 09 10:27:03 2011] [error] [client 127.0.0.1] ImportError: No module named django.core.handlers.wsgi

asked Jan 09 '11 at 10:15

Herman's gravatar image

Herman
7212

edited Jan 09 '11 at 11:15

Can you provide the contents of your mysite2.wsgi and mysite1.wsgi files?

(Jan 09 '11 at 10:18) aaronh ♦♦ aaronh's gravatar image

I've added more detail, as well as a newly-discovered error-log. Both sites are now reporting an internal error on load (obviously). The .wsgi file for mysite1 used to work fine before, so I don't see why it wouldn't work anymore.

(Jan 09 '11 at 10:36) Herman Herman's gravatar image

This is not right:

1
django.core.handlers.wsgi93

Do you have any strange or trailing characters in your .wsgi file?

(Jan 09 '11 at 10:55) David L ♦♦ David%20L's gravatar image

I see that (and fixed it), but no, it seems to be some sort of bug with this forum when I try to encapsulate code (I had to repetitively delete '93' from the start and end of my code, I missed that one. In the actual log, there is no '93'. It says ImportError: No module named django.core.handlers.wsgi

(Jan 09 '11 at 11:17) Herman Herman's gravatar image

Add the following to the top of your wsgi files:

1
sys.path = ['/home/username/webapps/django', '/home/username/webapps/django/lib/python2.6'] + sys.path

Replace username with your username.

answered Jan 09 '11 at 12:28

aaronh's gravatar image

aaronh ♦♦
12743

Note sure if this is the appropriate place for this, but for those of you using virtualenvs on Webfaction and have been running into the above problem, make sure your wsgi file is properly configured (as described above) PLUS be sure you have the appropriate virtualenv initiated when restarting the server.

answered Nov 02 '11 at 17:42

Clayton%20Thompson's gravatar image

Clayton Thompson
1

Your answer
If you have an answer to the above question, then use the form below. Otherwise, use the appropriate 'add new comment' button above to post your feedback.
toggle preview

Plans & prices    Sign up    Why WebFaction?    Contact us    Affiliate program    Support    Legal    Jobs    Blog    Control panel login
Powered by OSQA
© Copyright 2003-2012 Swarma Limited - WebFaction is a service of Swarma Limited