邢栋博客
邢栋博客,Action博客,记录工作和生活中的点点滴滴
最完美 ThinkPHP(tp) 的 Nginx 配置文件
===系统===
LSB Version: :....(太长了) Distributor ID: CentOS Description: CentOS Linux release 8.2.2004 (Core) Release: 8.2.2004 Codename: Core
===使用官网给的没有生效===
location / { // …..省略部分代码 if (!-e $request_filename) { rewrite ^(.*)$ /index.php?s=/$1 last; } }
===于是===
server { listen 80; server_name mydomain.com; access_log /data/logs/access_nginx.log combined; root /data/www/test_sdk/public; index index.html index.htm index.php; location / { try_files $uri @rewrite; } location /nginx_status { stub_status on; access_log off; allow 127.0.0.1; deny all; } location @rewrite { set $static 0; if ($uri ~ \.(css|js|jpg|jpeg|png|gif|ico|woff|eot|svg|css\.map|min\.map)$) { set $static 1; } if ($static = 0) { rewrite ^/index.php(.*)$ /index.php?s=/$1 last; } } location ~ \.php/ { if ($request_uri ~ ^(.+\.php)(/.+?)($|\?)) { } #fastcgi_pass remote_php_ip:9000; fastcgi_pass unix:/dev/shm/php-cgi.sock; include fastcgi_params; fastcgi_param SCRIPT_NAME $1; fastcgi_param PATH_INFO $2; fastcgi_param SCRIPT_FILENAME $document_root$1; } location ~ \.php$ { #fastcgi_pass remote_php_ip:9000; fastcgi_pass unix:/dev/shm/php-cgi.sock; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } location ~ .*\.(gif|jpg|jpeg|png|bmp|swf|flv|mp4|ico)$ { expires 30d; access_log off; } location ~ .*\.(js|css)?$ { expires 7d; access_log off; } location ~ ^/(\.user.ini|\.ht|\.git|\.svn|\.project|LICENSE|README.md) { deny all; } }
===参考链接===
https://www.kancloud.cn/manual/thinkphp6_0/1037488
https://www.seasidecrab.com/tp/487.html
http://www.thinkphp.cn/topic/34380.html
nginx中fastcgi_param参数说明
fastcgi_param QUERY_STRING $query_string; #请求的参数;如?app=123
fastcgi_param REQUEST_METHOD $request_method; #请求的动作(GET,POST)
fastcgi_param CONTENT_TYPE $content_type; #请求头中的Content-Type字段
fastcgi_param CONTENT_LENGTH $content_length; #请求头中的Content-length字段。
fastcgi_param SCRIPT_NAME $fastcgi_script_name; #脚本名称
fastcgi_param REQUEST_URI $request_uri; #请求的地址不带参数
fastcgi_param DOCUMENT_URI $document_uri; #与$uri相同。
fastcgi_param DOCUMENT_ROOT $document_root; #网站的根目录。在server配置中root指令中指定的值
fastcgi_param SERVER_PROTOCOL $server_protocol; #请求使用的协议,通常是HTTP/1.0或HTTP/1.1
fastcgi_param REQUEST_SCHEME $scheme;
fastcgi_param HTTPS $https if_not_empty;
fastcgi_param GATEWAY_INTERFACE CGI/1.1; #cgi 版本
fastcgi_param SERVER_SOFTWARE nginx/$nginx_version; #nginx 版本号,可修改、隐藏
fastcgi_param REMOTE_ADDR $remote_addr; #客户端IP
fastcgi_param REMOTE_PORT $remote_port; #客户端端口
fastcgi_param SERVER_ADDR $server_addr; #服务器IP地址
fastcgi_param SERVER_PORT $server_port; #服务器端口
fastcgi_param SERVER_NAME $server_name; #服务器名,域名在server配置中指定的server_name
# PHP only, required if PHP was built with --enable-force-cgi-redirect
fastcgi_param REDIRECT_STATUS 200;
fastcgi_param REQUEST_METHOD $request_method; #请求的动作(GET,POST)
fastcgi_param CONTENT_TYPE $content_type; #请求头中的Content-Type字段
fastcgi_param CONTENT_LENGTH $content_length; #请求头中的Content-length字段。
fastcgi_param SCRIPT_NAME $fastcgi_script_name; #脚本名称
fastcgi_param REQUEST_URI $request_uri; #请求的地址不带参数
fastcgi_param DOCUMENT_URI $document_uri; #与$uri相同。
fastcgi_param DOCUMENT_ROOT $document_root; #网站的根目录。在server配置中root指令中指定的值
fastcgi_param SERVER_PROTOCOL $server_protocol; #请求使用的协议,通常是HTTP/1.0或HTTP/1.1
fastcgi_param REQUEST_SCHEME $scheme;
fastcgi_param HTTPS $https if_not_empty;
fastcgi_param GATEWAY_INTERFACE CGI/1.1; #cgi 版本
fastcgi_param SERVER_SOFTWARE nginx/$nginx_version; #nginx 版本号,可修改、隐藏
fastcgi_param REMOTE_ADDR $remote_addr; #客户端IP
fastcgi_param REMOTE_PORT $remote_port; #客户端端口
fastcgi_param SERVER_ADDR $server_addr; #服务器IP地址
fastcgi_param SERVER_PORT $server_port; #服务器端口
fastcgi_param SERVER_NAME $server_name; #服务器名,域名在server配置中指定的server_name
# PHP only, required if PHP was built with --enable-force-cgi-redirect
fastcgi_param REDIRECT_STATUS 200;
nginx负载均衡 - 根据url做一致性hash
nginx负载均衡 - 根据url做一致性hash
目标:按照指定的参数(如分类/商品编号)做一致性hash,从而保证相同数据到一台机器上
先说下nginx里$request_uri和$uri的区别
$request_uri
This variable is equal to the *original* request URI as received from the client including the args. It cannot be modified. Look at $uri for the post-rewrite/altered URI. Does not include host name. Example: "/foo/bar.php?arg=baz"
这个变量等于从客户端发送来的原生请求URI,包括参数。它不可以进行修改。$uri变量反映的是重写后/改变的URI。不包括主机名。例如:"/foo/bar.php?arg=baz"
$uri
This variable is the current request URI, without any arguments (see $args for those). This variable will reflect any modifications done so far by internal redirects or the index module. Note this may be different from $request_uri, as $request_uri is what was originally sent by the browser before any such modifications. Does not include the protocol or host name. Example: /foo/bar.html
这个变量指当前的请求URI,不包括任何参数(见$args)。这个变量反映任何内部重定向或index模块所做的修改。注意,这和$request_uri不同,因$request_uri是浏览器发起的不做任何修改的原生URI。不包括协议及主机名。例如:"/foo/bar.html"
$document_uri
The same as $uri.
同$uri.
实现步骤
第一步:在nginx中做简单配置,先实现轮训,域名可以根据自己的来
server {
listen 80;
server_name default www.test.com;
location / {
proxy_pass http://www_posts;
index index.html index.htm;
}
}
upstream www_posts {
server 127.0.0.1:7001;
server 127.0.0.1:7002;
server 127.0.0.1:7003;
}
server {
listen 7001;
server_name default www.test.com;
location / {
root /data/www/post1/;
index index.html index.htm;
}
}
server {
listen 7002;
server_name default www.test.com;
location / {
root /data/www/post2/;
index index.html index.htm;
}
}
server {
listen 7003;
server_name default www.test.com;
location / {
root /data/www/post3/;
index index.html index.htm;
}
}
完成后 重启nginx
第二步创建程序文件
mkdir /data/www/post1; cd /data/www/post1;
vim 1.html //写入 1-1
vim 2.html //写入 1-2
vim 3.html //写入 1-3
mkdir /data/www/post2; cd /data/www/post2;
vim 1.html //写入 2-1
vim 2.html //写入 2-2
vim 3.html //写入 2-3
mkdir /data/www/post3; cd /data/www/post3;
vim 1.html //写入 3-1
vim 2.html //写入 4-2
vim 3.html //写入 3-3
通过浏览器访问 www.test.com/1.html,不断刷新,可分别出现1-1,2-1,3-1
第三步 自定义hash key
在server-location中加入
if ( $uri ~* "^\/(\d+).html$" ){ set $defurlkey $1; }
修改upstream,结果如下
upstream www_posts {
hash $defurlkey;
server 127.0.0.1:7001;
server 127.0.0.1:7002;
server 127.0.0.1:7003;
}
可通过分别访问,测试结果
www.test.com/1.html
www.test.com/2.html
www.test.com/3.html
目标:按照指定的参数(如分类/商品编号)做一致性hash,从而保证相同数据到一台机器上
先说下nginx里$request_uri和$uri的区别
$request_uri
This variable is equal to the *original* request URI as received from the client including the args. It cannot be modified. Look at $uri for the post-rewrite/altered URI. Does not include host name. Example: "/foo/bar.php?arg=baz"
这个变量等于从客户端发送来的原生请求URI,包括参数。它不可以进行修改。$uri变量反映的是重写后/改变的URI。不包括主机名。例如:"/foo/bar.php?arg=baz"
$uri
This variable is the current request URI, without any arguments (see $args for those). This variable will reflect any modifications done so far by internal redirects or the index module. Note this may be different from $request_uri, as $request_uri is what was originally sent by the browser before any such modifications. Does not include the protocol or host name. Example: /foo/bar.html
这个变量指当前的请求URI,不包括任何参数(见$args)。这个变量反映任何内部重定向或index模块所做的修改。注意,这和$request_uri不同,因$request_uri是浏览器发起的不做任何修改的原生URI。不包括协议及主机名。例如:"/foo/bar.html"
$document_uri
The same as $uri.
同$uri.
实现步骤
第一步:在nginx中做简单配置,先实现轮训,域名可以根据自己的来
server {
listen 80;
server_name default www.test.com;
location / {
proxy_pass http://www_posts;
index index.html index.htm;
}
}
upstream www_posts {
server 127.0.0.1:7001;
server 127.0.0.1:7002;
server 127.0.0.1:7003;
}
server {
listen 7001;
server_name default www.test.com;
location / {
root /data/www/post1/;
index index.html index.htm;
}
}
server {
listen 7002;
server_name default www.test.com;
location / {
root /data/www/post2/;
index index.html index.htm;
}
}
server {
listen 7003;
server_name default www.test.com;
location / {
root /data/www/post3/;
index index.html index.htm;
}
}
完成后 重启nginx
第二步创建程序文件
mkdir /data/www/post1; cd /data/www/post1;
vim 1.html //写入 1-1
vim 2.html //写入 1-2
vim 3.html //写入 1-3
mkdir /data/www/post2; cd /data/www/post2;
vim 1.html //写入 2-1
vim 2.html //写入 2-2
vim 3.html //写入 2-3
mkdir /data/www/post3; cd /data/www/post3;
vim 1.html //写入 3-1
vim 2.html //写入 4-2
vim 3.html //写入 3-3
通过浏览器访问 www.test.com/1.html,不断刷新,可分别出现1-1,2-1,3-1
第三步 自定义hash key
在server-location中加入
if ( $uri ~* "^\/(\d+).html$" ){ set $defurlkey $1; }
修改upstream,结果如下
upstream www_posts {
hash $defurlkey;
server 127.0.0.1:7001;
server 127.0.0.1:7002;
server 127.0.0.1:7003;
}
可通过分别访问,测试结果
www.test.com/1.html
www.test.com/2.html
www.test.com/3.html
nginx限制某个IP同一时间段的访问次数(转)
坑说明
公司内有好几个网段,测试那边在测试的时候偶尔会出现503,我这边切换了几个网,有的可以正常访问范围,有的是出现503,访问html文件也是如此,最后查看服务器的nginx配置,发现了一些参数,原来是nginx限制某个IP同一时间段的访问次数
相关资料
HttpLimitReqModul用来限制连单位时间内连接数的模块,使用limit_req_zone和limit_req指令配合使用来达到限制。一旦并发连接超过指定数量,就会返回503错误。
HttpLimitConnModul用来限制单个ip的并发连接数,使用limit_zone和limit_conn指令
这两个模块的区别前一个是对一段时间内的连接数限制,后者是对同一时刻的连接数限制
HttpLimitReqModul 限制某一段时间内同一ip访问数实例
limit_zone只能定义在http作用域,limit_conn可以定义在http server location作用域
nginx白名单设置
以上配置会对所有的ip都进行限制,有些时候我们不希望对搜索引擎的蜘蛛或者自己测试ip进行限制,
对于特定的白名单ip我们可以借助geo指令实现。
geo指令定义了一个白名单$limited变量,默认值为1,如果客户端ip在上面的范围内,$limited的值为0
2.使用map指令映射搜索引擎客户端的ip为空串,如果不是搜索引擎就显示本身真是的ip,这样搜索引擎ip就不能存到limit_req_zone内存session中,所以不会限制搜索引擎的ip访问
map $limited $limit {
1 $binary_remote_addr;
0 "";
}
3.设置limit_req_zone和limit_req
limit_req_zone $limit zone=foo:1m rate=10r/m;
limit_req zone=foo burst=5;
最后我们使用ab压php-fpm的方式,对上面的方法效果实际测试下
例1:限制只允许一分钟内只允许一个ip访问60次配置,也就是平均每秒1次
首先我们准备一个PHP脚本放在根目录下$document_root
test.php
for( $i=0; $i < 1000; $i++)
echo 'Hello World';
?>
nginx配置增加limit_req_zone 和 limit_req
ab -n 5 -c 1 http://www.weizhang.org/test.php
118.144.94.193 - - [22/Dec/2012:06:27:06 +0000] "GET /test.php HTTP/1.0" 200 11000 "-" "ApacheBench/2.3"
118.144.94.193 - - [22/Dec/2012:06:27:06 +0000] "GET /test.php HTTP/1.0" 503 537 "-" "ApacheBench/2.3"
118.144.94.193 - - [22/Dec/2012:06:27:07 +0000] "GET /test.php HTTP/1.0" 503 537 "-" "ApacheBench/2.3"
118.144.94.193 - - [22/Dec/2012:06:27:07 +0000] "GET /test.php HTTP/1.0" 503 537 "-" "ApacheBench/2.3"
118.144.94.193 - - [22/Dec/2012:06:27:07 +0000] "GET /test.php HTTP/1.0" 503 537 "-" "ApacheBench/2.3"
未设置brust和nodelay可以看到该配置只允许每秒访问1次,超出的请求返回503错误
ab -n 5 -c 1 http://www.weizhang.org/test.php
118.144.94.193 - - [22/Dec/2012:07:01:00 +0000] "GET /test.php HTTP/1.0" 200 11000 "-" "ApacheBench/2.3"
118.144.94.193 - - [22/Dec/2012:07:01:00 +0000] "GET /test.php HTTP/1.0" 200 11000 "-" "ApacheBench/2.3"
118.144.94.193 - - [22/Dec/2012:07:01:01 +0000] "GET /test.php HTTP/1.0" 503 537 "-" "ApacheBench/2.3"
118.144.94.193 - - [22/Dec/2012:07:01:01 +0000] "GET /test.php HTTP/1.0" 503 537 "-" "ApacheBench/2.3"
原文地址:http://blog.csdn.net/gebitan505/article/details/17610485
公司内有好几个网段,测试那边在测试的时候偶尔会出现503,我这边切换了几个网,有的可以正常访问范围,有的是出现503,访问html文件也是如此,最后查看服务器的nginx配置,发现了一些参数,原来是nginx限制某个IP同一时间段的访问次数
相关资料
HttpLimitReqModul用来限制连单位时间内连接数的模块,使用limit_req_zone和limit_req指令配合使用来达到限制。一旦并发连接超过指定数量,就会返回503错误。
HttpLimitConnModul用来限制单个ip的并发连接数,使用limit_zone和limit_conn指令
这两个模块的区别前一个是对一段时间内的连接数限制,后者是对同一时刻的连接数限制
HttpLimitReqModul 限制某一段时间内同一ip访问数实例
http{ ... #定义一个名为allips的limit_req_zone用来存储session,大小是10M内存, #以$binary_remote_addr 为key,限制平均每秒的请求为20个, #1M能存储16000个状态,rete的值必须为整数, #如果限制两秒钟一个请求,可以设置成30r/m limit_req_zone $binary_remote_addr zone=allips:10m rate=20r/s; ... server{ ... location { ... #限制每ip每秒不超过20个请求,漏桶数burst为5 #brust的意思就是,如果第1秒、2,3,4秒请求为19个, #第5秒的请求为25个是被允许的。 #但是如果你第1秒就25个请求,第2秒超过20的请求返回503错误。 #nodelay,如果不设置该选项,严格使用平均速率限制请求数, #第1秒25个请求时,5个请求放到第2秒执行, #设置nodelay,25个请求将在第1秒执行。 limit_req zone=allips burst=5 nodelay; ... } ... } ... }HttpLimitZoneModule 限制并发连接数实例
limit_zone只能定义在http作用域,limit_conn可以定义在http server location作用域
http{ ... #定义一个名为one的limit_zone,大小10M内存来存储session, #以$binary_remote_addr 为key #nginx 1.18以后用limit_conn_zone替换了limit_conn #且只能放在http作用域 limit_conn_zone one $binary_remote_addr 10m; ... server{ ... location { ... limit_conn one 20; #连接数限制 #带宽限制,对单个连接限数,如果一个ip两个连接,就是500x2k limit_rate 500k; ... } ... } ... }
nginx白名单设置
以上配置会对所有的ip都进行限制,有些时候我们不希望对搜索引擎的蜘蛛或者自己测试ip进行限制,
对于特定的白名单ip我们可以借助geo指令实现。
http{ geo $limited{ default 1; #google 64.233.160.0/19 0; 65.52.0.0/14 0; 66.102.0.0/20 0; 66.249.64.0/19 0; 72.14.192.0/18 0; 74.125.0.0/16 0; 209.85.128.0/17 0; 216.239.32.0/19 0; #M$ 64.4.0.0/18 0; 157.60.0.0/16 0; 157.54.0.0/15 0; 157.56.0.0/14 0; 207.46.0.0/16 0; 207.68.192.0/20 0; 207.68.128.0/18 0; #yahoo 8.12.144.0/24 0; 66.196.64.0/18 0; 66.228.160.0/19 0; 67.195.0.0/16 0; 74.6.0.0/16 0; 68.142.192.0/18 0; 72.30.0.0/16 0; 209.191.64.0/18 0; #My IPs 127.0.0.1/32 0; 123.456.0.0/28 0; #example for your server CIDR }
geo指令定义了一个白名单$limited变量,默认值为1,如果客户端ip在上面的范围内,$limited的值为0
2.使用map指令映射搜索引擎客户端的ip为空串,如果不是搜索引擎就显示本身真是的ip,这样搜索引擎ip就不能存到limit_req_zone内存session中,所以不会限制搜索引擎的ip访问
map $limited $limit {
1 $binary_remote_addr;
0 "";
}
3.设置limit_req_zone和limit_req
limit_req_zone $limit zone=foo:1m rate=10r/m;
limit_req zone=foo burst=5;
最后我们使用ab压php-fpm的方式,对上面的方法效果实际测试下
例1:限制只允许一分钟内只允许一个ip访问60次配置,也就是平均每秒1次
首先我们准备一个PHP脚本放在根目录下$document_root
test.php
for( $i=0; $i < 1000; $i++)
echo 'Hello World';
?>
nginx配置增加limit_req_zone 和 limit_req
http{ ... limit_req_zone $binary_remote_addr zone=allips:10m rate=60r/m; ... server{ ... location { ... limit_req zone=allips; ... } ... } ... }
ab -n 5 -c 1 http://www.weizhang.org/test.php
118.144.94.193 - - [22/Dec/2012:06:27:06 +0000] "GET /test.php HTTP/1.0" 200 11000 "-" "ApacheBench/2.3"
118.144.94.193 - - [22/Dec/2012:06:27:06 +0000] "GET /test.php HTTP/1.0" 503 537 "-" "ApacheBench/2.3"
118.144.94.193 - - [22/Dec/2012:06:27:07 +0000] "GET /test.php HTTP/1.0" 503 537 "-" "ApacheBench/2.3"
118.144.94.193 - - [22/Dec/2012:06:27:07 +0000] "GET /test.php HTTP/1.0" 503 537 "-" "ApacheBench/2.3"
118.144.94.193 - - [22/Dec/2012:06:27:07 +0000] "GET /test.php HTTP/1.0" 503 537 "-" "ApacheBench/2.3"
未设置brust和nodelay可以看到该配置只允许每秒访问1次,超出的请求返回503错误
http{ ... limit_req_zone $binary_remote_addr zone=allips:10m rate=60r/m; ... server{ ... location { ... limit_req zone=allips burst=1 nodelay; ... } ... } ... }
ab -n 5 -c 1 http://www.weizhang.org/test.php
118.144.94.193 - - [22/Dec/2012:07:01:00 +0000] "GET /test.php HTTP/1.0" 200 11000 "-" "ApacheBench/2.3"
118.144.94.193 - - [22/Dec/2012:07:01:00 +0000] "GET /test.php HTTP/1.0" 200 11000 "-" "ApacheBench/2.3"
118.144.94.193 - - [22/Dec/2012:07:01:01 +0000] "GET /test.php HTTP/1.0" 503 537 "-" "ApacheBench/2.3"
118.144.94.193 - - [22/Dec/2012:07:01:01 +0000] "GET /test.php HTTP/1.0" 503 537 "-" "ApacheBench/2.3"
118.144.94.193 - - [22/Dec/2012:07:01:01 +0000] "GET /test.php HTTP/1.0" 503 537 "-" "ApacheBench/2.3"
设置brust=1和nodelay后允许第1秒处理两个请求。原文地址:http://blog.csdn.net/gebitan505/article/details/17610485
关于nginx启动、停止、重启命令总结
标签:
nginx
nginx启动
/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
nginx停止
1.从容停止
ps aux|grep nginx //master进程号,例如是 1480
kill -QUIT 1480
2.快速停止
kill -TERM 1480 或 kill INT 1480
3.强制停止
pkill -9 nginx 或 killall nginx
nginx重启
检测配置文件是否正确
nginx -t
然后
nginx -s reload 或者 kill -HUP 1480
关于nginx的master和worker进程模型
标签:
nginx
关于nginx的master和worker进程模型
正常执行中的nginx会有多个进程,最基本的有master process(监控进程,也叫做主进程)和woker process(工作进程),还可能有cache相关进程。
master进程
监控进程充当整个进程组与用户的交互接口,同时对进程进行监护。它不需要处理网络事件,不负责业务的执行,只会通过管理worker进程来实现重启服务、平滑升级、更换日志文件、配置文件实时生效等功能。
worker进程
worker进程的主要任务是完成具体的任务逻辑。其主要关注点是与客户端或后端真实服务器(此时nginx作为中间代理)之间的数据可读/可写等I/O交互事件,所以工作进程的阻塞点是在像select()、epoll_wait()等这样的I/O多路复用函数调用处,以等待发生数据可读/写事件。当然也可能被新收到的进程信号中断。
原文具体链接:http://www.tuicool.com/articles/NNZvquV
nginx访问ci框架出现Access denied.
nginx访问ci框架出现Access denied.
nginx访问ci框架出现Access denied.
Lepus(天兔)web管理台nginx重写
server {
listen 80;
server_name lepus.example.com;
client_max_body_size 10m;
index index.html index.htm index.php;
root /work/www/lepus;
fastcgi_intercept_errors on;
location / {
root /work/www/lepus;
index index.html index.htm index.php;
#rewrite规则如下:
rewrite ^(.*)$ /index.php?s=$1 last;
}
location ~ ^(.+\.php)(.*)$ {
root /work/www/lepus;
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;
fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
#注意:去临时文件夹内找到你的php-cgi,也可能php-cgi.sock不是这么个名字。
fastcgi_pass unix:/dev/shm/php-cgi.sock;
include fastcgi_params;
}
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$ {
expires 30d;
}
location ~ .*\.(js|css)?$ {
expires 1h;
}
}
修改php.ini配置文件
cgi.fix_pathinfo=1
nginx访问ci框架出现Access denied.
Lepus(天兔)web管理台nginx重写
server {
listen 80;
server_name lepus.example.com;
client_max_body_size 10m;
index index.html index.htm index.php;
root /work/www/lepus;
fastcgi_intercept_errors on;
location / {
root /work/www/lepus;
index index.html index.htm index.php;
#rewrite规则如下:
rewrite ^(.*)$ /index.php?s=$1 last;
}
location ~ ^(.+\.php)(.*)$ {
root /work/www/lepus;
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;
fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
#注意:去临时文件夹内找到你的php-cgi,也可能php-cgi.sock不是这么个名字。
fastcgi_pass unix:/dev/shm/php-cgi.sock;
include fastcgi_params;
}
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$ {
expires 30d;
}
location ~ .*\.(js|css)?$ {
expires 1h;
}
}
修改php.ini配置文件
cgi.fix_pathinfo=1