今天遇到一个奇怪的问题,nginx的access日志不支持中文,其中我的环境变量是支持中文的:

nginx日志不支持中文_第1张图片

最后的解决办法把nginx的版本降低(原先是1.2.1现在是1.0.5)

未将版本前的日志:

119.14.15.78 - - [06/Dec/2012:20:40:58 +0800] "GET /wide/task/manage HTTP/1.1" 200 2186 "http://apns.ios.ijinshan.com/wide/index" "Mozilla/5.0 (Windows NT 6.1; rv:16.0) Gecko/20100101 Firefox/16.0"
219.143.15.78 - - [06/Dec/2012:20:42:21 +0800] "POST /rpc/report/device HTTP/1.1" 200 42 "-" "\xE9\x87\x91\xE5\xB1\xB1\xE7\x94\xB5\xE6\xB1\xA0\xE5\x8C\xBB\xE7\x94\x9F 3.0.9640.277 (iPhone; iPhone OS 6.0.1; zh_CN)"
219.143.15.78 - - [06/Dec/2012:20:45:17 +0800] "POST /rpc/report/device HTTP/1.1" 200 42 "-" "\xE9\x87\x91\xE5\xB1\xB1\xE7\x94\xB5\xE6\xB1\xA0\xE5\x8C\xBB\xE7\x94\x9F 3.0.9640.277 (iPhone; iPhone OS 6.0.1; zh_CN)"
219.143.15.78 - - [06/Dec/2012:21:00:32 +0800] "POST /rpc/report/device HTTP/1.1" 200 42 "-" "\xE9\x87\x91\xE5\xB1\xB1\xE7\x94\xB5\xE6\xB1\xA0\xE5\x8C\xBB\xE7\x94\x9F 3.0.9640.277 (iPhone; iPhone OS 6.0.1; zh_CN)"
219.143.15.78 - - [06/Dec/2012:21:09:35 +0800] "POST /rpc/report/device HTTP/1.1" 200 42 "-" "\xE9\x87\x91\xE5\xB1\xB1\xE7\x94\xB5\xE6\xB1\xA0\xE5\x8C\xBB\xE7\x94\x9F 3.0.9640.277 (iPhone; iPhone OS 6.0.1; zh_CN)"
219.143.15.78 - - [06/Dec/2012:21:17:43 +0800] "POST /rpc/report/device HTTP/1.1" 200 42 "-" "\xE9\x87\x91\xE5\xB1\xB1\xE7\x94\xB5\xE6\xB1\xA0\xE5\x8C\xBB\xE7\x94\x9F 3.0.9640.277 (iPhone; iPhone OS 6.0.1; zh_CN)"
219.143.15.78 - - [06/Dec/2012:21:18:05 +0800] "POST /rpc/report/device HTTP/1.1" 200 42 "-" "\xE9\x87\x91\xE5\xB1\xB1\xE7\x94\xB5\xE6\xB1\xA0\xE5\x8C\xBB\xE7\x94\x9F 3.0.9640.277 (iPhone; iPhone OS 6.0.1; zh_CN)"
219.143.15.78 - - [06/Dec/2012:21:21:49 +0800] "POST /rpc/report/device HTTP/1.1" 200 42 "-" "\xE9\x87\x91\xE5\xB1\xB1\xE8\xA3\x85\xE6\x9C\xBA\xE5\xBF\x85\xE5\xA4\x87 2.4.7547.19 (iPhone; iPhone OS 6.0.1; zh_CN)"
219.143.15.78 - - [06/Dec/2012:21:37:33 +0800] "POST /rpc/report/device HTTP/1.1" 200 42 "-" "\xE9\x87\x91\xE5\xB1\xB1\xE7\x94\xB5\xE6\xB1\xA0\xE5\x8C\xBB\xE7\x94\x9F 3.0.9640.277 (iPhone; iPhone OS 6.0.1; zh_CN)"

降低版本后的日志:
7.136.24.221 - - [07/Dec/2012:16:07:57 +0800] "POST /rpc/report/device HTTP/1.1" 200 42 "-" "金山电池医生 3.4.8238.321 (iPhone; iPhone OS 5.1.1; zh_CN)"
27.188.236.140 - - [07/Dec/2012:16:07:57 +0800] "POST /rpc/report/device HTTP/1.1" 200 42 "-" "金山电池医生 3.5.9137.322 (iPhone; iPhone OS 5.1.1; zh_CN)"
112.224.65.229 - - [07/Dec/2012:16:07:57 +0800] "POST /rpc/report/device HTTP/1.1" 200 42 "-" "金山电池医生 3.5.9137.322 (iPhone; iPhone OS 6.0.1; zh_CN)"
117.143.123.171 - - [07/Dec/2012:16:07:57 +0800] "POST /rpc/report/device HTTP/1.1" 200 42 "-" "金山电池医生 3.5.9137.322 (iPhone; iPhone OS 6.0.1; zh_CN)"
117.82.182.2 - - [07/Dec/2012:16:07:57 +0800] "POST /rpc/report/device HTTP/1.1" 200 42 "-" "金山电池医生 3.5.9137.322 (iPhone; iPhone OS 6.0; zh_CN)"
27.52.68.198 - - [07/Dec/2012:16:07:57 +0800] "POST /rpc/report/device HTTP/1.1" 200 42 "-" "金山保險箱 1.7.7205.175 (iPhone; iPhone OS 6.0.1; zh_TW)"
221.9.247.34 - - [07/Dec/2012:16:07:57 +0800] "POST /rpc/report/device HTTP/1.1" 200 42 "-" "金山电池医生 3.5.9137.322 (iPhone; iPhone OS 6.0.1; zh_CN)"
61.148.244.97 - - [07/Dec/2012:16:07:57 +0800] "POST /rpc/report/device HTTP/1.1" 200 42 "-" "金山电池医生 3.5.9137.322 (iPhone; iPhone OS 5.1.1; zh_CN)"
90.148.22.7 - - [07/Dec/2012:16:07:57 +0800] "POST /rpc/report/device HTTP/1.1" 200 42 "-" "BatteryDoctor 3.2.7105.315 (iPod touch; iPhone OS 5.0.1; en_US)"
119.39.248.61 - - [07/Dec/2012:16:07:58 +0800] "POST /rpc/report/device HTTP/1.1" 200 42 "-" "金山電池醫生 3.2.7105.315 (iPhone; iPhone OS 5.1.1; zh_CN)"
211.137.59.42 - - [07/Dec/2012:16:07:58 +0800] "POST /rpc/report/device HTTP/1.1" 200 42 "-" "金山电池医生 3.4.8238.321 (iPhone; iPho

具体步骤:
     wget http://bj.download.ijinshan.com/yunwei/nginx-1.0.5.tar.gz  ##下载nginx的源码包
    tar xzf nginx-1.0.5.tar.gz  ##解压
   cd nginx-1.0.5 ##进入nginx目录
   /usr/local/nginx/sbin/nginx -V  ##查看nginx的编译参数
   ./configure --prefix=/usr/local/nginx --with-http_stub_status_module --with-openssl=/usr/local/openssl(此参数是上面查到的)
   make && make install(安装)
   ll -tr /usr/local/nginx/sbin/nginx* ##你看到有nginx和nginx.old
   ps -ef | grep nginx  ##查看当前的nginx的master的进程号
   kill -USR2 25518  ##从容切换到新的nginx
   tail /data/logs/apns.ijinshan.com.log ##查看是否支持中文