摘要: 在nginx里的ngx_tr_t结构是字符串定义如下typedef struct { size_t len; u_char *data;}ngx_str_t;在给这样的结构体赋值的时候,nginx常用ngx_string(),这其实是个宏,如下#define ngx_string(str) { sizeof(str) - 1, (u_char *) str }当要建一个ngx_str_t类型的字符串,正确的做法是ngx_str_t mystr = ngx_string("hello");因为sizeof(str) - 1赋给len,sizeof()计算字符串长度会... 阅读全文
posted @ 2013-07-15 16:48 sunsweet 阅读(883) 评论(0) 推荐(0) 编辑
摘要: 1.用你最喜欢的编辑器来敲命令 command 在已经敲完的命令后按,会打开一个你指定的编辑器(比如vim,通过环境变 量$EDITOR指定),里面就是你刚输入的命令,然后爱怎么编辑就怎么编辑吧,特别是那些参数异常复杂的程序,比如 mencoder/ffmpeg,一个命令动辄3、4行的,要修改其中的参数,这个方法最合适不过了,保存退出后自动执行这个程序。 实际上这是readline 库的功能,在默认情况下,bash使用的是emacs模式的命令行操作方式,是 调用这个功能的一个绑定。如果你习惯使用vi模式,按可以实现同样功能。 如果你喜欢别的编辑器,可以在~/.bashrc里面放上比如... 阅读全文
posted @ 2013-07-07 22:59 sunsweet 阅读(598) 评论(0) 推荐(0) 编辑
摘要: 修改src/http/ngx_http_header_filter_module.c找到下面两行:static char ngx_http_server_string[] = "Server: nginx" CRLF;static char ngx_http_server_full_string[] = "Server: " NGINX_VER CRLF;将其修改为:static char ngx_http_server_string[] = "Server: nginx" CRLF;static char ngx_http_serv 阅读全文
posted @ 2013-07-06 16:27 sunsweet 阅读(1992) 评论(0) 推荐(0) 编辑
摘要: 在nginx中有几个关于uri的变量,包括$uri $request_uri $document_uri,下面看一下他们的区别 :$request_uri: /stat.php?id=1585378&web_id=1585378$uri /stat.php$document_uri: /stat.php$args #这个变量等于请求行中的参数。$content_length #请求头中的Content-length字段。$content_type #请求头中的Content-Type字段。$document_root #当前请求在root指令中指定的值。$host #请求主机头字段,否 阅读全文
posted @ 2013-07-06 15:27 sunsweet 阅读(6997) 评论(0) 推荐(0) 编辑
摘要: user root;worker_processes 4;#error_log logs/error.log;#error_log logs/error.log notice;#error_log logs/error.log info;#pid logs/nginx.pid;worker_rlimit_nofile 327680;events { worker_connections 327680; use epoll;}http { include mime.types; default_type application/... 阅读全文
posted @ 2013-07-05 01:37 sunsweet 阅读(773) 评论(2) 推荐(0) 编辑
摘要: log_format main '$remote_addr - $remote_user $time_local "$request_method http://$host$request_uri HTTP/1.1" $status $bytes_sent "$http_referer" "$http_user_agent" TCP_HIT:NONE $request_time';log_format miss '$remote_addr - $remote_user $time_local "$re 阅读全文
posted @ 2013-07-03 16:12 sunsweet 阅读(206) 评论(0) 推荐(0) 编辑
摘要: linux内核配置有一项tcp_keepalive_time,即tcp的保活定时器。当网络上两个建立连接的进程都没有数据向对方发送的时候,tcp会隔段时间发送一次保活数据,以保持连接,间隔时间就是tcp_keepalive_time设置的。默认是7200秒。在优化web服务器时,应该将数值设置的小一点,当客户关机,崩溃的时候可以更快的发现,而没必要等待2个小时才察觉,这样可以更快的清理无效的连接。http的keepalive : 默认http服务器在完成一个http响应以后会关闭这个连接,设置此项以后会保活一段时间,继续用此连接继续接受客户的请求。这样有效的减少了系统建立tcp连接的开销,但是 阅读全文
posted @ 2013-07-03 11:05 sunsweet 阅读(249) 评论(0) 推荐(0) 编辑
摘要: #!/bin/bashvariable="This is a fine mess."echo "$variable"# Regex matching with =~ operator within [[ double brackets ]].if [[ "$variable" =~ T.........fin*es* ]]# NOTE: 从bash V3.2开始,正则表达式不再用引号引起来then echo "match found" # match foundfi#!/bin/bashinput=$1if [[ 阅读全文
posted @ 2013-06-29 20:30 sunsweet 阅读(162) 评论(0) 推荐(0) 编辑
摘要: 如果在机器上发现有执行的脚本,却不知道在哪,可以这样找例如# netstat -ltnpActive Internet connections (only servers)Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name tcp 0 0 127.0.0.1:2208 0.0.0.0:* LISTEN 2288/hpiod t... 阅读全文
posted @ 2013-06-28 22:14 sunsweet 阅读(6918) 评论(0) 推荐(0) 编辑
摘要: [anonymous@localhost ~/lvs/ipvsadm-1.26]>>find ./ -maxdepth 3 -regex '.*Makefile.*' -o -regex '.*\.[ch]' -exec cat {} \; | wc -l4220[anonymous@localhost ~/lvs/ipvsadm-1.26]>>find ./ -maxdepth 3 \( -regex '.*Makefile.*' -o -regex '.*\.[ch]' \) -exec cat {} 阅读全文
posted @ 2013-06-28 20:50 sunsweet 阅读(441) 评论(0) 推荐(0) 编辑