nginx.conf学习

nginx的模块
upstream-keepalive-nginx-module-0.3
在openresty里面保函,长连接的。很有用哦
[color=red]注意那个echo命令
看那个变量不认识就打印出来吧[/color]

在mac下
[color=red]echo-nginx-module[/color]里面有echo等
nginx_hello_world是自己写的,
[color=orange]ngx_devel_kit[/color]是set-misc-nginx的以来
[color=orange]set-misc-nginx[/color]是设置参数的set_unescape_uri等
./configure \
--with-debug \
--prefix=/Users/apple/Desktop/myfile/nginxtest/nginx \
--add-module=/Users/apple/Desktop/myfile/nginxtest/echo-nginx-module-0.37rc7/ \
--add-module=/Users/apple/Desktop/myfile/nginxtest/nginx_hello_world/ \
--add-module=/Users/apple/Desktop/myfile/nginxtest/ngx_devel_kit-0.2.17/ \
--add-module=/Users/apple/Desktop/myfile/nginxtest/set-misc-nginx-module-0.22rc3/ \
--with-cc-opt="-Wno-deprecated-declarations"

效果
sh-3.2# curl http://localhost/testurl
hello anonymous!
sh-3.2# curl http://localhost/testurl?persion=heihei
hello heihei!
sh-3.2#
配置文件为:

location /hello {
hello_world;
}
# location /foo {
# set $a hello;
# echo_exec /bar;
# }
#
# location /bar {
# echo "a = [$a]";
# }
location /foo {
set $a hello;
rewrite ^ /bar;
}

location /bar {
echo "a = [$a]";
}

location /testurl {
set_unescape_uri $persion $arg_persion;
set_if_empty $persion 'anonymous';
echo 'hello $persion!';
}
location /merge {
echo '[';
echo_location_async /moon;
echo ',';
echo_location_async /earth;
echo ']';
}
location /moon {
echo '"moon"';
}
location /earth {
echo '"earth"';
}


注意使用$arg_persion,就是url后面的参数persion
curl http://localhost/testurl?persion=haha
curl http://localhost/merge
用ab压
[color=red]sh-3.2# ab -n 1 http://localhost:80/testurl[/color]
This is ApacheBench, Version 2.3 <$Revision: 655654 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking localhost (be patient)...apr_socket_recv: Connection refused (61)
是因为没起httpd
蛋疼ab不能直接用?
httpd
之后
还要ulimit -a
看看open file是否够
如果不够 ulimit -n 10240

安装http_load:http://www.acme.com/software/http_load/

http_load
-P 并发用户的进程数
-f 总计的访问次数
-r 每秒的访问次数
-s 总计的访问时间
url是一个文件
里面存 http://localhost/testurl
http_load -rate 10 -second 3 url
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值