Home > php教程 > php手册 > body text

Nginx下配置codeigniter框架方法,nginxcodeigniter

WBOY
Release: 2016-06-13 09:07:28
Original
981 people have browsed it

Nginx下配置codeigniter框架方法,nginxcodeigniter

原来在winserver+Apache环境下工作良好的一个微信公众号后台迁移到阿里云(环境:Ubuntu 64位 | PHP5.4 | Nginx1.6)下却频出 404,403,只能访问CI routes.php中设置的默认控制器等问题,后来上网查里下可能是路由设置问题,几经折腾最后按下面的设置解决问题。

1、修改网站配置文件

复制代码 代码如下:
server {
    listen 80;
    server_name example.com;//自己的域名
    root /alidata/www/example;//网站目录
    index index.php index.htm index.html;
    location / {
            try_files $uri $uri/ /index.php;
    }
    location /index.php{
        fastcgi_pass  127.0.0.1:9000;
        fastcgi_param SCRIPT_FILENAME /alidata/www/example/index.php;
        fastcgi_param PATH_INFO $fastcgi_path_info;
        fastcgi_split_path_info ^(.+\.php)(.*)$;
        fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
        include  fastcgi.conf;
    }
}

2、修改CI 的config.php 文件

复制代码 代码如下:
$config['base_url']     = 'http://example.com/';
$config['uri_protocol'] = 'PATH_INFO';//貌似REQUEST_URI也行
$config['index_page'] = '';

3、网站根目录以及以下目录设置读写权限(777)

4、重启nginx

以上所述就是本文的全部内容了,希望能够对大家熟练使用CI框架有所帮助。

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template