Flask Apache启动失败,权限被拒绝

qgzx9mmu  于 2022-11-16  发布在  Apache
关注(0)|答案(1)|浏览(217)

我尝试在运行Apache HTTP服务器的CentOS 7.9.2009 VM上安装Flask。我已经安装了Python3.8和mod_wsgi,但是当我尝试启动Apache时,在加载mod_wsgi时,我得到了下面的Permissioned denied。我检查了多个博客和论坛,但没有找到解决方案。知道为什么我会得到这个错误吗?
错误:无法打开共享对象文件:权限被拒绝

httpd: Syntax error on line 56 of /etc/httpd/conf/httpd.conf: Syntax error on line 1 of /etc/httpd/conf.modules.d/02-wsgi.conf: Cannot load /home/myuser/.local/lib/python3.8/site-packages/mod_wsgi/server/mod_wsgi-py38.cpython-38-x86_64-linux-gnu.so into server: /home/myuser/.local/lib/python3.8/site-packages/mod_wsgi/server/mod_wsgi-py38.cpython-38-x86_64-linux-gnu.so: cannot open shared object file: Permission denied

我使用./configure --enable-optimizations --enable-shared LDFLAGS="-Wl,-rpath /usr/local/lib"从源代码安装了python3.8,但仍然出现上述权限被拒绝的错误。
下面是我的app.conf文件的样子,也是mod_wsgi模块配置的输出。

应用程序配置:

LoadModule wsgi_module "/home/myuser/.local/lib/python3.8/site-packages/mod_wsgi/server/mod_wsgi-py38.cpython-38-x86_64-linux-gnu.so"

修改wsgi模块配置:

[myuser@mycentos conf.d]$ mod_wsgi-express module-config
LoadModule wsgi_module "/home/myuser/.local/lib/python3.8/site-packages/mod_wsgi/server/mod_wsgi-py38.cpython-38-x86_64-linux-gnu.so"
WSGIPythonHome "/usr/local"

当我尝试启动Apache - sudo systemctl start httpd时,我收到错误。

sycxhyv7

sycxhyv71#

权限问题是因为SELinux在我的系统上启用/强制执行。我联系了mod_wsgi源代码作者之一,他指示我检查这个。现在禁用这个解决了我的即时问题。如果其他人有解决这个问题的建议,而不关闭它,请提出建议。

$ sestatus
SELinux status:                 enabled
SELinuxfs mount:                /sys/fs/selinux
SELinux root directory:         /etc/selinux
Loaded policy name:             targeted
Current mode:                   enforcing
Mode from config file:          enforcing
Policy MLS status:              enabled
Policy deny_unknown status:     allowed
Max kernel policy version:      31

相关问题