试验下安装ssl证书
--------------------------
1.学习
http://blog.chinaunix.net/xmlrpc.php?r=blog/article&uid=29773962&id=4614871
2.解决 error while loading shared libraries: libpcre.so.1的错误
/usr/local/webserver/nginx/sbin/nginx: error while loading shared libraries: libpcre.so.1: cannot open shared object file: No such file or directory
解决方法:
32位系统 [root@sever lib]# ln -s /usr/local/lib/libpcre.so.1 /lib
64位系统 [root@sever lib]# ln -s /usr/local/lib/libpcre.so.1 /lib64
3.nginx作为TCP反向代理
http://blog.csdn.net/oldmtn/article/details/47613509
4.配置虚拟主机
server {
listen 8000;
server_name localhost;
location / {
root /opt/openresty/nginx/html/code8/; #注意这里文件夹的位置要加 /
index index.html index.htm;
}
location /myname {
default_type text/html;
content_by_lua '
ngx.say("<p>hello world! myname</p>")
';
}
}
默认文件位置: /usr/local/etc/nginx/nginx.conf
查看错误日志文件,access日志文件位置,使用nginx -V 可以查看
5.windows下nginx调试
从命令行启动的时候,需要将conf文件夹拷贝到nginx.exe的同级目录下
[alert] could not open error log file: CreateFile() "logs/error.log" fail ,手动创建logs文件夹
6.学习资料
nginx模块开发
http://tengine.taobao.org/book/chapter_02.html
7.C10K问题
7.1单机最大TCP链接数,参考
http://blog.csdn.net/huangjin0507/article/details/52399957
客户端
client每次发起tcp连接请求时,除非绑定端口,通常会让系统选取一个空闲的本地端口(local port),该端口是独占的,不能和其他tcp连接共享。tcp端口的数据类型是unsigned short,因此本地端口个数最大只有65536(1000以下的是给系统用的,实际上只有6000多),端口0有特殊含义,不能使用,这样可用端口最多只有65535,所以在全部作为client端的情况下,最大tcp连接数为65535,这些连接可以连到不同的server ip。
服务端,理论上是2的48次方
服务程序listen在某个固定端口,然后客户端链接上来,一个链接的五元组中只有远程IP,远程port是不一样的,所以理论上是2的16次方(port) * 2的32次方(IP)
8.最大句柄
查看系统最多能支持多少文件句柄数,参考我的nr_open文章,资源里有修改参数的shell脚本
服务器配置优化参考(tcp_max_tw_buckets对大量的time_wait有效)
kernel.shmall = 4294967296
net.ipv4.tcp_fin_timeout = 30
net.ipv4.tcp_keepalive_time = 300
net.ipv4.ip_local_port_range = 10240 65535
net.core.somaxconn = 32768
net.core.netdev_max_backlog = 32768
net.ipv4.tcp_max_tw_buckets = 10000
vm.dirty_background_ratio = 5
vm.dirty_ratio = 10
net.ipv4.tcp_tw_recycle = 0
net.ipv4.tcp_tw_reuse = 0
net.ipv4.tcp_timestamps = 1