Configure the codeigniter framework under Nginx, nginxcodeigniter_PHP tutorial

WBOY
Release: 2016-07-13 09:58:40
Original
1057 people have browsed it

Configure the codeigniter framework under Nginx, nginxcodeigniter

A WeChat public account that originally worked well in the winserver Apache environment was migrated to Alibaba Cloud in the background (environment: Ubuntu 64-bit | PHP5.4 | Nginx1.6), but 404, 403 frequently occurred, and the default controller set in CI routes.php could only be accessed. Later, I checked online and found out that it might be a routing setting issue. After much fiddling, I finally solved the problem by following the settings below.

1. Modify website configuration file

<span>server {
 2     listen 80;
 3     server_name<span> example.com</span>;//自己的域名
 4 
 5     root <span>/alidata/www/example</span>;//网站目录
 6     index index.php index.htm index.html;
 7 
 8     location / {
 9             try_files $uri $uri/ /index.php;
10     }
11 
12     location /index.php{
13         fastcgi_pass  127.0.0.1:9000;
14         fastcgi_param SCRIPT_FILENAME <span>/alidata/www/example/index.php</span>;
15       <span>  fastcgi_param PATH_INFO $fastcgi_path_info;</span>
16         fastcgi_split_path_info ^(.+\.php)(.*)$;
17         fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
18         include  fastcgi.conf;
19     }
20 
21 }</span>
Copy after login

2. Modify CI’s config.php file

$config['base_url'] = 'http://example.com/';

$config['uri_protocol'] = 'PATH_INFO';//It seems that REQUEST_URI will also work

$config['index_page'] = '';

3. Set read and write permissions (777) for the website root directory and the following directories

4. Restart nginx

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/977523.htmlTechArticleConfiguring the codeigniter framework under Nginx, nginxcodeigniter originally worked well in the winserver Apache environment and migrated the backend of a WeChat official account to Alibaba Cloud (Environment: Ubuntu 64-bit | PHP5.4 |...
Related labels:
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 Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!