更改 python shebang 后 apache 权限被拒绝
apache permission denied after changing python shebang
我正在尝试在我的网络服务器上执行简单的 python 代码。就像下面这样;
index.py 文件;
#!/home/myenv/bin/python
print("Content-type: text/html\n\n")
print("test is okay")
我从 apache 得到以下错误;
(13)Permission denied: exec of '/var/www/html/index.py' failed
Premature end of script headers: index.py
当我使用全系统 python 时,apache 没有错误。
#!/usr/bin/python
print("Content-type: text/html\n\n")
print("test is okay")
以上代码有效。
我认为问题出在更改 shebang 上,但我无法解决它。
我的网络服务器操作系统是 CentOS 6.10 版
我用 chcon 实用程序解决了更改 shebang 的安全上下文的问题。
这是我的解决方案,也许对其他人有帮助。
chcon system_u:object_r:bin_t:s0 /home/Python-3.7.9/python
我正在尝试在我的网络服务器上执行简单的 python 代码。就像下面这样;
index.py 文件;
#!/home/myenv/bin/python
print("Content-type: text/html\n\n")
print("test is okay")
我从 apache 得到以下错误;
(13)Permission denied: exec of '/var/www/html/index.py' failed
Premature end of script headers: index.py
当我使用全系统 python 时,apache 没有错误。
#!/usr/bin/python
print("Content-type: text/html\n\n")
print("test is okay")
以上代码有效。
我认为问题出在更改 shebang 上,但我无法解决它。
我的网络服务器操作系统是 CentOS 6.10 版
我用 chcon 实用程序解决了更改 shebang 的安全上下文的问题。
这是我的解决方案,也许对其他人有帮助。
chcon system_u:object_r:bin_t:s0 /home/Python-3.7.9/python