且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

WAMP的服务器上安装mod_wsgi的Windows 7上运行

更新时间:2023-02-23 17:34:32

这些都是你需要做的配置Apache Django的以下的东西。我假设你使用的是Windows上的Python 2.7( 32位)( 32位)与WAMP服务器( 32位)安装。

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. 下载 mod_wsgi-win32-ap22py27-3.3.so。或下载相应的.so兼容的文件

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

更​​名为 mod_wsgi.so 并将其复制到 / Program Files文件/阿帕奇软件基金会/ Apache22 /模块在Windows上。

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

打开的httpd.conf 使用管理员权限。现在,你会发现线路与的LoadModule ... 列表。只需添加的LoadModule wsgi_module模块/ mod_wsgi.so 到列表中。

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.

您是部分完成..你可以重新启动Apache,不应发现任何错误。

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

现在,你需要将它链接到您的Django项目。

Now you need to link it to your Django project.

在Django项目的根文件夹中添加阿帕奇文件夹并创建 django.wsgi (唐' T改变这个名字)和 apache_mydjango.conf

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

的httpd.conf 添加下面一行在页面的底部。

In httpd.conf add the following line at the bottom of the page.

包括D:/projects/mysite/apache_django_wsgi.conf

打开 django.wsgi 并添加以下行:

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()

打开 apache_djang_wsgi.conf 并添加:

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>

请注意:

我假设你的Django项目的层次结构是这样的:

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

***教程链接:


  1. port25.technet.com |出版了我的微软。

  2. mod_wsgi快速安装指南

  3. Django的网站

  4. Django的网站

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

其实我不明白为什么人们无法修复。我在这里看到它的问题很多,我甚至贴出几个。所以,我觉得直接写一个初始安装版本的答案