首页 >社区问答列表 >nginx配置php,可以看到phpinfo,但是解析不了其他的php代码

nginx配置php,可以看到phpinfo,但是解析不了其他的php代码

我在ubuntu上搭建lnmp环境,在配置nginx的时候有个小问题。
在/etc/nginx/sites-available/创建一个test文件    

server {
      listen 9090;
      #listen [::]:9090;

      server_name test.com;

       large_client_header_buffers 4 16k;
       client_max_body_size 300m;
       client_body_buffer_size 128k;
       proxy_connect_timeout 600;
       proxy_read_timeout 600;
       proxy_send_timeout 600;
       proxy_buffer_size 64k;
       proxy_buffers  4 32k;
       proxy_busy_buffers_size 64k;
       proxy_temp_file_write_size 64k;

      root /var/www/test;
      #index index.html index.php;
      index index.html index.htm index.php;

      location / {
              try_files $uri $uri/ =404;
      }
       # pass PHP scripts to FastCGI server
       #
       location ~ \.php$ {
       #       include snippets/fastcgi-php.conf;
       #
       #       # With php-fpm (or other unix sockets):
               fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
       #       # With php-cgi (or other tcp sockets):
               #fastcgi_pass 127.0.0.1:9090;
               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;
       #}
       }
然后在fastcgi_params文件下添加     

fastcgi_param  SCRIPT_FILENAME $document_root$fastcgi_script_name;


访问127.0.0.1:9090/index.php,会报 GET http://127.0.0.1:9090/index.php net::ERR_INCOMPLETE_CHUNKED_ENCODING 200 (OK)

在nginx的error.log日志中有

2020/01/31 17:11:55 [error] 15569#15569: *6 upstream timed out (110: Connection timed out) while reading upstream, client: 127.0.0.1, server: test.com, request: "GET /index.php HTTP/1.1", upstream: "fastcgi://unix:/var/run/php/php7.0-fpm.sock:", host: "127.0.0.1:9090"

无数据提示还没有回复,楼主喊你快去抢前排~~~我来回答