Home > Backend Development > PHP Tutorial > How to configure the codeigniter framework under Nginx, nginxcodeigniter_PHP tutorial

How to configure the codeigniter framework under Nginx, nginxcodeigniter_PHP tutorial

WBOY
Release: 2016-07-13 09:57:36
Original
928 people have browsed it

Configuring the codeigniter framework method under Nginx, nginxcodeigniter

A WeChat official 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 occurred frequently, and the default controller set in CI routes.php could only be accessed. Later, I checked online and found that it might be a routing setting issue. After much fiddling, I finally solved the problem with the following settings. .

1. Modify website configuration file

Copy code The code is as follows:
server {
Listen 80;
Server_name example.com;//Your own domain name
Root /alidata/www/example;//Website directory
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. Modify CI’s config.php file

Copy code The code is as follows:
$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

The above is the entire content of this article. I hope it will help everyone to use the CI framework proficiently.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/980225.htmlTechArticleConfiguring the codeigniter framework method under Nginx, nginxcodeigniter originally worked well in the winserver Apache environment and migrated a WeChat official account to the background Alibaba Cloud (Environment: Ubuntu 64-bit | PH...
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