登录  /  注册
nginx配置php,可以看到phpinfo,但是解析不了其他的php代码
黄黄滨
黄黄滨 2020-01-31 17:25:06
[Linux讨论组]

我在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"

黄黄滨
黄黄滨

全部回复(0)
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 意见反馈 讲师合作 广告合作 最新更新
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习
PHP中文网抖音号
发现有趣的

Copyright 2014-2024 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号