如何在python中修复权限被拒绝?

时间:2018-01-09 14:23:47

标签: django amazon-ec2 centos7

我正在尝试从apache配置访问index.html。 我的apache配置是

Listen 8080
#ServerName localhost
WSGISocketPrefix /var/run/wsgi

<VirtualHost *:8080>
WSGIDaemonProcess   <group-name> python-path=/opt/codebase/git/.pyenv/versions/3.5.2/envs/<project>/lib/python3.5/site-packages user=apache group=<group-name> display-name=%{GROUP}
WSGIProcessGroup    <group-name> 
WSGIScriptAlias     /api /codebase/projects/<project>/src/apps/apps/wsgi.py process-group=<group-name> 

Timeout 1800

SSLEngine off
SSLCertificateFile /etc/pki/tls/certs/apache.crt
SSLCertificateKeyFile /etc/pki/tls/private/apache.key


DocumentRoot /codebase/projects/<project>/src/client/<project>

<Directory /codebase/projects/<project>/src/client/<project>>
    Require all granted
    <IfModule expires_module>
        ExpiresActive On
        ExpiresDefault "modification plus 2 seconds"
        # ExpiresDefault "access plus 1 day"
        ExpiresByType image/gif "access plus 1 month"
        ExpiresByType image/png "access plus 1 month"
    </IfModule>

    Header set Content-Security-Policy "default-src 'self'; script-src 'self' 'unsafe-eval'; connect-src 'self'; img-src 'self' data:; style-src 'self' 'unsafe-inline'; font-src 'self'; child-src 'self'; form-action 'self'; media-src 'self'; object-src 'self'; report-uri /api/csp/report"
</Directory>
<Directory /codebase/projects/<project>/src/files>
Require all granted
</Directory>

我正在使用centos 7和apache2.4

我得到了:

13) Permission denied: [client 3.204.115.205:64720] AH00035: access to /index.html denied (filesystem path 
'/codebase/projects/<project>/src/client/<project>/index.html') because search permissions are missing on a component of the path.

我完全允许父母大多数dir提交。但得到许可否认问题。有人能帮我吗。我在EC2实例中运行所有这个env。

1 个答案:

答案 0 :(得分:0)

主要解决方案。

你有SELinux在跑吗?试试这个:sudo setenforce 0然后重启apache。如果这样做,请不要这样离开。重新启用SELinux:sudo setenforce 1,我将发布一些关于如何创建规则的链接,以允许apache访问这些文件。 by - wholevinski