最近刚学ci框架,做了个简单的项目,在本地搭Nginx服务器的环境都调通了,但是部署到远程服务器时:
http://example.com/(index.php)/ 可以访问(为配置的默认controller-class)
http://example.com/(index.php)/[controller-class]/[controller-method] 不可以访问(提示404错误!)
Nginx+CI 出现404错误 http://www.linuxidc.com/Linux/2013-01/78386.htm
原因:
1 server {
2 listen 80;
3 server_name example.com;
4 root /data/wwwroot/example/ 5 index index.php index.html index.htm;
6
7 location ~* \.(css|js|swf|htm|jpg|png|gif|json|atlas)?$ {
8 expires 1d;
9 add_header Pragma public;
10 add_header Cache-Control "public";
11 }
12
13 location /controller-class/ {
14 if (!-e $request_filename) {
15 rewrite ^/controller-class/(.*)$ /controller-class/index.php?q=$uri&$args;
16 }
17 }
18
19 location ~ \.php$ {
20 fastcgi_pass 127.0.0.1:9000;
21 fastcgi_index index.php;
22 fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
23 fastcgi_param PHP_VALUE open_basedir=$document_root:/tmp/:/proc/;
24 include fastcgi_params;
25 }
26
27 }
更多Nginx相关教程见以下内容:
CentOS 6.2实战部署Nginx+MySQL+PHP http://www.linuxidc.com/Linux/2013-09/90020.htm
使用Nginx搭建WEB服务器 http://www.linuxidc.com/Linux/2013-09/89768.htm
搭建基于Linux6.3+Nginx1.2+PHP5+MySQL5.5的Web服务器全过程 http://www.linuxidc.com/Linux/2013-09/89692.htm
CentOS 6.3下Nginx性能调优 http://www.linuxidc.com/Linux/2013-09/89656.htm
CentOS 6.3下配置Nginx加载ngx_pagespeed模块 http://www.linuxidc.com/Linux/2013-09/89657.htm
CentOS 6.4安装配置Nginx+Pcre+php-fpm http://www.linuxidc.com/Linux/2013-08/88984.htm
Nginx安装配置使用详细笔记 http://www.linuxidc.com/Linux/2014-07/104499.htm
Nginx日志过滤 使用ngx_log_if不记录特定日志 http://www.linuxidc.com/Linux/2014-07/104686.htm
Nginx 的详细介绍:请点这里
Nginx 的下载地址:请点这里
本文永久更新链接地址:http://www.linuxidc.com/Linux/2016-03/128895.htm
