最近花了点时间用php框架Slim做了个图片管理的小模块,由于不想单独创建域名+虚拟站点来部署,想直接放到网站的子目录下,折腾了一段时间终于搞定了,比如站点的根目录是/home/www/site/,nginx的location配置如下
# 部署目录/home/www/site/urlgo
location ^~ /urlgo {
root /home/www/site/;
index index.php;
try_files $uri $uri/ /urlgo/index.php$is_args$args;
location ~ [^/]\.php(/|$)
{
try_files $uri =404;
fastcgi_pass unix:/tmp/php-cgi.sock;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_split_path_info ^(.+\.php)(.*)$;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
include fastcgi.conf;
}
}
我要评论