Installing mod_wsgi on WAMP server running on Windows 7
These are the following things you need to do to setup Apache for Django. I assume you are using Python 2.7 (32-bit) on Windows (32-bit) with WAMP server (32-bits) installed.
Download mod_wsgi-win32-ap22py27-3.3.so. Or download your respective .so compatible file
Change its name to
mod_wsgi.so
and copy it to/Program Files/Apache Software Foundation/Apache22/modules
on Windows.Open
httpd.conf
using Admin rights. Now, you will find a list of lines withLoadModule ...
. Just addLoadModule wsgi_module modules/mod_wsgi.so
to that list.Your are partially done.. you can restart the apache and shouldn't find any errors.
Now you need to link it to your Django project.
In your Django project root folder, add
apache
folder and createdjango.wsgi
(don't change this name) andapache_mydjango.conf
.In
httpd.conf
add the following line at the bottom of the page.Include "d:/projects/mysite/apache_django_wsgi.conf"
Open django.wsgi
and add the following lines:
import os, syssys.path.append('d:/projects/mysite')os.environ['DJANGO_SETTINGS_MODULE'] = 'mysite.settings'import django.core.handlers.wsgiapplication = django.core.handlers.wsgi.WSGIHandler()
Open apache_djang_wsgi.conf
and add:
Alias /images/ "d:/projects/mysite/templates/images/"<Directory "d:/projects/mysite/images>Order allow,denyAllow from all</Directory>WSGIScriptAlias / "d:/projects/mysite/apache/django.wsgi"<Directory "d:/projects/mysite/apache">Allow from all</Directory><VirtualHost *:80> DocumentRoot d:/projects/mysite ServerName 127.0.0.1</VirtualHost>
Note:
I am assuming your Django project hierarchy is something like this:
mysite/ mysite/ settings.py urls.py, wsgi.py. manage.py <apache> / apache_django_wsgi.conf, django.wsgi
Best tutorial links:
Actually I don't understand why people are unable to fix it. I've seen lots of questions on it here and I even posted few...So, I thought to write a initial setup version directly as answer
Try the following websites for the unofficial windows binaries for python extensionshttp://www.kaij.org/blog/?p=123https://github.com/kirang89/pycrumbs/pull/28
Just in case anyone is using this and doesn't spot it, there is an inconsistency in the steps. In Step 5 it refers to the filename apache_mydjango.conf
In Step 6 it refers to the filename apache_django_wsgi.conf
These should obviously both be the same name - it doesn't matter which way round you go for - but I spent a while trying to figure out why it wasn't working.