Ubuntu 16.0.4
CodeIgniter 3.1.5
nginx 1.13.9
php-fpm 5.6.19
先修改nginx容器的 /etc/nginx/conf.d/default.conf
server {
listen 80;
root /var/www/html;
index index.html index.htm index.php;
server_name localhost;
location / {
#注意這個xxxxxxxxx,若CodeIgniter在web資料夾內的某目錄裡,就需要填入對應的路徑
#這個可以輸入網址時,不需要index.php
try_files $uri $uri/ /xxxxxxxxx/index.php;
}
location ~ \.php$ { #這邊也可換成 \.php($|/)
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass php:9000;
fastcgi_index index.php;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param SCRIPT_FILENAM $document_root$fastcgi_script_name;
include fastcgi_params;
}
location ~ /\.ht {
deny all;
}
}
再修改CodeIgniter內的application/config/config.php
這行 $config['uri_protocol'] = 'PATH_INFO';
改成 $config['uri_protocol'] = 'REQUEST_URI';
沒改的話都會跑到welcome頁
也要填上web的域名,不然form_open會跳到內部ip
$config['base_url'] = 'http://xxx.xxx.xxx.xxx:80/';
沒有留言:
張貼留言