nginx php-fpm =找不到文件

前端之家收集整理的这篇文章主要介绍了nginx php-fpm =找不到文件前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

当我尝试访问info.PHP我得到一个文件找不到.错误.

我试过一些教程没有用.

CONFIGS:
默认:

server {
    listen         80;
    listen   [::]:80 default ipv6only=on; 
    server_name  localhost;

    location / {
        root   /var/www;
        index  index.html index.htm index.PHP;
    }

    # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
    #
    location ~ \.PHP${
        fastcgi_pass 127.0.0.1:7777;
        fastcgi_index  index.PHP;
        fastcgi_param SCRIPT_FILENAME /usr/share/Nginx/html$fastcgi_script_name;
        fastcgi_buffers 256 128k;
        #fastcgi_buffer_size 16k;
        #fastcgi_busy_buffers_size 256k;
        fastcgi_connect_timeout 300s;
        fastcgi_send_timeout 300s;
        fastcgi_read_timeout 300s;
        include fastcgi_params;
    }
}

有什么问题?

最佳答案
如果那个info.PHP在/ var / www中,那么指示fast_cgi寻找是错误

/usr/share/Nginx/html/info.PHP;

对于html和PHP使用相同的根.此外,根和索引参数应该在特定位置之外,除非非常具体的用途.

server {
   listen         80;
   listen   [::]:80 default ipv6only=on; 
   server_name  localhost;
   root   /var/www;
   index  index.html index.htm index.PHP;


   #pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000

   location ~ \.PHP${
       fastcgi_pass 127.0.0.1:7777;
       fastcgi_index  index.PHP;
       fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
       fastcgi_buffers 256 128k;
       fastcgi_connect_timeout 300s;
       fastcgi_send_timeout 300s;
       fastcgi_read_timeout 300s;
       include fastcgi_params;
    }
}

不用说,您仍然需要确保您的PHP-fpm服务正在7777端口上侦听.通常的情况是让它在端口9000上侦听.

原文链接:https://www.f2er.com/nginx/434680.html

猜你在找的Nginx相关文章