原來在winserver+Apache環境下工做良好的一個微信公衆號後臺遷移到阿里雲(環境:Ubuntu 64位 | PHP5.4 | Nginx1.6)下卻頻出 404,403,只能訪問CI routes.php中設置的默認控制器等問題,後來上網查裏下多是路由設置問題,幾經折騰最後按下面的設置解決問題。php
一、修改網站配置文件html
server {
2 listen 80;
3 server_name example.com;//本身的域名
4
5 root /alidata/www/example;//網站目錄
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 /alidata/www/example/index.php;
15 fastcgi_param PATH_INFO $fastcgi_path_info;
16 fastcgi_split_path_info ^(.+\.php)(.*)$;
17 fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
18 include fastcgi.conf;
19 }
20
21 }
二、修改CI 的config.php 文件nginx
$config['base_url'] = 'http://example.com/';微信
$config['uri_protocol'] = 'PATH_INFO';//貌似REQUEST_URI也行網站
$config['index_page'] = '';阿里雲
三、網站根目錄以及如下目錄設置讀寫權限(777)url
四、重啓nginxspa