Created
March 31, 2017 05:36
-
-
Save boypt/23927399dec772a71153762acd328c17 to your computer and use it in GitHub Desktop.
ThinkPHP 5 子目录伪静态Nginx规则
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
upstream php { | |
server 127.0.0.1:9000; | |
} | |
server { | |
listen 80; | |
gzip on; | |
gzip_min_length 1000; | |
gzip_types application/json text/css application/x-javascript; | |
client_max_body_size 128m; | |
index index.html index.htm index.php; | |
server_name _; | |
root /srv/http/php; | |
include /etc/nginx/conf.d/php.d/*.conf; | |
location /nginx_status { | |
stub_status on; | |
} | |
# simple php | |
location / { | |
} | |
# thinkphp5 projects | |
location /tpproject1 { | |
try_files $uri @thinkphp; | |
} | |
location /tpproject2 { | |
try_files $uri @thinkphp; | |
} | |
location @thinkphp { | |
set $tpdir ''; | |
set $tppath ''; | |
if ($uri ~ ^/([^/]+)(.*$)) { | |
set $tpdir $1; | |
set $tppath $2; | |
} | |
include fastcgi_params; | |
fastcgi_param PATH_INFO $tppath; | |
fastcgi_param SCRIPT_FILENAME $document_root/$tpdir/public/index.php; | |
fastcgi_pass php; | |
} | |
location ~ \.php(.*)$ { | |
try_files $uri =404; | |
fastcgi_pass php; | |
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; | |
include fastcgi_params; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment