用户
 找回密码
 入住 CI 中国社区
搜索
查看: 4371|回复: 4
收起左侧

[讨论/交流] 用nginx下安装CI程序,实现rewiteurl例子

[复制链接]
发表于 2013-4-9 20:36:58 | 显示全部楼层 |阅读模式
好久没有来CI了,看见nginx讨论中有很多人在nginx下不会部署CI程序,实现url优化(去掉index.php),好吧,我已经在nginx使用CI有一段时间了,就来部署吧
这是nginx其中一个server的配置
  server
  {
    listen       82;
    server_name  _;  ##这个“_”其实没有什么,你也可以填*,它其实是一个域名的访问匹配正则
    index index.html index.htm index.php;
    root  /wwwroot;
    location ~ /(images|css|js|swf|upload|kindeditor)/.*$
    {
    }

    location ~ .*\.(txt|ico)$
    {
    }

    location ~ .*$
    {
      rewrite /.* /index.php break;
      fastcgi_pass  127.0.0.1:9000;
      fastcgi_index index.php;
      include fastcgi.conf;
    }
    access_log off;
  }


在CI中config.php设置如下就可了,
$config['base_url']        = '';
$config['index_page'] = '';

另外注意是,要将82这个端口在防火墙中打开,重启nginx就可以了
发表于 2013-5-13 17:33:17 | 显示全部楼层
不错,谢谢
发表于 2013-5-16 09:27:27 | 显示全部楼层
采用楼主的配置,解决了No input file specified.
但现在一直显示404 Page Not Found
项目本身的配置文件还需要哪里配置么
本地测试(mac+nginx) ok
服务器 (linux+nginx) ng
 楼主| 发表于 2013-10-29 20:55:52 | 显示全部楼层
cn.soft 发表于 2013-5-16 09:27
采用楼主的配置,解决了No input file specified.
但现在一直显示404 Page Not Found
项目本身的配置文件还 ...

如果出现404是很容易打问题了,这是说这页不存在,你可以打开nginx  访问日志,在日志中找到查找文件路径,对比下该路径是否有这个文件就能解决问题
发表于 2013-10-31 09:59:07 | 显示全部楼层
我一般这样:
try_files $uri $uri/ /index.php

本版积分规则