zoukankan      html  css  js  c++  java
  • Nginx PHP页面找不到总是返回404

    同目录下 html 没有问题,一访问 *.php 就404

    原因:
    nginx 配置的 server 段没有指定 root,导致 fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name 中的 $document_root并不起作用

    解决方法:
    server 段加上 root 网站目录,或不使用 $document_root变量,转而使用其它变量或直接指定路径

    server {
        #使用 one 这个缓存
            #proxy_cache    one;
            #proxy_cache_valid   any  10m;
    
            listen         80;
            server_name    abc.com ;
    
            # 就是增加的下面的 root,指定了当前 server 的root指向哪里
            root           /a/b/c;
    
            location / {
                root     /home/wwwroot/tyshgm-www;
                index    index.html  index.php;
    
                try_files  $uri  $uri/  /index.php?$args;
            }
    
            rewrite /wp-admin$ $scheme://$host$uri/ permanent;
    
            error_page   401 402 403 404 500 502 503 504  /oops.html;
            location = /oops.html {
                root     /a/b/c;
            }
    
            location  ~.php$ {
                root            /a/b/c;
                fastcgi_pass    unix:/run/php-fpm/c.sock;
                #fastcgi_pass    127.0.0.1:9000;
                fastcgi_index   index.php;
                fastcgi_param   SCRIPT_FILENAME  $document_root$fastcgi_script_name;
                include         fastcgi_params;
            }
        }
    
    ## 不重要的其实最重要
  • 相关阅读:
    lvs实现故障转移(backup)
    shell计算
    CEGUI 聊天对话框
    SetRenderState 设置渲染状态【转】
    MFC 弹出对话框
    DrawIndexedPrimitive函数的详细解释【转】
    IDirect3DDevice9::Clear 【转】
    manifest 文件错误
    D3DXMatrixLookAtLH 【转】
    D3D中的网格(Mesh)
  • 原文地址:https://www.cnblogs.com/cinlap/p/14872024.html
Copyright © 2011-2022 走看看