Deploying multiple Django projects in apache using windows

I am trying to give a domain name and run several django projects on my apache, at the moment I managed to host one application and run it on 127.0.0.1:8888 . Settings look like this.

WSGIScriptAlias / C:/Users/ShabeerSheffa/workspace/ApacheDemo/ApacheDemo/wsgi.py WSGIPythonPath C:/Users/ShabeerSheffa/workspace/ApacheDemo <Directory C:/Users/ShabeerSheffa/workspace/ApacheDemo> <Files wsgi.py> Order deny,allow Allow from all </Files> </Directory> 

I tried to modify the code above to look like the code below with the domain name, so I could access it using apachedemo.com , but failed.

 NameVirtualHost apachedemo.com <VirtualHost apachedemo.com> ServerName apachedemo.com ServerAlias www.apachedemo.com WSGIScriptAlias / C:/Users/ShabeerSheffa/workspace/ApacheDemo/ApacheDemo/wsgi.py WSGIPythonPath C:/Users/ShabeerSheffa/workspace/ApacheDemo DocumentRoot C:/Users/ShabeerSheffa/workspace/ApacheDemo <Directory C:/Users/ShabeerSheffa/workspace/ApacheDemo> <Files wsgi.py> Order deny,allow Allow from all </Files> </Directory> </VirtualHost> 

I am currently using port 8888 for my apache on a Windows 7 machine, 127.0.0.1:8888 worked for the first version of the code, but after editing the code, apache gives an error when restarting apache.

This is what my host file looks like, I just added the last line. (not quite sure why there are # in the second and third lines)

 # localhost name resolution is handled within DNS itself. # 127.0.0.1 localhost # ::1 localhost 127.0.0.1:8888 apachedemo.com www.apachedemo.com 

I am trying to find answers to two questions -

  • How to make apachedemo.com work
  • How to add another project to one server, for example apachedemo2.com

EDIT: I develop my projects using eclipse

Thank you very much for helping the guys

+7
source share
3 answers

Try the configuration below. You may also find this question helpful, and there is a virtualhosts section in the wsgi docs module that can help you.

 WSGIPythonPath C:/Users/ShabeerSheffa/workspace/ApacheDemo <VirtualHost apachedemo.com:8888> ServerName apachedemo.com WSGIScriptAlias / C:/Users/ShabeerSheffa/workspace/ApacheDemo/ApacheDemo/wsgi.py <Directory C:/Users/ShabeerSheffa/workspace/ApacheDemo> <Files wsgi.py> Order deny,allow Allow from all </Files> </Directory> </VirtualHost> <VirtualHost apachedemo2.com:8888> ServerName apachedemo2.com WSGIScriptAlias / C:/Users/ShabeerSheffa/workspace/ApacheDemo/apachedemo2/wsgi.py <Directory C:/Users/ShabeerSheffa/workspace/ApacheDemo> <Files wsgi.py> Order deny,allow Allow from all </Files> </Directory> </VirtualHost> 

Update

In one of the comments below you can have different WSGIPythonPath in each virtual host. Looking at the configuration documents, WSGIPythonPath can only be in the context server configuration, and not in virtualhost. However, you can add wsgi files to this path as in this answer . You can also try and see WSGIDaemonProcess with python-path, as shown in this question .

+4
source

Make sure you read:

The automatically generated wsgi.py file in Django 1.4 does things in such a way that you cannot place two instances of Django in the same process under different sub-interpreters. You will need to modify the wsgi.py file.

This is in addition to any problems that may arise when configuring Apache, if you still have one. Because, although you are vague about what the error is when providing error messages, itโ€™s hard to guess what your problem is.

+4
source

The best solution is to run each Django project in its own WSGI process inside its own Django instance.

 WSGIPythonPath /var/www/path/web:/var/www/path/api WSGIDaemonProcess api_wsgi user=user group=group WSGIScriptAlias /api /var/www/path/api/wsgi.py <Location /api> WSGIProcessGroup api_wsgi </Location> WSGIDaemonProcess web_wsgi user=user group=group WSGIScriptAlias /web /var/www/path/web/wsgi.py <Location /web> #SetEnv DJANGO_SETTINGS_MODULE project.settigs WSGIProcessGroup web_wsgi </Location> 

Related post: http://www.area0x33.com/blog/?p=155

+1
source

All Articles