解决 ci yii 下nginx 404 错误

本文详细介绍了Nginx服务器的配置方法,包括监听端口、指定服务器名称、设置根目录等基本配置,以及如何通过rewrite规则实现URL重写,如何配置FastCGI参数以支持PHP解析等功能。
location ~ \.php { # 这里减掉一个“$”原本是\.php$
    fastcgi_pass 127.0.0.1:9000;
    fastcgi_index index.php; # 这一句不知道什么用处
    fastcgi_split_path_info ^(.+\.php)(.*)$; # 加了这一句
    fastcgi_param PATH_INFO $fastcgi_path_info; # 还有这一句
    include fastcgi.conf;
}


yii----------------------------------------------

        location ~ \.php { # ......<93>$<94>...\.php$
         root  html;
         fastcgi_pass 127.0.0.1:9000;
         fastcgi_index index.php; # ..........
         fastcgi_split_path_info ^(.+\.php)(.*)$; # ....
        # fastcgi_param PATH_INFO $fastcgi_path_info; # .....
        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
         include fastcgi.conf;
        }
---------------------------------------------
nginx 配置

    server {
        listen       8080;
        server_name  192.168.1.168;
        root  html/e3m;


        location / {
            root   html/e3m;
            index  index.html index.php;
            if ($request_filename !~ (connect|gif|png|jpg|js|css|images|source|robots/.txt|index/.php.*) ) {
             rewrite ^/(.*)$ /index.php/$1 last;
             break;
            }
         }


        location ~* .(jpg|jpeg|gif|png|css|js|ico|xml)$ {
            access_log        off;
            log_not_found     off;
            expires           360d;
        }




        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root  html;
        }


        location ~ \.php { # ......<93>$<94>...\.php$
         root  html/e3m;
         fastcgi_pass 127.0.0.1:9000;
         fastcgi_index index.php; # ..........
         fastcgi_split_path_info ^(.+\.php)(.*)$; # ....
        # fastcgi_param PATH_INFO $fastcgi_path_info; # .....
        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
         include fastcgi.conf;
        }
    }

最后执行
/usr/local/nginx/sbin/nginx -s reload

就完事儿了
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值