尝试 运行 Apache 上的 Flask:错误 13(缺少搜索权限)
Trying to run Flask on Apache: error 13 (search permissions missing)
我正在尝试在我的 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 ..
一直往下。
我仍然遇到相同的 "search permissions are missing on a component of the path" 错误。
这是 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 并遵循了那里的建议,但没有任何改变。
Apache 作为特殊用户运行。如果您的文件在您的主目录下,它将无法读取它们。最好将它们移出您的主目录。否则你必须对所有目录执行 chmod o+rx
直到文件所在的位置,这与你的 OS 为你设置的相反。
我正在尝试在我的 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 ..
一直往下。
我仍然遇到相同的 "search permissions are missing on a component of the path" 错误。
这是 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 并遵循了那里的建议,但没有任何改变。
Apache 作为特殊用户运行。如果您的文件在您的主目录下,它将无法读取它们。最好将它们移出您的主目录。否则你必须对所有目录执行 chmod o+rx
直到文件所在的位置,这与你的 OS 为你设置的相反。