nginx支持PHP的CI

1.找到CI库的配置文件修改


$config['base_url']     = 'http://test.example.com';

$config['uri_protocol'] = 'PATH_INFO';

2.找到NGINX配置.在SERVER段中添加如下代码段


location /index.php{

                               fastcgi_pass  unix:/tmp/php-cgi.sock;

                               fastcgi_param SCRIPT_FILENAME /home/wwwroot/index.php;

                               fastcgi_param PATH_INFO $fastcgi_path_info;

                               fastcgi_split_path_info ^(.+\.php)(.*)$;

                               fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;

                              include fcgi.conf;

             }

3.如果要做跳转的话,(比如:http://test.example.com/index.php/test,跳转
http://test.example.com/test.)可以server 段中添加如下配置
location /{
                   if (-f $request_filename) {
                               expires max;
                               break;
                       }
                       if (!-e $request_filename) {
                               rewrite ^/(.*)$ /index.php/$1 last;
                       }
  }