首页  >  问答  >  正文

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在读取上游时上游超时(110:连接超时) ,客户端:127.0.0.1,服务器:test.com,请求:“GET /index.php HTTP/1.1”,上游:“fastcgi://unix:/var/run/php/php7.0-fpm.sock: ”,主机:“127.0.0.1:9090”

黄黄滨黄黄滨1694 天前1369

全部回复(0)我来回复

暂无回复
  • 取消回复