![](/img/trans.png)
[英]Permission denied running python script with the shebang line in linux
[英]apache permission denied after changing python shebang
我正在嘗試在我的 web 服務器上執行簡單的 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,但我無法解決。
我的 web 服務器操作系統是 CentOS 版本 6.10
我用 chcon 實用程序解決了它改變 shebang 的安全上下文的問題。
這是我的解決方案,也許可以對其他人有所幫助。
chcon system_u:object_r:bin_t:s0 /home/Python-3.7.9/python
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.