访问被拒绝,在Apache2上运行.py尝试从Apache2上的/ opt打开文件

时间:2018-12-17 13:40:44

标签: python ubuntu apache2

我的权限有问题。我正在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?有什么线索吗?谢谢。

0 个答案:

没有答案