Nginx + PHP-FPM用户主目录的权限被拒绝

时间:2018-08-01 08:50:52

标签: php linux nginx permissions

PHP-FPM配置

user = www-data
group = www-data

listen.owner = www-data
listen.group = www-data

Nginx配置

user www-data;

主机配置为

server {
    listen 80;
    listen [::]:80;
    listen 443 ssl;
    listen [::]:443 ssl;

    root /home/SITENAME/www;
    index index.php;

    server_name SITENAME.com www.SITENAME.com;
    include snippets/ssl-SITENAME.com.conf;
    include snippets/ssl-params.conf;

    access_log /home/SITENAME/logs/access.log combined;
    error_log /home/SITENAME/logs/error.log warn;

    location ~ /.well-known {
        allow all;
    }

    location / {
        try_files $uri $uri/ =404;
    }

    location ~ \.php$ {
        include snippets/fastcgi-php.conf;
        fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
    }

    location ~ /\.ht {
        deny all;
    }

    expires 86400s;
    add_header Pragma public;
    add_header Cache-Control "max-age=86400, public, must-revalidate, proxy-revalidate";

    location ~* ^.+\.(css|js)$ {
        rewrite ^(.+)\.(\d+)\.(css|js)$ $1.$3 last;
        expires 31536000s;
        access_log off;
        log_not_found off;
        add_header Pragma public;
        add_header Cache-Control "max-age=31536000, public";
    }

    location ~* \.(asf|asx|wax|wmv|wmx|avi|bmp|class|divx|doc|docx|eot|exe|gif|gz|gzip|ico|jpg|jpeg|jpe|mdb|mid|midi|mov|qt|mp3|m4a|mp4|m4v|mpeg|mpg|mpe|mpp|odb|odc|odf|odg|odp|ods|odt|ogg|ogv|otf|pdf|png|pot|pps|ppt|pptx|ra|ram|svg|svgz|swf|tar|t?gz|tif|tiff|ttf|wav|webm|wma|woff|wri|xla|xls|xlsx|xlt|xlw|zip)$ {
        expires 31536000s;
        access_log off;
        log_not_found off;
        add_header Pragma public;
        add_header Cache-Control "max-age=31536000, public";
    }
}

用户站点名称位于组www-data中,而用户www-data位于组用户中,但是我仍然无法在主目录中写入,该如何解决? 将用户主目录拖到www-data不是解决方案,就像不是使用777的解决方案。

0 个答案:

没有答案