codeigniter(CI)是一个轻量型的PHP框架,因为它是在apache服务器下开发的,所以在nginx下需要特别的配置才可以使用。
具体方法如下:
1.对application/config/config.php
进行修改,大约在48行左右。
$config
[
‘uri_protocol‘
] =
"PATH_INFO"
;
2.配置nginx.conf文件
server {
listen 80;
listen [::]:80 ipv6only=on;
server_name localhost;
#charset koi8-r;
#access_log logs/host.access.log main;
root share/nginx/html;
index index.php index.html index.htm;
location / {
#root share/nginx/html;
#index index.php index.html index.htm;
try_files $uri $uri/ /index.php?$query_string;
}
location ~ \.php($|/) {
root localhost;//类似于apache的host地址 例如:share/nginx/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 localhost$fastcgi_script_name; //这里的localhost指的是完整的root地址例如:/opt/local/share/nginx/html
include fastcgi.conf;
}