You are not logged in.

  • Index
  •  » Django
  •  » Running multiple Django sites from the same Apache/mod_python instance

#1 2006-10-19 03:30:30

remi
Member
From: London
Registered: 2006-09-19
Posts: 716
Website

Running multiple Django sites from the same Apache/mod_python instance

itgoesclick wrote:

The "Shared hosting plans" page says for "Shared 2" you can:
Run up to 5 small to medium:
...
* Django sites
...
However when I try and add a second Django site it says I can't do it.
How do I configure small Django sites 4-5?

You can easily run multiple Django projects within the same Apache/mod_python instance.
To do so, put all your Django projects under the same webapp (for instance: $HOME/webapps/django/project1, $HOME/webapps/django/project2, .etc.).

Then edit your httpd.conf file (in $HOME/webapps/django/apache2/conf/) and include a NameVirtualHost directive and multiple VirtualHost sections like this:

NameVirtualHost *:<port>

<VirtualHost *:<port>>
  ServerName www.domain1.com
  ServerAlias domain1.com
  DocumentRoot /<home>/webapps/django/project1
  <Location "/">
    SetHandler python-program
    PythonHandler django.core.handlers.modpython
    SetEnv DJANGO_SETTINGS_MODULE project1.settings
    PythonPath "['/<home>/webapps/django'] + sys.path"
    PythonDebug On
    </Location>
    <Location "/media">
        SetHandler none
    </Location>
</VirtualHost>

<VirtualHost *:<port>>
  ServerName www.domain2.com
  ServerAlias domain2.com
  DocumentRoot /<home>/webapps/django/project2
  <Location "/">
    SetHandler python-program
    PythonHandler django.core.handlers.modpython
    SetEnv DJANGO_SETTINGS_MODULE project2.settings
    PythonPath "['/<home>/webapps/django'] + sys.path"
    PythonDebug On
    </Location>
    <Location "/media">
        SetHandler none
    </Location>
</VirtualHost>

Replace <home>, <port>, the domain names and the project paths with the actual values.

Restart Apache.

Remi.


WebFaction - Smarter web hosting

Offline

 

#2 2006-11-02 17:59:07

itgoesclick
Member
Registered: 2006-11-02
Posts: 7

Re: Running multiple Django sites from the same Apache/mod_python instance

When I do this, I get a warning regarding the first one being on a given port and the second on the same port. When I atempt to go to my www.domain2.com I get what is what is at www.domain1.com

-- solution found --

I had to add a  NameVirtualHost directive (I placed it right after the listen directive)

NameVirtualHost *:<port>

where port is the port already in your listen directive.

Last edited by itgoesclick (2006-11-02 18:11:00)

Offline

 

#3 2006-11-20 19:25:54

tttallis
Member
Registered: 2006-11-19
Posts: 4

Re: Running multiple Django sites from the same Apache/mod_python instance

Remi - this approach works fine as long as the sites don't share the same namespace.

I have the classic situation where I am trying to run a development, staging, and production version of a site, all using the same database and media files. Predictably, I'm using subversion to keep them in sync. There are quite a few internal references to the project name, so I need each project to have the same name, otherwise these references will get "crossed over". Can you suggest a way of doing this sort of setup on WebFaction?

I've currently got this set up on DreamHost, but it's a bit flakey, which is why I decided to move it to WebFaction. So far I've installed one copy of the site on WebFaction, and it's rock-solid, so I'm really keen to move the others over as well. Please don't tell me I have to move back to DreamHost! :-(

Thomas

Offline

 

#4 2006-11-20 20:29:15

IAIHMB
Member
From: Hudson, Florida.
Registered: 2006-09-19
Posts: 1362

Re: Running multiple Django sites from the same Apache/mod_python instance

Can you give a brief description of how you've got things set up on DreamHost?


-David Sissitka

Offline

 

#5 2006-11-21 14:35:27

skabber
Member
Registered: 2006-09-19
Posts: 5

Re: Running multiple Django sites from the same Apache/mod_python instance

Ya when I set up an apache conf like this and start it I get.
[Tue Nov 21 14:32:51 2006] [warn] _default_ VirtualHost overlap on port 2878, the first has precedence

Offline

 

#6 2006-11-21 16:52:42

tttallis
Member
Registered: 2006-11-19
Posts: 4

Re: Running multiple Django sites from the same Apache/mod_python instance

IAIHMB wrote:

Can you give a brief description of how you've got things set up on DreamHost?

DreamHost is a completely different kettle of fish - using fcgi rather than mod_python.

I simply have each instance running under a separate user, so all the code lives in separate directories, and I can kill each user's python process individually. I simply point a different sub-domain at each Django instance and it all works - except not too fast, and lately the one instance that gets a bit of traffic keeps locking up.

Offline

 

#7 2006-11-21 23:03:40

IAIHMB
Member
From: Hudson, Florida.
Registered: 2006-09-19
Posts: 1362

Re: Running multiple Django sites from the same Apache/mod_python instance

I've tested the following and it works:

Code:

ServerRoot "/home2/iaihmb/webapps/test/apache2"
LoadModule python_module /home2/iaihmb/webapps/test/apache2/modules/mod_python.so
LoadModule log_config_module /home2/iaihmb/webapps/test/apache2/modules/mod_log_config.so
LoadModule dir_module /home2/iaihmb/webapps/test/apache2/modules/mod_dir.so
LoadModule mime_module /home2/iaihmb/webapps/test/apache2/modules/mod_mime.so
LoadModule rewrite_module /home2/iaihmb/webapps/test/apache2/modules/mod_rewrite.so
LoadModule env_module /home2/iaihmb/webapps/test/apache2/modules/mod_env.so
Listen 2857
User iaihmb
Group iaihmb
LogFormat "%{X-Forwarded-For}i %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
CustomLog /home2/iaihmb/webapps/test/apache2/logs/access.log combined
Errorlog /home2/iaihmb/webapps/test/apache2/logs/error.log
DirectoryIndex index.py
ServerLimit 2
<VirtualHost *:2857>
    ServerName iaihmb.webfactional.com
    DocumentRoot /home2/iaihmb/webapps/test
    <Location "/env1">
        SetHandler python-program
        PythonHandler django.core.handlers.modpython
        SetEnv DJANG0_SETTINGS_MODULE myproject.settings
        PythonPath "['/home2/iaihmb/webapps/test/env1'] + sys.path"
        PythonDebug On
        PythonInterpreter env1
    </Location>
    <Location "/env2">
        SetHandler python-program
        PythonHandler django.core.handlers.modpython
        SetEnv DJANGO_SETTINGS_MODULE myproject.settings
        PythonPath "['/home2/iaihmb/webapps/test/env2'] + sys.path"
        PythonDebug On
        PythonInterpreter env2
    </Location>
    <Location "/env3">
        SetHandler python-program
        PythonHandler django.core.handlers.modpython
        SetEnv DJANGO_SETTINGS_MODULE myproject.settings
        PythonPath "['/home2/iaihmb/webapps/test/env3'] + sys.path"
        PythonDebug On
        PythonInterpreter env3
    </Location>
</VirtualHost>

Hope it helps.


-David Sissitka

Offline

 

#8 2006-11-23 19:18:02

tttallis
Member
Registered: 2006-11-19
Posts: 4

Re: Running multiple Django sites from the same Apache/mod_python instance

David's solution works if you have each django instance running at separate directory within the same domain name. However I needed to have each instance running under its own subdomain. Fortunately Remi came up with the following, which works well:

Remi wrote:

Well, I did some testing and I think I got what you want working.
Here is what I did:

I created one django app with the control panel ($HOME/webapps/django)
I created 3 sub-directories (sub1, sub2 and sub3) and put a Django project (myproject) in each of them.
So I have the following files:

[test12@web4 django]$ pwd
/home2/test12/webapps/django
[test12@web4 django]$ ls -R
.:
apache2 sub1 sub2 sub3

./apache2:
bin conf logs modules

./apache2/bin:
httpd start stop

./apache2/conf:
httpd.conf mime.types

./apache2/logs:
access.log error.log httpd.pid

./apache2/modules:
libphp5.so mod_cgi.so mod_include.so mod_python.so
mod_access.so mod_dav_fs.so mod_info.so mod_rewrite.so
mod_actions.so mod_dav.so mod_ldap.so mod_setenvif.so
mod_alias.so mod_dav_svn.so mod_log_config.so mod_speling.so
mod_asis.so mod_deflate.so mod_log_forensic.so mod_ssl.so
mod_auth_anon.so mod_dir.so mod_logio.so mod_status.so
mod_auth_dbm.so mod_disk_cache.so mod_mem_cache.so mod_suexec.so
mod_auth_digest.so mod_env.so mod_mime_magic.so mod_unique_id.so
mod_auth_ldap.so mod_expires.so mod_mime.so mod_userdir.so
mod_auth.so mod_ext_filter.so mod_negotiation.so mod_usertrack.so
mod_authz_svn.so mod_fastcgi.so mod_proxy_connect.so mod_vhost_alias.so
mod_autoindex.so mod_file_cache.so mod_proxy_ftp.so
mod_cache.so mod_headers.so mod_proxy_http.so
mod_cern_meta.so mod_imap.so mod_proxy.so

./sub1:
myproject

./sub1/myproject:
__init__.py manage.py settings.pyc urls.pyc
__init__.pyc settings.py urls.py

./sub2:
myproject

./sub2/myproject:
__init__.py manage.py settings.pyc urls.pyc
__init__.pyc settings.py urls.py

./sub3:
myproject

./sub3/myproject:
__init__.py manage.py settings.py urls.py
[test12@web4 django]$


Then I created 3 subdomains (sub1|2|3.test12.webfactional.com) and mounted my django app on these subdomains with the control panel.

Then I used the following httpd.conf file:

Listen 127.0.0.1:2678
NameVirtualHost 127.0.0.1:2678
ServerRoot "/home2/test12/webapps/django/apache2"
LoadModule python_module /home2/test12/webapps/django/apache2/modules/mod_python.so
LoadModule log_config_module /home2/test12/webapps/django/apache2/modules/mod_log_config.so
LoadModule dir_module /home2/test12/webapps/django/apache2/modules/mod_dir.so
LoadModule mime_module /home2/test12/webapps/django/apache2/modules/mod_mime.so
LoadModule rewrite_module /home2/test12/webapps/django/apache2/modules/mod_rewrite.so
LoadModule env_module /home2/test12/webapps/django/apache2/modules/mod_env.so
User test12
Group test12
LogFormat "%{X-Forwarded-For}i %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
CustomLog /home2/test12/webapps/django/apache2/logs/access.log combined
Errorlog /home2/test12/webapps/django/apache2/logs/error.log
ServerLimit 2
<VirtualHost 127.0.0.1:2678>
ServerName sub1.test12.webfactional.com
DocumentRoot /home2/test12/webapps/django/sub1/myproject
<Location "/">
SetHandler python-program
PythonHandler django.core.handlers.modpython
SetEnv DJANGO_SETTINGS_MODULE myproject.settings
PythonPath "['/home2/test12/webapps/django/sub1'] + sys.path"
PythonDebug On
</Location>
</VirtualHost>

<VirtualHost 127.0.0.1:2678>
ServerName sub2.test12.webfactional.com
DocumentRoot /home2/test12/webapps/django/sub2/myproject
<Location "/">
SetHandler python-program
PythonHandler django.core.handlers.modpython
SetEnv DJANGO_SETTINGS_MODULE myproject.settings
PythonPath "['/home2/test12/webapps/django/sub2'] + sys.path"
PythonDebug On
</Location>
</VirtualHost>

<VirtualHost 127.0.0.1:2678>
ServerName sub2.test12.webfactional.com
DocumentRoot /home2/test12/webapps/django/sub3/myproject
<Location "/">
SetHandler python-program
PythonHandler django.core.handlers.modpython
SetEnv DJANGO_SETTINGS_MODULE myproject.settings
PythonPath "['/home2/test12/webapps/django/sub3'] + sys.path"
PythonDebug On
</Location>
</VirtualHost>

So if you want to use this approach on your own account, just swap in your own domains names, directory names and port number. You can determine your port number by looking in your existing httpd.conf file (look for the line that starts with 'Listen').

The one oustanding issue is that I don't have a way of rebooting each instance separately. This means that each time I make a change to the development server I have to reboot all three instances - which is not really ideal.

I tried to set 'MaxRequestsPerChild 1' for the development server only, so that I don't have to restart apache to see changes. (This is recommended by the Django folks at http://www.djangoproject.com/documentat … mod-python). But unfortunately I can't put this directive anywhere inside the <VirtualHost> section, hence I can only set it for all 3 sites, or none.

As an alternative approach, I tried putting 'PythonAutoReload On' inside the <Location "/"> block, but this did not produce the desired effect. I'm not sure why, although a quick Google search indicated that this directive has been buggy in some recent versions of mod_python. In any case I'm convinced that it's meant to do what I want.

I guess my best option might be to do development off-line, but then I lose the luxury of developing with a well-populated database. If there were some way I could  install Django elsewhere, but connect to my database on WebFaction I could get around this, but I don't think external access to databases is possible with WebFaction. Does anyone know if there is a way to do this?

It also occurs to me that I could bypass Apache and mod_python for the development server, and use the built-in Django development server, but I don't have any idea how to configure the IP address and port number so that I can access it remotely. It also seems quite likely that this wouldn't work at all in a shared hosting environment.

Thomas

Offline

 

#9 2006-11-23 19:50:34

tttallis
Member
Registered: 2006-11-19
Posts: 4

Re: Running multiple Django sites from the same Apache/mod_python instance

Thomas wrote:

It also occurs to me that I could bypass Apache and mod_python for the development server, and use the built-in Django development server, but I don't have any idea how to configure the IP address and port number so that I can access it remotely. It also seems quite likely that this wouldn't work at all in a shared hosting environment.

Actually I got it working fine. I just had to cd into my project directory and then enter:

Code:

python2.4 manage.py runserver 0.0.0.0:8000

You can then access your site at the address you gave it in the httpd.conf file, but just add the port number '8000' to the end of the url (eg. http://whatever.com:8000).

Offline

 

#10 2006-11-23 22:01:32

IAIHMB
Member
From: Hudson, Florida.
Registered: 2006-09-19
Posts: 1362

Re: Running multiple Django sites from the same Apache/mod_python instance

I guess my best option might be to do development off-line, but then I lose the luxury of developing with a well-populated database. If there were some way I could  install Django elsewhere, but connect to my database on WebFaction I could get around this, but I don't think external access to databases is possible with WebFaction. Does anyone know if there is a way to do this?

I'm surprised that you don't develop locally, I find it more productive especially when debugging. Since you're using Subversion to manage your project that would make things really easy. You could even take things a step further and add Capistrano to the mix. You never mentioned what database you were using, but I just tried using MySQL's GRANT and it's off limits. If SQLite is an option it's something that you might want to consider, since SQLite databases consist of a flat file you could keep it under version control.

Last edited by IAIHMB (2006-11-23 22:02:00)


-David Sissitka

Offline

 

#11 2006-11-28 05:07:15

kryton
Member
Registered: 2006-11-28
Posts: 1

Re: Running multiple Django sites from the same Apache/mod_python instance

I've had 5-6 django virtual hosts run successfully in the same instance.

the trick is to add
PythonInterpreter #SITENAME#
into the virtual host config for each site.
that way they each have a seperate python interpreter and you avoid getting some weird and wonderful errors.

Offline

 

#12 2006-12-06 18:26:59

landslideinc
Member
Registered: 2006-10-11
Posts: 11

Re: Running multiple Django sites from the same Apache/mod_python instance

Ok, how about this possibility?

I have one project/application that I want to run on three different urls (subdomain1.domain1.com, subdomain2.domain1.com, domain2.com) with three different sets of data.  I'm using Django's site framework so I've set up three domains in the admin section and I've created three settings files each with a different SITE_ID and I've set up my http.conf file similar to what is in the first post of this thread.  Now I'm running all three domains off of one website as defined in the Webfaction control panel. 
When I visit the urls, only the first one works while the other two do not (I'm getting a Django error which I don't understand)

Am I close with this setup?  Do I need to set up a discreet Website for each domain in Webfaction's control panel?  Do I need to change some other setting?  Possibly give each site its own URL conf?

Any ideas?

Thanks,
Condredge

Offline

 

#13 2006-12-07 12:24:59

landslideinc
Member
Registered: 2006-10-11
Posts: 11

Re: Running multiple Django sites from the same Apache/mod_python instance

Ok, I've tried adding another site for one of my domains, but I'm still getting the same error, so that's ruled out. Any ideas?

Offline

 

#14 2006-12-08 03:56:39

remi
Member
From: London
Registered: 2006-09-19
Posts: 716
Website

Re: Running multiple Django sites from the same Apache/mod_python instance

landslideinc wrote:

Ok, I've tried adding another site for one of my domains, but I'm still getting the same error, so that's ruled out. Any ideas?

Are you sharing the same files for your 3 Django sites ? Maybe you should copy the project files three times ?

Remi.


WebFaction - Smarter web hosting

Offline

 

#15 2006-12-08 09:00:58

landslideinc
Member
Registered: 2006-10-11
Posts: 11

Re: Running multiple Django sites from the same Apache/mod_python instance

Yeah, that might be what I need to do.  I was hoping they could all run off of the same codebase since they will all be basically the same sites with different content and make use of the CurrentSiteManager to control what data is sent to the browser.  Presumably it is possible.  But maybe it isn't actually what I'll want down the line when the sites begin to diverge more.


Of course at the moment it doesn't matter because I've screwed up all three so that none of them are actually working!  I think it is time to wipe the slate clean, uninstall Django and my Database and try it again.

Thanks for your help Remi!

Offline

 

#16 2007-01-29 23:23:21

luxagraf
Member
Registered: 2006-11-30
Posts: 4

Re: Running multiple Django sites from the same Apache/mod_python instance

I'm running basically the same setup as tttallis outlines above, but I only have two VirtualHosts. Everything works fine except that when Django uses its APPEND_SLASH setting to add slashes the port number gets appended to the base url... in other words a request for http://mysite.com/photos becomes http://mysite.com:2694/photos/

Can anyone explain why that's happening and how I can fix it?

Offline

 

#17 2007-03-18 13:44:45

skam
Member
Registered: 2007-03-18
Posts: 2

Re: Running multiple Django sites from the same Apache/mod_python instance

luxagraf wrote:

I'm running basically the same setup as tttallis outlines above, but I only have two VirtualHosts. Everything works fine except that when Django uses its APPEND_SLASH setting to add slashes the port number gets appended to the base url... in other words a request for http://mysite.com/photos becomes http://mysite.com:2694/photos/

Can anyone explain why that's happening and how I can fix it?

I've got the same problem, and APPEND_SLASH is set to False in my settings.py
I think that it not depends on Django, PREPEND_WWW = True works correctly without adding the port number in the base url.

Offline

 

#18 2007-03-18 13:57:58

skam
Member
Registered: 2007-03-18
Posts: 2

Re: Running multiple Django sites from the same Apache/mod_python instance

skam wrote:

luxagraf wrote:

I'm running basically the same setup as tttallis outlines above, but I only have two VirtualHosts. Everything works fine except that when Django uses its APPEND_SLASH setting to add slashes the port number gets appended to the base url... in other words a request for http://mysite.com/photos becomes http://mysite.com:2694/photos/

Can anyone explain why that's happening and how I can fix it?

I've got the same problem, and APPEND_SLASH is set to False in my settings.py
I think that it not depends on Django, PREPEND_WWW = True works correctly without adding the port number in the base url.

The problem persists also if I remove 'django.middleware.common.CommonMiddleware' from MIDDLEWARE_CLASSES

Offline

 

#19 2007-03-19 18:24:25

mezhaka
Member
From: Belarus, Minsk
Registered: 2007-03-11
Posts: 4
Website

Re: Running multiple Django sites from the same Apache/mod_python instance

tttallis wrote:

The one outstanding issue is that I don't have a way of rebooting each instance separately. This means that each time I make a change to the development server I have to reboot all three instances - which is not really ideal.

that's been puzzling me as well. having separate apache instances for development and production sites would be great. i am not sure this will work out, but anyway someone might try:
the ~/webapps/django/apache2/bin/start script basically just does

Code:

~/webapps/django/apache2/bin/httpd -f /home2/styler/webapps/django/apache2/conf/httpd.conf

and the stop script uses system's kill in conjunction with ps. so if it where it possible to split httpd.conf into development and release parts,  thus we'd gain the ability to start\stop\restart httd passing a different configuration files. did not tried it yet though.

Offline

 

#20 2007-07-14 03:31:56

remi
Member
From: London
Registered: 2006-09-19
Posts: 716
Website

Re: Running multiple Django sites from the same Apache/mod_python instance

skam wrote:

luxagraf wrote:

I'm running basically the same setup as tttallis outlines above, but I only have two VirtualHosts. Everything works fine except that when Django uses its APPEND_SLASH setting to add slashes the port number gets appended to the base url... in other words a request for http://mysite.com/photos becomes http://mysite.com:2694/photos/

Can anyone explain why that's happening and how I can fix it?

I've got the same problem, and APPEND_SLASH is set to False in my settings.py
I think that it not depends on Django, PREPEND_WWW = True works correctly without adding the port number in the base url.

If anyone is still having that problem, the trailing slash is added by apache (the request doesn't even make it to Django). This behavior is caused by the "mod_dir" module, so if you remove the "LoadModule dir_module ..." and the "DirectoryIndex ..." lines from your apache config the problem will go away.

Note that our Django installer was fixed a while ago so new Django apps don't load "mod_dir" in the apache config anymore.

Cheers,

Remi.


WebFaction - Smarter web hosting

Offline

 

#21 2008-01-09 18:17:04

Baxter
Member
Registered: 2006-11-27
Posts: 33

Re: Running multiple Django sites from the same Apache/mod_python instance

OK, this may be a dumb question, but that's never stopped me before...

I think I get the virtual host up above, but I'm not sure it'll fix my case. I need two sites, but they'll share a lot of code. Ideally I'd like something like

site1/
site2/
shared/

With the sites going to domains and shared just hanging in the background. Problem is, I'm not seeing how to get shared on the path. What am I missing?

Offline

 

#22 2008-01-09 20:06:31

IAIHMB
Member
From: Hudson, Florida.
Registered: 2006-09-19
Posts: 1362

Re: Running multiple Django sites from the same Apache/mod_python instance

Do you mean that you'd like the shared/ directory to be in your PYTHONPATH? If so, add it to your PYTHONPATH lines:

PythonPath "['/home/example/webapps/django/', 'XXX/shared/'] + sys.path"

If that's not what you mean then you're going to have to explain the desired affect in a little more detail.

Hope it helps. smile


-David Sissitka

Offline

 

#23 2008-01-09 20:16:19

Baxter
Member
Registered: 2006-11-27
Posts: 33

Re: Running multiple Django sites from the same Apache/mod_python instance

Yeah, kind of... I'm looking for two sites off one django instance (as outlined above using virtualhosts), but then I need "shared" on the path, too, available to both, but not really a site of it's own.
I'm currently trying the code you posted above, but I'm getting a 503 -- just trying to get the two sites running, then figure I'll sort out the shared code.

Offline

 

#24 2008-01-09 21:33:33

Baxter
Member
Registered: 2006-11-27
Posts: 33

Re: Running multiple Django sites from the same Apache/mod_python instance

This is going poorly. If I use IAIHMB's example, I can't import my settings:
    raise ImportError, "Could not import settings '%s' (Is it on sys.path? Does it have syntax errors?): %s" % (self.SETTINGS_MODULE, e)

If I use Remi's example, I get a DJANGO_SETTINGS_MODULE not set error.

Offline

 

#25 2008-02-12 15:10:44

SpyderFCS
Member
Registered: 2007-02-03
Posts: 27
Website

Re: Running multiple Django sites from the same Apache/mod_python instance

I'm having some issues running two completely separate domains from the same django instance.  I have two projects within my django folder and each of them are assigned a unique set of apps and separate mysql databases.  Right now I have them sharing the 'media' folder but I will be changing that so they are running completely independent of each other.

Anyway, the problem I have is the when I visit www.domain1.com it loads perfect but when I go to www.domain2.com it loads the content from domain1.  I'm now 100% sure what is going on.  Below is my http.conf which i think is set up correctly although I have a suspicion that I am missing one thing that is throwing it off.  I'm think something with the ports but I' not sure...

Code:

ServerRoot "/home2/username/webapps/django/apache2"
LoadModule python_module /home2/username/webapps/django/apache2/modules/mod_python.so
LoadModule log_config_module /home2/username/webapps/django/apache2/modules/mod_log_config.so
LoadModule mime_module /home2/username/webapps/django/apache2/modules/mod_mime.so
LoadModule env_module /home2/username/webapps/django/apache2/modules/mod_env.so
Listen 2956
User username
Group username
LogFormat "%{X-Forwarded-For}i %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
CustomLog /home2/username/webapps/django/apache2/logs/access.log combined
Errorlog /home2/username/webapps/django/apache2/logs/error.log
ServerLimit 2

<VirtualHost *:2956>
  ServerName www.domain1.com
  ServerAlias domain1.com
  DocumentRoot /home2/username/webapps/django/project1
  <Location "/">
    SetHandler python-program
    PythonHandler django.core.handlers.modpython
    SetEnv DJANGO_SETTINGS_MODULE project1.settings
    PythonPath "['/home2/username/webapps/django','/home2/username/webapps/django/project1'] + sys.path"
    PythonDebug On
    </Location>
    <Location "/media">
        SetHandler none
    </Location>
</VirtualHost>

<VirtualHost *:2956>
  ServerName www.domain2..com
  ServerAlias domain2.com
  DocumentRoot /home2/username/webapps/django/project2
  <Location "/">
    SetHandler python-program
    PythonHandler django.core.handlers.modpython
    SetEnv DJANGO_SETTINGS_MODULE project2.settings
    PythonPath "['/home2/username/webapps/django','/home2/username/webapps/django/project2'] + sys.path"
    PythonDebug On
    </Location>
    <Location "/media">
        SetHandler none
    </Location>
</VirtualHost>

EDIT

I'm assuming I need to change the port of the second site but I'm not sure to what....

Code:

[warn] _default_ VirtualHost overlap on port 2956, the first has precedence

Last edited by SpyderFCS (2008-02-12 19:30:01)

Offline

 
  • Index
  •  » Django
  •  » Running multiple Django sites from the same Apache/mod_python instance

Board footer

Powered by PunBB
© Copyright 2002–2005 Rickard Andersson