嘿,我想安装一个论坛(xenforo),我已经得到了所有的 .php 文件,我把文件夹放在/usr/share/nginx/html 页面在哪里(主页 index.html),但是当我做 127.0. 0.1/forum/我得到那个错误
403 Forbidden
nginx/1.10.3
所以我想知道如何修复它,配置就是那个
server {
listen 80 default_server;
listen [::]:80 default_server;
server_name _;
root /usr/share/nginx/html;
# Load configuration files for the default server block.
include /etc/nginx/default.d/*.conf;
location / {
}
error_page 404 /404.html;
location = /40x.html {
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
}
getenforce 被禁用
最佳答案
在 nginx 上设置 Xenforo 2 时,您需要阅读 documentation here .
它告诉您如何设置 nginx 配置,如下所示:
location /xf/ {
try_files $uri $uri/ /xf/index.php?$uri&$args;
index index.php index.html;
}
location /xf/install/data/ {
internal;
}
location /xf/install/templates/ {
internal;
}
location /xf/internal_data/ {
internal;
}
location /xf/library/ { #legacy
internal;
}
location /xf/src/ {
internal;
}
location ~ \.php$ {
try_files $uri /index.php?$uri&$args;
#try_files $uri =404;
fastcgi_pass 127.0.0.1:9000;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
这应该可以解决您的问题。这就是我在 centminmod 上使用的,效果很好。如果您的论坛位于根目录中,请从每个路径中删除“/xf”,或者如果您位于不同的文件夹中,请更改它。
关于Nginx 子目录 404,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56815349/