本文介绍了mod_wsgi的在CentOS 5.7禁错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道,这个问题被问了数百万次,但我已经花了很多时间试图在CentOS 5.7配置Apache和mod_wsgi的,其新的我。从未遇到过这样的问题在Debian(Ubuntu的)。

I know that this question was asked millions of times, but i already spent many hours trying to configure Apache and mod_wsgi on CentOS 5.7, which it new to me. Never faced this kind of problem on Debian (Ubuntu).

我创建 wsgi.conf /etc/httpd/conf.d / 目录,containting的下面几行:

I've created wsgi.conf in /etc/httpd/conf.d/ directory, containting the following lines:

LoadModule wsgi_module modules/mod_wsgi.so
WSGIPythonHome /var/xxx/env

的/ var / XXX / env的包含项目的虚拟环境。

然后我添加以下行到 /etc/httpd/conf.d/ssl.conf (是的,我需要它对于HTTPS,但我也试过把它变成正常的虚拟主机)。

Then I've added the following lines into /etc/httpd/conf.d/ssl.conf (yes, I need it for https, but i also tried to put it into normal virtual host).

WSGIScriptAlias /suburl /var/xxx/yyy/hello.wsgi
<Location /suburl>
  Order deny,allow
  Allow from all
</Location>

hello.wsgi 包含

def application(environ, start_response):
       status = '200 OK'
       output = 'Hello World!'
       response_headers = [('Content-type', 'text/plain'),
              ('Content-Length', str(len(output)))]
       start_response(status, response_headers)
       return [output]

下面是的输出ls -l命令的/ var / XXX /

 total 16
 drwxr-xr-x 5 apache apache 4096 Feb  9 05:14 env
 drwxr-xr-x 7 apache apache 4096 Feb  9 05:41 yyy

ls -l命令的/ var / XXX / YYY /

total ...
...
-rwxr-xr-x 1 apache apache  238 Feb  9 05:19 hello.wsgi
...

PS -aF | grep的的httpd 显示

 root      8872     1  0 07:06 ?        00:00:00 /usr/sbin/httpd
 apache    8874  8872  0 07:06 ?        00:00:00 /usr/sbin/httpd
 apache    8875  8872  0 07:06 ?        00:00:00 /usr/sbin/httpd
 apache    8876  8872  0 07:06 ?        00:00:00 /usr/sbin/httpd
 apache    8877  8872  0 07:06 ?        00:00:00 /usr/sbin/httpd
 apache    8878  8872  0 07:06 ?        00:00:00 /usr/sbin/httpd
 apache    8879  8872  0 07:06 ?        00:00:00 /usr/sbin/httpd
 apache    8880  8872  0 07:06 ?        00:00:00 /usr/sbin/httpd
 apache    8881  8872  0 07:06 ?        00:00:00 /usr/sbin/httpd
 fedor    10609  4716  0 07:16 pts/1    00:00:00 grep httpd

的/ var /日志/的httpd / ssl_error_log 满像线以下

[Thu Feb 09 07:06:47 2012] [error] [client 127.0.0.1] (13)Permission denied: access to /suburl denied

但它通过调用启动Apache sudo的/ usr / sbin目录/的httpd hello.wsgi开始工作,尽管 PS -aF | grep的的httpd 显示非常相似的行:

BUT it start Apache by calling sudo /usr/sbin/httpd hello.wsgi starts working, even though ps -Af | grep httpd shows very similar lines:

root     11442     1  3 07:21 ?        00:00:00 /usr/sbin/httpd
apache   11443 11442  0 07:21 ?        00:00:00 /usr/sbin/httpd
apache   11444 11442  0 07:21 ?        00:00:00 /usr/sbin/httpd
apache   11445 11442  0 07:21 ?        00:00:00 /usr/sbin/httpd
apache   11446 11442  0 07:21 ?        00:00:00 /usr/sbin/httpd
apache   11447 11442  0 07:21 ?        00:00:00 /usr/sbin/httpd
apache   11448 11442  0 07:21 ?        00:00:00 /usr/sbin/httpd
apache   11449 11442  0 07:21 ?        00:00:00 /usr/sbin/httpd
apache   11450 11442  0 07:21 ?        00:00:00 /usr/sbin/httpd
fedor    11453  4716  0 07:21 pts/1    00:00:00 grep httpd

任何想法可能会导致问题,还有什么我一定要检查?

Any ideas what may cause the problem and what else do i have to check?

推荐答案

设置上的文件和目录适当的SELinux的文件。有关详细信息,请参阅 httpd_selinux(8)手册页。

Set the appropriate SELinux file context on the files and directories. See the httpd_selinux(8) man page for details.

这篇关于mod_wsgi的在CentOS 5.7禁错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-14 17:15