我正在尝试配置mod_wsgi以使用一个简单的web.py python脚本。我听了这本食谱:http://webpy.org/cookbook/mod_wsgi-apache
每次我去https://<server>/appname/
chrome说Internal Server Error
以下是我的配置详情:
在httpd.conf中我有
LoadModule wsgi_module modules/mod_wsgi.so
WSGIScriptAlias /appname /var/www/webpy-app/cody.py/
Alias /appname /var/www/webpy-app/static/
AddType text/html .py
<Directory /var/www/webpy-app/>
Order deny,allow
Allow from all
</Directory>
<Location /appname>
AuthType Basic
AuthName "Authenication Required"
AuthUserFile "/etc/httpd/conf/some_sample_users"
</Location>
以下是代码:
import web
urls = (
'/.*', 'hello',
)
class hello:
def GET(self):
return "Hello, world."
application = web.application(urls, globals()).wsgifunc()
我检查了错误日志但在那里找不到多少:
[Wed Oct 09 02:24:50 2013] [notice] caught SIGTERM, shutting down
[Wed Oct 09 02:24:55 2013] [notice] SELinux policy enabled; httpd running as context unconfined_u:system_r:httpd_t:s0
[Wed Oct 09 02:24:55 2013] [notice] suEXEC mechanism enabled (wrapper: /usr/sbin/suexec)
[Wed Oct 09 02:24:55 2013] [warn] module wsgi_module is already loaded, skipping
[Wed Oct 09 02:24:55 2013] [notice] Digest: generating secret for digest authentication ...
[Wed Oct 09 02:24:55 2013] [notice] Digest: done
[Wed Oct 09 02:24:55 2013] [notice] Apache/2.2.15 (Unix) mod_wsgi/3.2 Python/2.6.6 DAV/2 mod_ssl/2.2.15 OpenSSL/1.0.0-fips configured -- resuming normal operations
我需要做哪些修改才能使其正常工作?
答案 0 :(得分:0)
一开始就错了:
WSGIScriptAlias /appname /var/www/webpy-app/cody.py/
Alias /appname /var/www/webpy-app/static/
Alias指令优先于WSGIScriptAlias。你有相同的挂载点,所以别名获胜。我建议你先评论别名。
除此之外,在第二个参数上使用尾部斜杠而不是第一个在子URL处安装时可能会导致问题。使用:
WSGIScriptAlias /appname /var/www/webpy-app/cody.py
下一个问题是:
[Wed Oct 09 02:24:55 2013] [warn] module wsgi_module is already loaded, skipping
这表明你有:
LoadModule wsgi_module modules/mod_wsgi.so
在Apache配置的不同位置列出两次,或者您已设法包含两次列出的配置文件。
先修复这些问题,然后使用更新的信息编辑问题。
答案 1 :(得分:0)
我关注this tutorial,这是完成步骤,无需.htaccess即可运行web.py, 但请记住,当您复制粘贴python代码时,您必须观察缩进,因为它也会显示内部服务器错误。这就是httpd.conf的样子
<VirtualHost _default_ *:80>
ServerAdmin admin@project.com
DocumentRoot /var/www/project.com/public_html/
ErrorLog /var/www/project.com/logs/error.log
CustomLog /var/www/project.com/logs/access.log combined
WSGIScriptAlias / /var/www/project.com/production/main.py
Alias /static /var/www/project.com/public_html
AddType text/html .py
WSGIDaemonProcess www-data threads=15
WSGIProcessGroup www-data
<Directory /var/www/project.com/production/>
Order deny,allow
Allow from all
Options +FollowSymLinks
Options -Indexes
</Directory>
</VirtualHost>
将main.py作为索引文件