的笨

2017-08-11 16 views
0

NGINX服务器配置/etc/nginx/conf.d/default.conf的笨

server{ 
listen 80; 
listen [::]:80; 
server_name 192.168.56.101 192.168.101.100 localhost; 
root /var/www/html; 
index index.php index.html index.htm; 

location/{ 
    try_files $uri $uri/ =404; 
} 

error_page 404 /404.html; 
error_page 500 502 503 504 /50x.html; 

location = /50x.html { 
    root /var/www/html; 
} 

location ~ \.php$ { 
    try_files $uri =404; 
    fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock; 
    fastcgi_index index.php; 
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; 
    include fastcgi_params; 
} 


location ~ /\.ht { 
    deny all; 
} 
} 

我笨文件夹是位于在/ var '词'/ www/html等/ CI 我需要什么样的配置,以你的工作try_files URL重写?...

+0

[Doc:Nginx的Codeigniter](https://www.nginx.com/resources/wiki/start/topics/recipes/codeigniter/)你检查过吗? –

+0

是的,我做了,但没有工作... – Amin

+0

更改根'root/var/www/html/ci' –

回答

0

因为我的'ci'文件夹位于/var/www/html/ci,所以我不想更改当前文档根目录(/var/www/html) 。

所以不是,我在/etc/nginx/conf.d/default.conf创建了一个新的位置块:

server{ 
... 
    location /ci { 
     try_files $uri $uri/ /ci/index.php?/$request_uri; 
    } 
... 
} 

感谢Mert Öksüz的建议使用try_files $uri $uri/ /ci/index.php?/$request_uri;

2

根更改为root /var/www/html/ci

更改为try_files $uri $uri/ /index.php?/$request_uri;

确保你的fpm路径(unix:/var/run/php-fpm/php-fpm.sock;)是正确的。