【发布时间】:2021-11-08 21:30:40
【问题描述】:
我在我的 manjaro 机器上使用安装了 Nginx 的默认配置。我只是在下面添加了一些简单的配置。
nginx.conf:
user http;
worker_processes auto;
worker_cpu_affinity auto;
.....
http{
.....
server {
listen 9000;
server_name localhost;
root /usr/share/nginx/html/exam;
location / {
index index.php index.html index.htm;
autoindex on;
autoindex_exact_size off;
autoindex_localtime on;
if (!-e $request_filename){
rewrite ^/(.+)$ /index.php?url=$1 break;
}
}
location /. {
return 404;
}
location ~ \.php$ {
try_files $uri =404;
include /etc/nginx/fastcgi_params;
include /etc/nginx/fastcgi.conf;
fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;
include fastcgi_params;
fastcgi_index index.php;
fastcgi_intercept_errors on;
fastcgi_split_path_info ^(.+\.php)(.*)$;
fastcgi_read_timeout 864000;
}
location ~ /\.ht {
deny all;
}
}
....
}
由于 Nginx 的用户是 http,我还将文件夹、子文件夹和文件的所有权更改为 HTTP:
chmod -R http:http exam/
看起来像这样:
1838248 lrwxrwxrwx 1 http http 42 Eyl 13 17:42 exam
但仍然在浏览器上给出 403 Forbidden 并出现此错误:
2021/09/13 17:49:22 [error] 493923#493923: *4 open() "/usr/share/nginx/html/exam/index.php" failed (13: Permission denied), client: 127.0.0.1, server: localhost, request: "GET /exam HTTP/1.1", host: "localhost:9000"
我已经尝试了所有找到的解决方案,但都没有成功。
我还尝试了像“phpinfo();”这样运行的简单 PHP 文件即使他们不工作。
【问题讨论】:
标签: php nginx nginx-config