目录标题
1. 什么是openresty
2. 操作
1. tar zxf openresty-1.13.6.1.tar.gz
2. cd openresty-1.13.6.1
./configure --prefix=/usr/local/openresty
gmake && gmake install
3. nginx -s stop
4. cd /usr/local/openresty/nginx/conf/
vim nginx.conf
user nginx nginx;
http {
include mime.types;
default_type application/octet-stream;
upstream memcache {
server localhost:11211;
keepalive 512;
}
location /memc{
internal; # 只接收内部访问,不接受外部http访问,比较安全。
memc_connect_timeout 100ms;
memc_send_timeout 100ms; # 后端服务器数据回传时间
memc_read_timeout 100ms; # 连接成功后,后端服务器响应时间
set $memc_key $query_string;
set $memc_exptime 300;
memc_pass memcache;
}
location ~ \.php$ {
set $key $uri$args;
# http的get方法表示get、put方法表示set
srcache_fetch GET /memc $key; # 请求php页面时,先回取memecache中找,如果没有找到,正常访问
srcache_store PUT /memc $key; # 访问结束后将结果存到memcache,下次访问时直接从缓存中拿
root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
include fastcgi.conf;
}
5. cp /usr/local/lnmp/nginx/html/index.php /usr/local/openresty/nginx/html/
6. cp /usr/local/lnmp/nginx/html/example.php /usr/local/openresty/nginx/html/
7. cd /usr/local/openresty/nginx/sbin/
./nginx
测试:
[kiosk@foundation60 images]$ ab -c 10 -n 5000 http://172.25.60.253/index.php
Concurrency Level: 10
Time taken for tests: 13.763 seconds
Complete requests: 5000
[kiosk@foundation60 images]$ ab -c 10 -n 5000 http://172.25.60.253/example.php
Concurrency Level: 10
Time taken for tests: 1.907 seconds
Complete requests: 5000
速度明显缩短