nginx

server {
listen 80;
server_name ly.com;

charset utf-8;
access_log /usr/local/var/log/nginx/test-local.com.access.log main;
error_log /usr/local/var/log/nginx/test-local.com.error.log;

root /Users/zuanbank/pg/www/project/lianyi/Public;
#hide index.php工
location / {
index index.php;
# 虽然 if 不规范但 rewrite 还是很方便的 可以兼容 yii2 和 tp 的 pathinfo 模式
if (!-e $request_filename){
rewrite ^/(.*)$ /index.php/$1 last;
break;
}

}

#handler php request
#include enable-php.conf;
location ~ [^/]\.php(/|$)
{
#listen unix socket
#fastcgi_pass unix:/tmp/php-cgi.sock;
#listen tcp socket
fastcgi_pass 127.0.0.1:9001;

fastcgi_index index.php;
include fastcgi.conf;

#pathinfo
fastcgi_split_path_info ^(.+?\.php)(/.*)$;
set $path_info $fastcgi_path_info;
fastcgi_param PATH_INFO $path_info;
try_files $fastcgi_script_name =404;
}

#handler static resource
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
{
expires 30d;
}

location ~ .*\.(js|css)?$
{
expires 12h;
}

#forbidden access . type
location ~ /\.
{
deny all;
}
}

2019-03-14
暂无评论

发表评论