![Ubuntu Vserver(Strato):wsgi 脚本显示为纯文本](https://linux22.com/image/1275716/Ubuntu%20Vserver%EF%BC%88Strato%EF%BC%89%EF%BC%9Awsgi%20%E8%84%9A%E6%9C%AC%E6%98%BE%E7%A4%BA%E4%B8%BA%E7%BA%AF%E6%96%87%E6%9C%AC.png)
我已经在本地 Gentoo 机上测试了配置,但是在我的 Strato-vServer 上它不起作用:
$ apache2 -M|grep wsgi
wsgi_module (shared)
# cat /etc/apache2/sites-enabled/000-default
<VirtualHost *:80>
DocumentRoot /var/www/vhosts/default/
<Directory /var/www/vhosts/default/>
Options Indexes FollowSymLinks MultiViews ExecCGI
AddHandler cgi-script .cgi
AddHandler wsgi-script .wsgi
SetHandler wsgi-script
Options ExecCGI
AllowOverride None
Order allow,deny
allow from all
</Directory>
ScriptAlias /cgi-bin/ "/var/www/vhosts/default/cgi-bin/"
<Directory "/var/www/vhosts/default/cgi-bin/">
AllowOverride None
Options None
Order allow,deny
Allow from all
</Directory>
wsgi脚本:
root@h1900160:/var/www/vhosts/default/cgi-bin# cat test.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]
该脚本仅显示为纯文本。错误日志显示以下内容:
[Fri May 13 12:54:02 2011] [info] mod_wsgi (pid=14311): Attach interpreter ''.
答案1
这并不能解决您的问题,但是您应该有以下几行:
SetHandler wsgi-script
以下行:
AddHandler wsgi-script .wsgi
已经确保任何带有 .wsgi 扩展名的内容都由 mod_wsgi 处理。添加 SetHandler 只会导致您的 .cgi 脚本不再作为 CGI 脚本提供。此外,您也无法再提供静态文件服务。