简体   繁体   English

Apache Python 500内部服务器错误

[英]Apache Python 500 internal server error

Thank you in advance for any help on this, I am a bit of a newb and have been looking everywhere to figure what I am doing wrong. 在此先感谢您提供的任何帮助,我有点不高兴,并且一直在到处寻找错误的地方。

I have the Apache 2.4.6, python 2.7 centos 7. 我有Apache 2.4.6,python 2.7 centos 7。

I have a simple python script 我有一个简单的python脚本

/var/www/html/test.py

In the script it has 在脚本中有

#!/usr/bin/env python
print 'Hello World!'

The permission have been checked (777 just because I can't figure it out): 权限已检查(777,因为我无法弄清楚):

-rwxrwxrwx.  1 apache apache   192 Aug 27 11:45 test.py

running the command 运行命令

/var/www/html/test.py

works find and displays Hello World! 可以找到并显示Hello World!

The log for apache says apache的日志说

[Thu Aug 27 11:38:53.703606 2015] [cgi:error] [pid 10218] [client 86.159.50.246:61086] AH01215: (13)Permission denied: exec of '/var/www/html/test.py' failed

The relevant apache configuration is as follows: 相关的Apache配置如下:

LoadModule wsgi_module modules/mod_wsgi.so
<Directory /var/www/html/>
 Order allow,deny
 Require all granted
 allow from all
 Options +ExecCGI
 AddHandler cgi-script .py
</Directory>

Any help would be greatly appreciated because I have no idea what else I am doing wrong! 任何帮助将不胜感激,因为我不知道我在做什么错!

I finally figured out the issue. 我终于弄清楚了这个问题。 It was that I installed mod_wsgi with yum and it was precomilid for a different version of python. 那是我在yum上安装了mod_wsgi,并且与其他版本的python预兼容。 It works with SE linux inabled. 它与SE linux inabled一起使用。 To fisc the issue I ran the following lines of code 为了解决这个问题,我运行了以下代码行

yum install httpd-devel
git clone https://github.com/GrahamDumpleton/mod_wsgi.git
cd mod_wsgi
./configure --with-python=/usr/bin/python2.7    
make
make install

Then it output the path of the module (.so) file. 然后,它输出模块(.so)文件的路径。 It looked right but just for completeness sake I change the file: /etc/httpd/conf.modules.d/10-wsgi.conf 它看起来不错,但是为了完整起见,我更改了文件:/etc/httpd/conf.modules.d/10-wsgi.conf

from

LoadModule wsgi_module modules/mod_wsgi.so

to

LoadModule wsgi_module /usr/lib64/httpd/modules/mod_wsgi.so

because that was the output path of the make step and it worked!! 因为那是make步骤的输出路径,所以有效!!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM