Nginx 无法读取某些文件,但可以读取其他文件

Nginx 无法读取某些文件,但可以读取其他文件

我全新安装了 nginx 来为我的laravel应用程序提供服务。有些文件显示,有些则不显示。当我加载页面时,它显示:

403 禁止文件

我在网上看到说这通常是权限问题,因此我尝试过:

  1. chown -R :www-data /path/to/webroot
  2. chmod -R 755 /路径/到/webroot

我们可以在下图中看到:

权限设置

我的 nginx 守护进程正在www-data从该nginx.conf文件运行: user www-data;

我尝试了网上能找到的所有解决方案,但似乎都不起作用。任何帮助都将不胜感激。

sites-available conf

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

    root /usr/share/nginx/x/public/;
    index index.html index.htm index.php;


    #error logs
    error_log /var/log/nginx/x.com-error.log error;

    server_name x.com www.x.com;

    # pass the PHP scripts to FastCGI server listening on /var/run/php5-fpm.sock
    location / {
        try_files $uri $uri/ /index.php?$query_string;
        fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;
    }

}

nginx.conf

user www-data;
worker_processes 8;
pid /run/nginx.pid;
events {
   worker_connections 8096;
   multi_accept on;
   use epoll;
}
worker_rlimit_nofile 40000;
http {
   ##
   # Basic Settings
   ##
   sendfile on;
   tcp_nopush on;
   tcp_nodelay on;
   keepalive_timeout 15;
   types_hash_max_size 2048;
   # server_tokens off;
   server_names_hash_bucket_size 64;
   # server_name_in_redirect off;
   include /etc/nginx/mime.types;
   default_type application/octet-stream;
   client_max_body_size 50M;
   ##
   # SSL Settings
   ##
   ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE
   ssl_prefer_server_ciphers on;
   ##
   # Logging Settings
   ##
   access_log on;
   error_log on;
   ##
   # Gzip Settings
   ##
   gzip  on;
   gzip_vary on;
   gzip_min_length 10240;
   gzip_proxied expired no-cache no-store private auth;
   gzip_types text/plain text/css text/xml text/javascript application/x-javascript application/xml;
gzip_disable "MSIE [1-6]\.";
   ##
   # Virtual Host Configs
   ##
   include /etc/nginx/conf.d/*.conf;
   include /etc/nginx/sites-enabled/*;
}

相关内容