由于项目迁移,不得不在Nginx下配置codeigniter框架,开始怎么配置都不成功,经过度娘以及众网友的热心帮忙,终于完成了正确的设置,这里分享给大家,有需要的小
原来在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框架有所帮助。

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Atom editor mac version download
The most popular open source editor

WebStorm Mac version
Useful JavaScript development tools

SublimeText3 English version
Recommended: Win version, supports code prompts!

Dreamweaver Mac version
Visual web development tools

Safe Exam Browser
Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.
