谁搞过ThinkPHP,nginx下要配置才能用infopath模式。找了一个网上的用不了呢 - V2EX
V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
coolicer
V2EX    NGINX

谁搞过ThinkPHP,nginx下要配置才能用infopath模式。找了一个网上的用不了呢

  •  
  •   coolicer 2013-11-28 11:19:48 +08:00 4350 次点击
    这是一个创建于 4409 天前的主题,其中的信息可能已经有所发展或是发生改变。
    location / {
    index index.html index.htm index.php;
    root /home/www/php;
    try_files $uri $uri/ =404;
    }
    location ~.*\.php$ {
    root /home/www/php;
    fastcgi_pass unix:/var/run/php5-fpm.sock;
    fastcgi_index index.php;
    include fastcgi_params;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    }

    ---------------------------以上是现在的配置----------------------


    #这段是网上说开启的
    location /App/ { #App是我的项目目录
    index index.php;
    if (!-e $request_filename) {
    rewrite ^/App/(.*)$ /App/index.php/$1 last;
    break;
    }
    }

    location ~ .+\.php($|/) {
    set $script $uri;
    set $path_info "/";
    if ($uri ~ "^(.+\.php)(/.+)") {
    set $script $1;
    set $path_info $2;
    }

    fastcgi_pass fastcgi_pass unix:/var/run/php5-fpm.sock;
    fastcgi_index index.php?IF_REWRITE=1;
    include /APMServ/nginx/conf/fastcgi_params;
    fastcgi_param PATH_INFO $path_info;
    fastcgi_param SCRIPT_FILENAME $document_root/$script;
    fastcgi_param SCRIPT_NAME $script;
    }
    #这段是网上说开启的



    现在有几个Location,不知道哪些不要。
    9 条回复    1970-01-01 08:00:00 +08:00
    ooh
        1
    ooh  
       2013-11-28 11:59:28 +08:00
    server {
    listen 80;
    server_name 127.0.0.1;

    root /home/www/new/;
    index index.html index.htm index.php;

    location / {
    if (!-e $request_filename) {
    rewrite ^(.*)$ /index.php?s=$1 last;
    }
    # try_files $uri $uri/ /index.php;
    }

    location ~ \.php$ {
    try_files $uri =404;
    fastcgi_split_path_info ^(.+\.php)(/.+)$;
    # # NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
    #
    # # With php5-cgi alone:
    # fastcgi_pass 127.0.0.1:9000;
    # # With php5-fpm:
    fastcgi_pass unix:/var/run/php5-fpm.sock;
    fastcgi_index index.php;
    include fastcgi_params;
    }
    }
    你重写url试试
    coolicer
        2
    coolicer  
    OP
       2013-11-28 13:54:11 +08:00
    @ooh 大哥,木有反应,还是不能用PATHINFO模式
    vvtommy
        3
    vvtommy  
       2013-11-28 14:17:34 +08:00
    为什么在nginx下使用PATHINFO呢?如果仔细设计URL的话,花时间写一下rewrite规则才是不错的选择,ThinkPHP用PATHINFO只是在当年看来是一个比较“潮”的feature。

    当然,回答你的问题,在nginx下安装这个module,可以打开PATHINFO支持 http://wiki.nginx.org/HttpFastcgiModule
    coolicer
        4
    coolicer  
    OP
       2013-11-28 14:27:28 +08:00
    @vvtommy 不是很懂。其实我看了REST的ULR,我觉得PATHINFO的好丑。
    ooh
        5
    ooh  
       2013-11-28 17:03:54 +08:00
    @coolicer 我忘了phpinfo模式的URL是什么样的了,你举个栗子?这个用url模式2是没问题的
    coolicer
        6
    coolicer  
    OP
       2013-11-28 17:26:14 +08:00
    @ooh http://localhost/app/index.php/Index/index

    我这样启动不了:

    server {
    listen 8080 default_server;
    server_name localhost;
    index index.html index.htm index.php;
    root /home/www/php;
    location / {
    try_files $uri $uri/ =404;
    if(!-e $request_filename){
    rewrite ^(.*)$ /index.php?s=$1 last;
    break;
    }
    }
    location ~\.php$ {
    fastcgi_pass unix:/var/run/php5-fpm.sock;
    fastcgi_index index.php;
    set $path_info "";
    set $real_script_name $fastcgi_script_name;
    if ($fastcgi_script_name ~ "^(.+?\.php)(/.+)$") {
    set $real_script_name $1;
    set $path_info $2;
    }
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    fastcgi_param SCRIPT_NAME $real_script_name;
    fastcgi_param PATH_INFO $path_info;
    include /etc/nginx/fastcgi_params;
    }
    }
    qingting
        7
    qingting  
       2013-11-28 17:56:30 +08:00
    ooh
        8
    ooh  
       2013-11-28 19:38:30 +08:00
    @coolicer 你直接用我贴的,把new改成你php项目地址,然后先访问localhost看看行不,在访问localhost/Index/index,我那个是重写了URL的,还有你url模式是不是2?我都是用的这个
    coolicer
        9
    coolicer  
    OP
       2013-11-29 09:25:35 +08:00
    @ooh 是2的。
    关于     帮助文档     自助推广系统     博客     API     FAQ     Solana     2954 人在线   最高记录 6679       Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 26ms UTC 12:22 PVG 20:22 LAX 04:22 JFK 07:22
    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