tp5-nginx配置

做项目要弄一个微信管理系统,涉及到tp5,为了pathinfo问题改了好久的配置。耽误了不少的功夫。当然其中也有项目的因素,更加坚定了之前的想法。

废话不说,适应tp的配置如下:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
server {
listen 80;
root /www/rhaphp;
index index.php index.html index.htm index.nginx-debian.html;
server_name rhaphp.localhost;
location / {
index index.php index.html index.htm;
try_files $uri /index.php$uri;
if (!-e $request_filename) {
#rewrite ^/(.*)$ /index.php?$1 last;
rewrite ^(.*)$ /index.php?s=$1 last;
break;
}
client_max_body_size 50m;
}

location ~ \.php(.*)$ {
fastcgi_pass php:9000;
fastcgi_index index.php;
fastcgi_split_path_info ^(.+\.php)(.*)$;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
include fastcgi_params;
}

}