为什么 WSGIScriptAlias 没有效果?
Why is WSGIScriptAlias not having an effect?
我 运行 遇到了在 Apache 中设置 WSGIScriptAlias 的问题,尝试使用别名会由于试图访问 "literal" URL 而出现 404 错误.这是我的 Apache2 sites-available/000-default.conf
中的测试设置(模仿 mod_wsgi Quick Start Guide):
DocumentRoot /var/www/html
WSGIScriptAlias /wsgi_test /var/www/html/test.wsgi
<Directory /var/www/html>
Order allow,deny
Allow from all
</Directory>
重启Apache2后进入mydomain.com/wsgi_test
,显示404页面。下面 Apache 的 error.log
文件的第一行显示服务器试图访问 DocumentRoot
中的 URL 路径 wsgi_test
,而不是别名文件路径:
AH00128: File does not exist: /var/www/html/wsgi_test
AH01964: Connection to child 1 established (server nathanclonts.com:443)
(70007)The timeout specified has expired: [client 67.161.148.188:33883] AH01991: SSL input filter read failed.
文件/var/www/html/test.wsgi
与上述快速入门指南的代码相同:
def application(environ, start_response):
status = '200 OK'
output = b'Hello World!'
response_headers = [('Content-type', 'text/plain'),
('Content-Length', str(len(output)))]
start_response(status, response_headers)
return [output]
权限设置为:
-rwxrw-r-- 1 username www-data 278 Apr 16 11:31 test.wsgi
有没有人对在哪里寻找可能影响此的其他配置或任何其他调试技巧有任何建议?
奇怪的是,我已经使用 mod_wsgi 设置了另一个 (Django) 应用程序,该应用程序目前正在同一个 VirtualHost 中运行,但显然我在这个测试中遗漏了一些东西。
这已通过更新 <VirtualHost *:443>
配置文件以包含 WSGIScriptAlias
行(因为服务器使用 SSL)而不是 WSGIScriptAlias
在 <VirtualHost *>
下解决配置。
我不知道所有别名都需要包含在 443 端口中才能运行,但在玩了一个普通的 Alias
并找到它们定义的文件后最终解决了这个问题:
grep -R "Alias" /etc/apache2/*
我 运行 遇到了在 Apache 中设置 WSGIScriptAlias 的问题,尝试使用别名会由于试图访问 "literal" URL 而出现 404 错误.这是我的 Apache2 sites-available/000-default.conf
中的测试设置(模仿 mod_wsgi Quick Start Guide):
DocumentRoot /var/www/html
WSGIScriptAlias /wsgi_test /var/www/html/test.wsgi
<Directory /var/www/html>
Order allow,deny
Allow from all
</Directory>
重启Apache2后进入mydomain.com/wsgi_test
,显示404页面。下面 Apache 的 error.log
文件的第一行显示服务器试图访问 DocumentRoot
中的 URL 路径 wsgi_test
,而不是别名文件路径:
AH00128: File does not exist: /var/www/html/wsgi_test
AH01964: Connection to child 1 established (server nathanclonts.com:443)
(70007)The timeout specified has expired: [client 67.161.148.188:33883] AH01991: SSL input filter read failed.
文件/var/www/html/test.wsgi
与上述快速入门指南的代码相同:
def application(environ, start_response):
status = '200 OK'
output = b'Hello World!'
response_headers = [('Content-type', 'text/plain'),
('Content-Length', str(len(output)))]
start_response(status, response_headers)
return [output]
权限设置为:
-rwxrw-r-- 1 username www-data 278 Apr 16 11:31 test.wsgi
有没有人对在哪里寻找可能影响此的其他配置或任何其他调试技巧有任何建议?
奇怪的是,我已经使用 mod_wsgi 设置了另一个 (Django) 应用程序,该应用程序目前正在同一个 VirtualHost 中运行,但显然我在这个测试中遗漏了一些东西。
这已通过更新 <VirtualHost *:443>
配置文件以包含 WSGIScriptAlias
行(因为服务器使用 SSL)而不是 WSGIScriptAlias
在 <VirtualHost *>
下解决配置。
我不知道所有别名都需要包含在 443 端口中才能运行,但在玩了一个普通的 Alias
并找到它们定义的文件后最终解决了这个问题:
grep -R "Alias" /etc/apache2/*