用mod_wsgi安装Django [英] Installing Django with mod_wsgi

查看:178
本文介绍了用mod_wsgi安装Django的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用Django 1.0编写了一个应用程序。它适用于django测试服务器。但是当我试图让它变得更有可能的生产环境时,Apache服务器无法运行应用程序。
我使用的服务器是 WAMP2.0 。我多年以来一直是PHP程序员,很久以前我一直在使用WAMPServer。
我安装了mod_wsgi.so,似乎工作正常(没有服务错误),但是我无法配置httpd.conf来查看位于服务器根外部的python脚本。



现在,我很高兴覆盖文档根目录,并从文档根目录中提供django应用程序,因此httpd.conf行应如下所示:

 
WSGIScriptAlias / C:/Users/Marcos/Documents/mysite/apache/django.wsgi

但服务器的响应是403 Forbidden

解决方案

您有:

  WSGIScriptAlias / /C:/Users/Marcos/Documents/mysite/apache/django.wsgi 

这是错误的,因为RHS不是有效的Windows路径名。使用:

  WSGIScriptAlias / C:/Users/Marcos/Documents/mysite/apache/django.wsgi 

也就是说,在Windows驱动器说明符之前没有前导斜杠。



除此之外,请遵循其他人指出的mod_wsgi文档。






海报编辑的问题可以改变现在看来是什么如果是这样的话,403的下一个原因如下。

$ b $($)

首先,您还需要:

 <目录C:/ Users / Marcos /文档/ mysite的/阿帕奇> 
订单拒绝,允许
允许从所有
< / Directory>

如果没有,那么Apache没有被授予服务脚本的权限目录,所以将返回FORBIDDEN(403)。



其次是你确实有,但不承认你做,那个目录或WSGI脚本文件不可用于Apache服务在Windows下运行。


I wrote an application using Django 1.0. It works fine with the django test server. But when I tried to get it into a more likely production enviroment the Apache server fails to run the app. The server I use is WAMP2.0. I've been a PHP programmer for years now and I've been using WAMPServer since long ago. I installed the mod_wsgi.so and seems to work just fine (no services error) but I can't configure the httpd.conf to look at my python scripts located outside the server root.

For now, I'm cool with overriding the document root and serve the django app from the document root instead so the httpd.conf line should look like this:

    WSGIScriptAlias / C:/Users/Marcos/Documents/mysite/apache/django.wsgi

but the server's response is a 403 Forbidden

解决方案

You have:

WSGIScriptAlias / /C:/Users/Marcos/Documents/mysite/apache/django.wsgi

That is wrong as RHS is not a valid Windows pathname. Use:

WSGIScriptAlias / C:/Users/Marcos/Documents/mysite/apache/django.wsgi

That is, no leading slash before the Windows drive specifier.

Other than that, follow the mod_wsgi documentation others have pointed out.


Poster edited question to change what now would appear to be a typo in the post and not a problem with his configuration.

If that is the case, next causes for a 403 are as follows.

First is that you need to also have:

<Directory C:/Users/Marcos/Documents/mysite/apache>
Order deny,allow
Allow from all
</Directory>

If you don't have that then Apache isn't being granted rights to serve a script from that directory and so will return FORBIDDEN (403).

Second is that you do have that, but don't acknowledge that you do, and that that directory or the WSGI script file is not readable by the user that the Apache service runs as under Windows.

这篇关于用mod_wsgi安装Django的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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