2008年5月29日星期四

乱码-utf8

乱码,乱码!乱马1/2
做web难免会遇到乱码,可最近迁移完服务器后,用户post上来的数据有人出现的是乱码(几率很小)。
squid -> apache ->php->mysql
apache 中页面编码的设置为utf8
真是奇怪了,mysql

mysql> show variables like 'collation%';
+----------------------+-----------------+
| Variable_name | Value |
+----------------------+-----------------+
| collation_connection | utf8_general_ci |
| collation_database | utf8_general_ci |
| collation_server | utf8_general_ci |
+----------------------+-----------------+

mysql> show variables like 'character\_set\_%';
+--------------------------+-------+
| Variable_name | Value |
+--------------------------+-------+
| character_set_client | utf8 |
| character_set_connection | utf8 |
| character_set_database | utf8 |
| character_set_results | utf8 |
| character_set_server | utf8 |
| character_set_system | utf8 |


apache 的页面是设置的utf8
实在是头疼不知道问题出现在哪里,不过有传输的地方就有编码的不一直,只有先在每一段设置下监控,看乱码最先是在哪里产生的!
初步猜测应该是在squid->apache这里由于网络问题产生的:)
先在这里记录下,前端稍微也做下调整。
update(2008-06-09):可能是别人写得发帖机器人post过来数据的编码存在一些问题。
update(2008-11-26):问题已经彻底解决,原因是之前有个和电信互联星空的一个合作项目,他们的页面编码是gb2312的,服务器是以前的老web服务器(域名不一样),由于我们迁移后,数据库的编码做了统一,而从合作项目post过来的数据作为gb2312过来的,所以插入数据库的时候数据乱码了!把post过来的数据做了下处理就好了:)

2008年5月27日星期二

mysql 安装

安装mysql时可能会遇到下面的问题(os :centos 5.0)
checking for termcap functions library... configure: error: No curses/termcap library found

解决方法:
yum install ncurses-devel

2008年5月5日星期一

header信息不一致

遇到一个trouble
一个css 访问的过程是squid ->apache(deflate)
直接访问apache是可以得到正确的header

HTTP/1.1 200 OK
Date: Mon, 05 May 2008 07:32:32 GMT
Server: Apache
Last-Modified: Thu, 27 Mar 2008 02:32:28 GMT
ETag: "278c15c-19da-ff234700"
Accept-Ranges: bytes
Cache-Control: max-age=5184000
Expires: Fri, 04 Jul 2008 07:32:32 GMT
Vary: Accept-Encoding
Content-Encoding: gzip
Content-Length: 1834
Connection: close
Content-Type: text/css


而经过了squid 后,时而好,时而不好
下面是不好

Date: Mon, 05 May 2008 07:30:29 GMT
Server: Apache
Content-Type: text/plain; charset=UTF-8
Last-Modified: Thu, 27 Mar 2008 02:32:28 GMT
ETag: "278c15c-19da-ff234700"
Accept-Ranges: bytes
Content-Length: 6618
Cache-Control: max-age=5184000
Expires: Fri, 04 Jul 2008 07:29:29 GMT
Age: 60
***-Cache: MISS from nj-1.***.com
***-Cache-Lookup: MISS from nj-1.***.com:80
Via: 1.0 nj-1.***.com:80 (*** Cache)


过squid好的情况

HTTP/1.0 200 OK
Date: Mon, 05 May 2008 07:33:40 GMT
Server: Apache
Last-Modified: Thu, 27 Mar 2008 02:32:28 GMT
ETag: "278c15c-19da-ff234700"
Accept-Ranges: bytes
Cache-Control: max-age=5184000
Expires: Fri, 04 Jul 2008 07:33:40 GMT
Vary: Accept-Encoding
Content-Encoding: gzip
Content-Length: 1834
Content-Type: text/css
***-Cache: MISS from nj-1.***.com
***-Cache-Lookup: MISS from nj-1.***.com:80
Via: 1.0 nj-1.***.com:80 (*** Cache)
Connection: close


已知的情况
1.url带问号,如:

www/style/layout1.css?v=20080327_v1.css

2.apache已设置mod_deflate,和 mod_mem_cache,apache的addtype是正确的

CacheEnable mem /
MCacheSize 10240
McacheMaxObjectCount 5000


猜测原因1,mod_mem_cache的问题,squid设置的问题
需要进一步关注:)