1.根据教程安装:http://codeigniter.org.cn/user_guide/installation/index.html
2.修改nginx配置:server {
listen 80;
server_name localhost;
rewrite_log on;
#根目录
root /usr/share/nginx/html/www;
index index.php index.html index.htm;
location / {
try_files $uri $uri/ /index.php;
location = /index.php {
fastcgi_pass 127.0.0.1:9000;
#ci的路径
fastcgi_param SCRIPT_FILENAME /usr/share/nginx/html/www/CodeIgniter$fastcgi_script_name;
include fastcgi_params;
}
}
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
location ~ /\.ht {
deny all;
}
}
3.根据官网提示(https://www.nginx.com/resources/wiki/start/topics/recipes/codeigniter/)修改config文件:
$config['base_url'] = ""; $config['index_page'] = ""; $config['uri_protocol'] = "AUTO";按照以上步骤可以开启nginx的pathinfo模式,此时http://xxxxx/index.php/about可以跳到about.php文件,http://xxxxxxx/index.php/home可以跳到home.php文件