【问题标题】:permission denied in apache configuration : [Errno 13] Permission deniedapache配置中的权限被拒绝:[Errno 13]权限被拒绝
【发布时间】:2018-06-11 21:12:03
【问题描述】:

我正在尝试使用 wsgi 在 apache2.4(ubuntu 16) 上托管烧瓶,但我在浏览器中遇到 500 错误:

内部服务器错误 服务器遇到内部错误或配置错误,无法完成您的请求。 请通过 root@51.255.213.181 联系服务器管理员,告知他们此错误发生的时间,以及您在此错误之前执行的操作。 服务器错误日志中可能提供有关此错误的更多信息。 Apache/2.4.25 (Ubuntu) 服务器在 51.255.213.181 端口 80

当我运行tail -f /var/log/apache2/error.log:

[Tue Jan 02 05:27:28.444613 2018] [wsgi:error] [pid 3308:tid 139686857123584] [client 209.95.51.167:53868] Traceback(最近一次通话最后): [Tue Jan 02 05:27:28.444688 2018] [wsgi:error] [pid 3308:tid 139686857123584] [client 209.95.51.167:53868] 文件“/var/www/TW96/tw96.wsgi”,第 4 行,在 [Tue Jan 02 05:27:28.444703 2018] [wsgi:error] [pid 3308:tid 139686857123584] [client 209.95.51.167:53868] 来自索引导入应用程序作为应用程序 [2018 年 1 月 2 日星期二 05:27:28.444717] [wsgi:error] [pid 3308:tid 139686857123584] [client 209.95.51.167:53868] 文件“/var/www/TW96/tw96/index.py”,第 32 行,在 [2018 年 1 月 2 日星期二 05:27:28.444740] [wsgi:error] [pid 3308:tid 139686857123584] [client 209.95.51.167:53868] app.run(port=80,debug=True) [2018 年 1 月 2 日星期二 05:27:28.444755] [wsgi:error] [pid 3308:tid 139686857123584] [client 209.95.51.167:53868] 文件“/usr/local/lib/python3.5/dist-packages/flask/ app.py”,第 841 行,运行中 [Tue Jan 02 05:27:28.444766 2018] [wsgi:error] [pid 3308:tid 139686857123584] [client 209.95.51.167:53868] run_simple(host, port, self, **options) [2018 年 1 月 2 日星期二 05:27:28.444789] [wsgi:error] [pid 3308:tid 139686857123584] [client 209.95.51.167:53868] 文件“/usr/local/lib/python3.5/dist-packages/werkzeug/ serving.py”,第 780 行,在 run_simple 中 [Tue Jan 02 05:27:28.444799 2018] [wsgi:error] [pid 3308:tid 139686857123584] [client 209.95.51.167:53868] s.bind((hostname, port)) [Tue Jan 02 05:27:28.444825 2018] [wsgi:error] [pid 3308:tid 139686857123584] [client 209.95.51.167:53868] PermissionError: [Errno 13] Permission denied

这是我的 apache 配置文件:

<VirtualHost *:80>
                ServerName roboticworkshop.ir
                ServerAdmin root@51.255.213.181
                WSGIScriptAlias / /var/www/TW96/tw96.wsgi
                <Directory /var/www/TW96/tw96/>
                        Require all granted
                </Directory>
                ErrorLog ${APACHE_LOG_DIR}/error.log
                LogLevel warn
                CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

这是我的 wsgi 文件:

import sys,os
sys.path.insert(0,"/var/www/TW96/tw96")
os.chdir("/var/www/TW96/tw96")
from index import app as application

还有 www 文件夹:

TW96
....tw96
........index.py
........static
........templates
....tw96.wsgi

【问题讨论】:

标签: python linux flask ubuntu-16.04 apache2.4


【解决方案1】:

/var/www/TW96/tw96/index.py 的第 32 行在端口 80 上启动 HTTP 服务器:

app.run(port=80,debug=True)

这失败了,因为first 1024 ports are for privileged users only。即使您的应用程序将以特权用户身份运行,Apache 已经在侦听该端口,因此您无法打开它。

在任何情况下,导入应用程序一开始都不应该启动 HTTP 服务器。删除第 32 行。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-07-19
    • 2017-04-20
    • 2011-06-11
    • 2014-07-15
    • 2015-07-17
    • 2016-07-25
    • 2013-06-12
    • 2016-05-07
    相关资源
    最近更新 更多