手动编译php + nginx ,fastcgi模式.nginx配置好后,访问php一片空白 - V2EX
V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
Distributions
Ubuntu
Fedora
CentOS
中文资源站
网易开源镜像站
letitbesqzr
V2EX    Linux

手动编译php + nginx ,fastcgi模式.nginx配置好后,访问php一片空白

  •  
  •   letitbesqzr Nov 17, 2013 13220 views
    This topic created in 4543 days ago, the information mentioned may be changed or developed.
    nginx 配置:

    ------------------------------
    #user nobody;
    worker_processes 1;

    #error_log logs/error.log;
    #error_log logs/error.log notice;
    #error_log logs/error.log info;

    #pid logs/nginx.pid;


    events {
    worker_connections 1024;
    }


    http {
    include mime.types;
    default_type application/octet-stream;

    #log_format main '$remote_addr - $remote_user [$time_local] "$request" '
    # '$status $body_bytes_sent "$http_referer" '
    # '"$http_user_agent" "$http_x_forwarded_for"';

    #access_log logs/access.log main;
    br /> sendfile on;
    #tcp_nopush on;

    #keepalive_timeout 0;
    keepalive_timeout 65;

    #gzip on;

    server {
    listen 80;
    server_name localhost;

    #charset koi8-r;

    #access_log logs/host.access.log main;

    location / {
    root /www/default;
    index index.html index.htm index.php;
    }

    location ~.*\.php$ {
    root /www/default;
    fastcgi_pass 127.0.0.1:9000;
    fastcgi_index index.php;
    include fastcgi_params;
    }
    }

    ------

    $ netstat -anl | grep 9000
    tcp 0 0 127.0.0.1:9000 0.0.0.0:* LISTEN


    ------

    每访问刷新一次

    tcp 0 0 127.0.0.1:9000 0.0.0.0:* LISTEN
    tcp 0 0 127.0.0.1:9000 127.0.0.1:34246 TIME_WAIT
    tcp 0 0 127.0.0.1:9000 127.0.0.1:34245 TIME_WAIT
    tcp 0 0 127.0.0.1:9000 127.0.0.1:34243 TIME_WAIT
    tcp 0 0 127.0.0.1:9000 127.0.0.1:34247 TIME_WAIT


    ------

    /www/default/
    ├── 1.txt
    └── index.php

    ------

    访问1.txt 正常... index.php内容:
    <?php
    phpinfo();
    ?>

    访问index.php 一片空白,访问任何*.php 也是全空白。不提示404
    13 replies    1970-01-01 08:00:00 +08:00
    shiny
        1
    shiny  
    PRO
       Nov 17, 2013   1
    http状态码呢?200还是500?看 nginx 错误日志?看 php 错误日志?
    tywtyw2002
        2
    tywtyw2002  
       Nov 17, 2013   1
    看下日志吧,估计是php报错。。
    letitbesqzr
        3
    letitbesqzr  
    OP
       Nov 17, 2013
    @shiny 2013/11/17 23:12:38 [error] 32394#0: *12 FastCGI sent in stderr: "Primary script unknown" while reading response header from upstream, client: 127.0.0.1, server: localhost, request: "GET /index.php HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "localhost"
    letitbesqzr
        4
    letitbesqzr  
    OP
       Nov 17, 2013
    @tywtyw2002 2013/11/17 23:12:38 [error] 32394#0: *12 FastCGI sent in stderr: "Primary script unknown" while reading response header from upstream, client: 127.0.0.1, server: localhost, request: "GET /index.php HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "localhost"
    letitbesqzr
        5
    letitbesqzr  
    OP
       Nov 17, 2013
    @tywtyw2002
    @shiny

    感谢。。一直用lnmp的一键安装,手动安装能力很差..一键安装几乎没出什么错,也就没去关注过nginx的错误日志功能..下次一定注意了
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    加上这句话就成功了..
    shiny
        6
    shiny  
    PRO
       Nov 17, 2013
    @letitbesqzr 其实用 dotdeb 源安装更方便,而且默认情况下不需要改配置。
    princeofwales
        7
    princeofwales  
       Nov 17, 2013
    前几天,抛弃用了3年的一键安装包,用dotdeb的源安装的
    确实很快就装好了,配置还是需要改一点的,nginx里php部分,要反注释几行
    richiefans
        8
    richiefans  
       Nov 17, 2013
    看看 这里面的配置 include fastcgi_params;
    大部分情况是 fastcgi_param SCRIPT_FILENAME 的问题
    letitbesqzr
        9
    letitbesqzr  
    OP
       Nov 18, 2013
    @princeofwales
    @richiefans
    @shiny

    ...我用的这个senginx ...非常注重安全的一个版本..http://senginx.org/
    bigwang
        10
    bigwang  
       Nov 18, 2013
    把php.ini中的display_errors 设置为On ,然后执行 /etc/init.d/php-fpm restart
    txlty
        11
    txlty  
       Nov 18, 2013
    内个,,解决问题了就不要顶了。。刚才我对照了半天,找到了问题。刚要回复,才发现你已经自己找到了。
    上面有两位8楼、10楼,估计是没发现你已经解决问题了。
    shiny
        12
    shiny  
    PRO
       Nov 18, 2013
    @letitbesqzr 程序写得好大部分情况下都不需要这个东西(比如防 SQL 注入、跨站脚本之类的,治标不治本)
    防 DDoS 之类的一般是机房方面硬防的工作。Nginx 配置一般都是保持最简洁,很少让它介入安全方面的工作。并不觉得这种东西有什么必要。
    不过带入的一些功能还蛮实用,比如 ifall 命令什么的……
    coolicer
        13
    coolicer  
       Nov 18, 2013
    我现在跟你差不多,只是我的是502。访问静态文件正常,不知道是什么毛病
    About     Help     Advertise     Blog     API     FAQ     Solana     5299 Online   Highest 6679       Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 64ms UTC 01:19 PVG 09:19 LAX 18:19 JFK 21:19
    Do have faith in what you're doing.
    ubao msn snddm index pchome yahoo rakuten mypaper meadowduck bidyahoo youbao zxmzxm asda bnvcg cvbfg dfscv mmhjk xxddc yybgb zznbn ccubao uaitu acv GXCV ET GDG YH FG BCVB FJFH CBRE CBC GDG ET54 WRWR RWER WREW WRWER RWER SDG EW SF DSFSF fbbs ubao fhd dfg ewr dg df ewwr ewwr et ruyut utut dfg fgd gdfgt etg dfgt dfgd ert4 gd fgg wr 235 wer3 we vsdf sdf gdf ert xcv sdf rwer hfd dfg cvb rwf afb dfh jgh bmn lgh rty gfds cxv xcv xcs vdas fdf fgd cv sdf tert sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf shasha9178 shasha9178 shasha9178 shasha9178 shasha9178 liflif2 liflif2 liflif2 liflif2 liflif2 liblib3 liblib3 liblib3 liblib3 liblib3 zhazha444 zhazha444 zhazha444 zhazha444 zhazha444 dende5 dende denden denden2 denden21 fenfen9 fenf619 fen619 fenfe9 fe619 sdf sdf sdf sdf sdf zhazh90 zhazh0 zhaa50 zha90 zh590 zho zhoz zhozh zhozho zhozho2 lislis lls95 lili95 lils5 liss9 sdf0ty987 sdft876 sdft9876 sdf09876 sd0t9876 sdf0ty98 sdf0976 sdf0ty986 sdf0ty96 sdf0t76 sdf0876 df0ty98 sf0t876 sd0ty76 sdy76 sdf76 sdf0t76 sdf0ty9 sdf0ty98 sdf0ty987 sdf0ty98 sdf6676 sdf876 sd876 sd876 sdf6 sdf6 sdf9876 sdf0t sdf06 sdf0ty9776 sdf0ty9776 sdf0ty76 sdf8876 sdf0t sd6 sdf06 s688876 sd688 sdf86