PHP FastCGI权限问题

时间:2019-04-07 19:29:18

标签: php nginx

我已经在新的Ubuntu 18.04服务器上安装了nginx。如果这很重要,则适用于osTicket安装。我将所有文件都放在/ var / www / html目录中,并设置了我的网站-available / enabled。但是,当我转到该站点时,会收到“拒绝访问”消息,并且错误日志显示为:

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

1 个答案:

答案 0 :(得分:0)

好吧,我直接跳到配置和其他想法。忘了亲吻。无论出于何种原因,osTicket下载中的文件在文件夹中都具有755权限,但绝对没有文件权限。对所有东西都做了chmod 755,现在它很好了。