【问题标题】:PHP FastCGI Permission IssuePHP FastCGI 权限问题
【发布时间】:2019-08-28 23:29:23
【问题描述】:

我在新的 Ubuntu 18.04 服务器上安装了 nginx。如果这很重要,它用于 osTicket 安装。我将所有文件放在 /var/www/html 目录中并设置我的站点可用/启用。但是当我访问该站点时,我收到一条拒绝访问消息,并且错误日志显示:

2019/04/07 13:50:24 [error] 17708#17708: *1 FastCGI sent in stderr:
"PHP message: PHP Warning:  Unknown: failed to open stream: Permission
denied in Unknown on line 0
Unable to open primary script: /var/www/html/upload/index.php
(Permission denied)" while reading response header from upstream,
client: [my IP], server: server.domain.local, request: "GET / HTTP/1.1",
upstream: "fastcgi://unix:/run/php/php7.2-fpm.sock:", host: "server.domain.local"

已经确保 /var/www/html 以下的所有目录都有 www-data:www-data 和 +x。

/etc/nginx/sites-available/osticket.conf

server {
  listen 80;
        server_name server.domain.local;

        root   /var/www/html/upload/;

        access_log  /var/log/nginx/access.log;
        error_log  /var/log/nginx/error.log;

        index index.php;
        client_max_body_size 2000M;
        client_body_buffer_size 100M;
        client_header_buffer_size 10M;
        large_client_header_buffers 2 10M;
        client_body_timeout 12;
        client_header_timeout 12;
        keepalive_timeout 15;
        send_timeout 10;
        gzip             on;
        gzip_comp_level  2;
        gzip_min_length  1000;
        gzip_proxied     expired no-cache no-store private auth;
        gzip_types       text/plain application/x-javascript text/xml text/css application/xml;

        set $path_info "";

        location ~ /include {
          deny all;
          return 403;
       }

       if ($request_uri ~ "^/api(/[^\?]+)") {
         set $path_info $1;
       }

       location ~ ^/api/(?:tickets|tasks).*$ {
        try_files $uri $uri/ /api/http.php?$query_string;
       }

       if ($request_uri ~ "^/scp/.*\.php(/[^\?]+)") {
          set $path_info $1;
       }

       location ~ ^/scp/ajax.php/.*$ {
          try_files $uri $uri/ /scp/ajax.php?$query_string;
       }

       location / {
          try_files $uri $uri/ index.php;
       }

       location ~ \.php$ {
           fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
           include        fastcgi_params;
        include snippets/fastcgi-php.conf;
        fastcgi_pass unix:/run/php/php7.2-fpm.sock;
        fastcgi_param  PATH_INFO    $path_info;
      }
}

/etc/php/7.2/fpm/pool.d/www.conf 的用户部分

; Unix user/group of processes
user = www-data
group = www-data

【问题讨论】:

    标签: php nginx


    【解决方案1】:

    好吧,我直接跳到配置和其他想法。忘记亲吻了。无论出于何种原因,来自 osTicket 下载的文件对文件夹具有 755 权限,但对文件绝对没有权限。对所有内容都进行了 chmod 755,现在效果很好。

    【讨论】:

      猜你喜欢
      • 2010-12-16
      • 2018-09-17
      • 2018-06-09
      • 1970-01-01
      • 2013-09-10
      • 2021-04-22
      • 2011-04-16
      • 2011-01-04
      • 1970-01-01
      相关资源
      最近更新 更多