WebFaction
Community site: login 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

# 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:

import os
import sys

from django.core.handlers.wsgi import WSGIHandler

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

Mysite2:

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:

[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 09 Jan '11, 10:15

Herman
72712
accept rate: 0%

edited 09 Jan '11, 11:15

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

(09 Jan '11, 10:18) aaronh ♦♦

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.

(09 Jan '11, 10:36) Herman

This is not right:

django.core.handlers.wsgi93

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

(09 Jan '11, 10:55) David L ♦♦

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

(09 Jan '11, 11:17) Herman

Add the following to the top of your wsgi files:

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

Replace username with your username.

permanent link

answered 09 Jan '11, 12:28

aaronh ♦♦
1.3k3
accept rate: 34%

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.

permanent link

answered 02 Nov '11, 17:42

Clayton Thom...
1
accept rate: 0%

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×224
×27
×6

question asked: 09 Jan '11, 10:15

question was seen: 5,235 times

last updated: 02 Nov '11, 17:42

WEBFACTION
REACH US
SUPPORT
AFFILIATE PROGRAM
LEGAL
© COPYRIGHT 2003-2019 SWARMA LIMITED - WEBFACTION IS A SERVICE OF SWARMA LIMITED
REGISTERED IN ENGLAND AND WALES 5729350 - VAT REGISTRATION NUMBER 877397162
5TH FLOOR, THE OLD VINYL FACTORY, HAYES, UB3 1HA, UNITED KINGDOM