在 Windows 7 上运行的 WAMP 服务器上安装 mod_wsgi [英] Installing mod_wsgi on WAMP server running on Windows 7

查看:28
本文介绍了在 Windows 7 上运行的 WAMP 服务器上安装 mod_wsgi的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我从 以下位置下载了 mod_wsgi,用于 apache 2.2 和 python 2.7(64 位).(我正在尝试让 django 在我的计算机上运行).

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

每当我添加以下行时:

LoadModule wsgi_module modules/mod_wsgi.so

Apache 无法启动.谁能告诉我可能是什么问题?

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

推荐答案

这些是为 Django 设置 Apache 需要执行的以下操作.我假设您在安装了 WAMP 服务器(32 位)的 Windows(32 位)上使用 Python 2.7(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 并将其复制到 Windows 上的 /Program Files/Apache Software Foundation/Apache22/modules.

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 modules/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 项目根文件夹中,添加 apache 文件夹并创建 django.wsgi(不要更改此名称)和 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 并添加以下几行:

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

打开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 站点

实际上我不明白为什么人们无法修复它.我在这里看到了很多问题,我什至发布了一些......所以,我想直接写一个初始设置版本作为答案

这篇关于在 Windows 7 上运行的 WAMP 服务器上安装 mod_wsgi的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆