我在许可方面有问题。我正在Apache2/var/www/html/project上运行带有CGI的.py程序,在.py程序上我试图在/opt/image.png中打开文件,我得到:
PermissionError: [Errno 13] Permission denied: '/opt/image.png
Apache2配置:
<VirtualHost *:80>
ServerName localhost
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html
<Directory /var/www/html/project>
Order Allow,Deny
Allow from all
Options +ExecCGI
AddHandler cgi-script .py
</Directory>
<Directory "/opt">
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
代码中,我从外部获取了POST的路径:
#!/usr/bin/python3
# -*- coding: UTF-8 -*-# enable debugging
print("Content-Type: text/html;charset=utf-8")
print()
import cgitb, cgi
cgitb.enable()
import PIL
form = cgi.FieldStorage()
file = form.getvalue('file')
imopen = Image.open(file)
我已经尝试将修饰符改为777,所有者改为root,我仍然无法访问,权限被拒绝。我想问题是我无法从/var访问/opt?有线索吗?多谢各位
目前没有回答
相关问题 更多 >
编程相关推荐