【发布时间】:2016-12-23 20:08:50
【问题描述】:
我正在尝试在我的 Ubuntu 16.04 / Apache 2.4 服务器上运行一个测试 Flask 应用程序,但在请求页面时我不断收到 403 错误。
日志显示如下:
[Wed Aug 17 10:13:39.782920 2016] [core:error] [pid 30612:tid 140294142019328] (13)Permission denied: [client 131.180.174.104:57481] AH00035: access to /favicon.ico denied (filesystem path '/home/leon/opendc-production/web-server/opendc.wsgi') because search permissions are missing on a component of the path, referer: https://opendc.ewi.tudelft.nl/
我在 Apache 的网站上找到了 (13) Permission Denied 页面并按照步骤操作,一直执行 sudo chmod 644 opendc.wsgi、sudo chmod 644 hello.py 和 sudo chmod 644 hello.pyc,以及 sudo chmod +x . 和 cd ..。
我仍然收到相同的“路径组件缺少搜索权限”错误。
这是web-server 目录中 ls -al 的输出:
drwxrwx--- 3 leon leon 4096 Aug 17 10:36 .
drwxrwx--- 7 leon leon 4096 Aug 17 10:21 ..
-rw-rw---- 1 leon leon 93 Aug 16 14:13 .gitignore
-rw-r--r-- 1 leon leon 106 Aug 16 15:41 hello.py
-rw-r--r-- 1 leon leon 419 Aug 16 15:45 hello.pyc
-rw-rw---- 1 leon leon 54044 Aug 16 14:13 openapi-spec.yaml
-rw-r--r-- 1 leon leon 37 Aug 17 10:36 opendc.wsgi
-rw-rw---- 1 leon leon 410 Aug 16 14:13 README.md
drwxrwx--- 6 leon leon 4096 Aug 16 15:40 venv
这是opendc.wsgi的内容:
from hello import app as application
这是hello.py的内容:
from flask import Flask
app = Flask(__name__)
@app.route('/')
def hello_world():
return 'Hello, OpenDC!'
这是我/etc/apache2/sites-available/opendc.ewi.tudelft.nl.conf的内容:
<VirtualHost *:443>
# Meta
ServerAdmin l.overweel@gmail.com
ServerName opendc.ewi.tudelft.nl:443
# SSL
SSLEngine on
SSLCertificateFile /root/opendc.ewi.tudelft.nl.crt
SSLCertificateKeyFile /root/opendc.ewi.tudelft.nl.key
SSLCertificateChainFile /root/DigiCertCA.crt
# WSGI Python app
WSGIDaemonProcess opendc user=leon group=adm threads=5
WSGIScriptAlias / /home/leon/opendc-production/web-server/opendc.wsgi
<Directory /home/leon/opendc-production/web-server>
WSGIProcessGroup opendc
WSGIApplicationGroup %{GLOBAL}
Require all granted
</Directory>
</VirtualHost>
另外需要注意的是,我关注的是Flask installation guide,所以我在virtualenv中有python,这是我以前从未使用过的。不知道这是否会改变什么,或者我是否应该因此而采取不同的做法。
我还找到了this SO question 并按照那里的建议进行操作,但没有任何改变。
【问题讨论】:
-
看看这个flask.pocoo.org/docs/0.11/deploying/mod_wsgi你有没有尝试使用'Order allow,deny Allow from all'来授予权限?
-
@SteevenBrunner 是的,这就是我最初的想法。刚刚改回那个再试一次,我得到了同样的错误。
标签: apache ubuntu flask mod-wsgi wsgi