Nginx 子目录 404

标签 nginx centos

嘿,我想安装一个论坛(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/

相关文章:

mysql - 数据迁移停止后急救致命mysql服务器错误

windows - 添加 nginx.exe 作为 Windows 系统服务(如 Apache)?

nginx - 如何将 yii2 与 ispconfig3 集成

php - 权威的 LEMP 堆栈官方 - Ubuntu 14.04

linux - 如何在CentOS中安装sendmail?

centos - 错误 'bad pad value "2m": must be positive screen distance' when using tk_messageBox on a wayland display (CentOS)

linux - centos配置网络的方法

angular - 在 Nginx 中使用 Angular 应用程序管理环境

nginx 一条规则正则表达式的多个位置

python-2.7 - Ruamel.yaml.jinja2 : typ "jinja2"not recognised on CentOS