[英]apache permission denied after changing python shebang
I'm trying to execute simple python code on my web server.我正在尝试在我的 web 服务器上执行简单的 python 代码。 it's like as follow;
如下所示;
index.py file; index.py 文件;
#!/home/myenv/bin/python
print("Content-type: text/html\n\n")
print("test is okay")
I get the below error from apache;我从 apache 得到以下错误;
(13)Permission denied: exec of '/var/www/html/index.py' failed
Premature end of script headers: index.py
when i use system-wide python, there is no error from apache.当我使用系统范围的 python 时,apache 没有错误。
#!/usr/bin/python
print("Content-type: text/html\n\n")
print("test is okay")
the above code is working.上面的代码正在工作。
I think the problem is about changing shebang but i could'nt solve it.我认为问题在于改变shebang,但我无法解决。
my web server operating system is CentOS release 6.10我的 web 服务器操作系统是 CentOS 版本 6.10
I solved it changing security context of shebang with chcon utility.我用 chcon 实用程序解决了它改变 shebang 的安全上下文的问题。
This is my solution maybe it can be helped for other people.这是我的解决方案,也许可以对其他人有所帮助。
chcon system_u:object_r:bin_t:s0 /home/Python-3.7.9/python
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.