路径对权限有但访问PHP文件提示404File not found如何解决?

先贴一下配置代码:
nginx:

 server {
        listen       80;
        server_name rpc.testweb.net;
        index index.php index.html index.htm ;
        root /data1/htdocs/www/rpc.testweb.net/;
        
        location / {
            index  index.php index.html index.htm;
        }
        
        #error_page  404              /404.html;
        
        # redirect server error pages to the static page /50x.html
        #
        #error_page   500 502 503 504  /50x.html;
        #location = /50x.html {
        #    root   html;
        #}
                                                                                                                                                                           
        
        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
        #
        location ~ \.php$ {
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
            include        fastcgi_params;                                                                                                                                 
        }                                                                                                                                                                  
                                                                                                                                                                           
        # deny access to .htaccess files, if Apache's document root                                                                                                        
        # concurs with nginx's one                                                                                                                                         
        #
        #location ~ /\.ht {                                                                                                                                                
        #    deny  all;                                                                                                                                                    
        #}
    }

$document_root,$fastcgi_script_name 这两个变量我打印出来了,路径跟我代码路径一致,
代码路径下的文件 也都是 777 权限了,还有哪里有问题?
nginx,php都是用nobody用户运行的

访问提示

File not found.

好,我改一下配置,把script_filename 直接改为我的地址,访问还是 FILE NOT FOUND

        location ~ \.php$ {
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
            #fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
            fastcgi_param  SCRIPT_FILENAME   /data1/htdocs/www/rpc.testweb.net/index.php;
            include        fastcgi_params;
        }

这是什么问题?

阅读 11.4k
4 个回答

最后找运维也没解决,最有可能的答案是,Centos7中预装版本的PHP有问题

不一定是ng配置的问题的,可以尝试在代码断点试试

拿你的用户去这个路径看一下这个文件 能访问就找其他的原因 不能就看看是不是路径中间有你没权限访问的目录 比如/data1/htdocs/www/rpc.testweb.net/index.php最后这个文件你有权限,但是/data1/htdocs/www/这个目录没权限也是白搭

chown nobody.nobody -R 你的目录

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题