Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
305 views
in Technique[技术] by (71.8m points)

python - Installing mod_wsgi on WAMP server running on Windows 7

I downloaded mod_wsgi from the following location for apache 2.2 and python 2.7 (64bit). (I'm trying to get django to run on my computer).

Whenever I add the following line:

LoadModule wsgi_module modules/mod_wsgi.so

Apache fails to start up. Can anyone tell me what the issue might be?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.

  1. Download mod_wsgi-win32-ap22py27-3.3.so. Or download your respective .so compatible file

  2. Change its name to mod_wsgi.so and copy it to /Program Files/Apache Software Foundation/Apache22/modules on Windows.

  3. Open httpd.conf using Admin rights. Now, you will find a list of lines with LoadModule .... Just add LoadModule wsgi_module modules/mod_wsgi.so to that list.

    Your are partially done.. you can restart the apache and shouldn't find any errors.

  4. Now you need to link it to your Django project.

  5. In your Django project root folder, add apache folder and create django.wsgi (don't change this name) and apache_mydjango.conf.

  6. 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, 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()

Open apache_djang_wsgi.conf and add:

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>

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:

  1. port25.technet.com | Published my microsoft.
  2. mod_wsgi Quick Install guide
  3. Django site
  4. Django site

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...