代潇瑞博客

nginx配置yii2.0重写

| 点击次数:24495

apache和nginx比起来,我更倾向nginx,占用资源少,且性能高,不管是开发还是生产环境都很好用。那么,如何配置nginx让其支持yii2.0的访问呢?


配置范例如下:


server {

    listen       80;

    server_name  reson.com;


    location / {

        root   D:/wwwroot/reson/web;

        index  index.html index.php;

if (!-e $request_filename){

rewrite ^/(.*) /index.php last;

}

    }


location ~ \.php$ {

root           D:/wwwroot/reson/web;

fastcgi_pass   127.0.0.1:9000;

fastcgi_index  index.php;

fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;

include        fastcgi_params;

}


}


扩展一下,如果想让yii2.0在nginx下支持rewrite路由(pathinfo)的形式访问的话,请参考:yii2.0配置以pathinfo的形式访问

【相关推荐】

触屏版 | 电脑版

Copyright © 2013 代潇瑞博客手机版

QQ: 446673330

粤ICP备13071969号-1