You should note that I do not advise running Microsoft Windows. Or any software that is end-of-life, unless you are able to patch it yourself. And, so, I especially do not advise people to go configure Windows 7 to host Django using mod_wsgi
Configuring Django on a WAMP Host
Getting Apache ready for Django, on a WAMP host machine, can sometimes be problematic. Particularly because setting up mod_wsgi on Windows (in this case Windows 7) isn’t always straight forward. I’ll be using the deprecated Python 2.7 on Windows with WampServer installed.
Install the mod_wsgi Apache module
- Download mod_wsgi-win32-ap22py27-3.3.so. Or download your respective .so compatible file
- Change its name to
- Copy it to
$DRIVE/Program Files/Apache Software Foundation/Apache22/modules
httpd.confas Administrator, or equal. Here, you’re going to find a list of lines with “
LoadModule” followed by a bunch of other “.so” files. Simply add
LoadModule wsgi_module modules/mod_wsgi.soto that list.
- Restart Apache.
Creating Configuration Files for Django on WAMP
- Next you have to point it at Django
- In your Django project root folder, create an
- Change into that directory and create a file named
- And, finally create a file named
- Go back to apache’s
httpd.confand add the following line at the bottom of the page:
- Now put these lines in
Populating Configurations for Django on WAMP
import os, sys sys.path.append('D:/projects/mysite') os.environ['DJANGO_SETTINGS_MODULE'] = 'mysite.settings' import django.core.handlers.wsgi application = django.core.handlers.wsgi.WSGIHandler()
Alias /images/ "D:/projects/mysite/templates/images/" <Directory "D:/projects/mysite/images> Order allow,deny Allow 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>