【问题标题】:"page not found nginx/1.4.4" errors on every page except homepage“page not found nginx/1.4.4”错误在除主页之外的每个页面上
【发布时间】:2015-10-16 11:09:39
【问题描述】:

我几乎在每个页面上都收到“找不到页面”错误。我搜了谷歌,提示可能是nginx的URL_rewrite有问题。

我已经把nginx/conf/nginx.config.default改成这样了

 location / {
            root   html;
            index  index.html index.htm;
            try_files $uri $uri/ /index.php?$args;
        }

但它仍然无法正常工作。

服务器系统:Centos 7 nginx:1.4.4 PHP版本:5.5.7

【问题讨论】:

    标签: php nginx centos


    【解决方案1】:

    您需要做的第一件事是在您的文档根目录中创建两个文件。

    第一个调用 test.html 并在文件中写入以下内容:

    这是一个测试

    然后创建一个名为 test.php 的文件,其中包含以下内容:

    <?php
    
    // Show all information, defaults to INFO_ALL
    phpinfo();
    
    ?>
    

    在浏览器上导航到每个,例如

    http://example.com/test.htmlhttp://example.com/test.php

    我的猜测是 html 会加载,而 php 不会。

    这是由于 php 和 nginx 没有正确的文件权限。

    首先是执行以下命令:

    chown -R nginx:nginx 文档根目录

    并继续执行该命令,每次添加 /* 直到出现错误。

    在您的 nginx.conf 文件中,您需要确保具有以下内容:

    location ~ \.php$ {
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
            include        fastcgi_params;
            fastcgi_param  SCRIPT_FILENAME $document_root$fastcgi_script_name;
        }
    

    然后转到/etc/php-fpm.d/www.conf

    并确保以下设置:

    listen.owner = nginx
    listen.group = nginx
    

    这应该可以解决问题。

    【讨论】:

    • 很高兴为您工作,我的建议是保存 php-fpm 和 nginx 的 conf 文件,以便您可以在需要时重复使用正确的设置。
    【解决方案2】:

    我已经像这样更改了 nginx/conf/nginx.config.default


    好像那个文件是原来的配置文件,不是有效的文件,试着找 nginx.config 文件没有 .default 扩展名。
    如果您没有找到它,请尝试将默认值复制到一个名为 nginx.config 的新文件中

    【讨论】:

      猜你喜欢
      • 2016-10-14
      • 1970-01-01
      • 1970-01-01
      • 2017-07-15
      • 1970-01-01
      • 2017-07-17
      • 2013-11-06
      • 2020-05-25
      • 2023-03-26
      相关资源
      最近更新 更多