February 9, 2010 by Chan Cham Chung
一个项目是apache+resin的架构,有一条 rewrite 规则是这样的:
RewriteRule ^/flashinfo/vinfo/([a-z0-9A-Z_]+).xml$ /video/videolist.htm?sid=$1 [PT,L]
其中,\.htm 交给resin处理
<LocationMatch (.*)\.htm>
SetHandler caucho-request
</LocationMatch>
理论上,访问 /flashinfo/vinfo/V5OJEFN7C.xml 文件,是会代理访问到 /video/videolist.htm?sid=V5OJEFN7C 的。
但事实上,却403了,如下:
$curl -I -H host:so.v.test.com http://127.0.0.1/flashinfo/vinfo/V5OJEFN7C.xml
HTTP/1.1 403 Forbidden
Date: Tue, 09 Feb 2010 07:29:30 GMT
Server: Apache/2.2.11 (Unix) Resin/3.0.26
Content-Type: text/html; charset=iso-8859-1
让我看看rewrite后的访问是否正常:
$curl -I -H host:so.v.test.com http://127.0.0.1/video/videolist.htm?sid=V5OJEFN7C
HTTP/1.1 200 OK
Date: Tue, 09 Feb 2010 07:33:23 GMT
Server: Apache/2.2.11 (Unix) Resin/3.0.26
Cache-Control: max-age=600
Expires: Tue, 09 Feb 2010 07:43:23 GMT
Content-Type: text/html
究竟什么原因呢??我看了一下,应该是这样的:
原因在于,在DocumentRoot下,有一个错误的软链video.
$ls -alh| grep video
lrwxrwxrwx 1 root root 29 02-09 15:29 video -> /data/videopage
而/data/videopage这个目录是不存在的,所以video是一个错误的软链,rewrite 后的地址是 /video/videolist.htm?sid=$1 ,这样就爆403了。
真奇怪,其实apache 根本不用管我有没有video 这个目录的,因为都是转发到resin 去处理的了。既然想不通,就先记下。。。
我还做了两个测试:
1,让 video 成为一个正确的软链,curl 测试结果,200 。
2,把 video 删去,不存在这个软链,curl 测试结果,200。
————————————
结论:apache rewrite 后的地址,如 /data/dopost.jsp?sid=$1 这种,如果data 是一个错误的软链,尽管动态程序/data/dopost.jsp?sid=$1是正确的,apache 的 rewrite 都会不成功,返回 403 。如果 data 是一个正确的软链或者压根不存在,apache 正确地rewrite 。
Tags: apache, linux
Categories: technology •
No Comments »
January 19, 2010 by Chan Cham Chung
部门明天要上一个大项目啊,我今天赶紧搭监控。
原谅我这个古董,21 世纪了,还在搭nagios。。。web 环境,我也还是很古董地选用apache + php_module 的方式。。。其实监控系统来说,没什么性能要求,apache和nagios 也符合我的需求了,好,开始!!
首先爆了一堆这样的错:
Deprecated: Assigning the return value of new by reference is deprecated in /data/nagios/share/pnp/include/function.inc.php on line 1029
Warning: date() [function.date]: It is not safe to rely on the system’s timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected ‘Asia/Chongqing’ for ‘CST/8.0/no DST’ instead in /data/nagios/share/pnp/include/function.inc.php on line 560
貌似 5.3.0 才报这样的错,5.2.9 也没有爆啊。。。没错,我是很懒,但一般我都会追求真相的。但是,项目明天就要上线了啊,时间不允许我这样玩了,我还是懒一点吧。。。以解决问题为最终目标!!
让我设timezone。。。不太会php啊。。。也没研究过nagios的架构。。。直接一点吧,见到什么改什么!!
function.inc.php 貌似是一个基础函数,每个函数都会include它的,我在里面显式地指定timezone总可以吧,于是在function.inc.php 里加一句
date_default_timezone_set(‘Asia/Chongqing’);
哈哈,timezone 的 warning 解决了!但问题随之又来了。。。又报错。。。
Deprecated: Function eregi() is deprecated in /data/nagios/share/pnp/include/function.inc.php on line 1505
函数 deprecated 了。。。算了,我决定改php.ini,屏蔽错误和warning!
打开 phpinfo() 看一下php.ini 在哪里,找不到。。。
在 httpd.conf 里加一句:
PHPIniDir “/data/apache/conf”
随便copy一个php.ini过来,刚才google了一下,好像是 error_reporting 的问题,但不管我怎么改error_reporting的组合,都无法成功。。。突然被我看到这样的字眼:
display_errors = On
哈哈,还不是你!!把你关了总可以了吧!!
display_errors = Off
apachectl graceful 一下,哈哈,问题解决了!!!可以用了!!继续配置监控。。。
唉,LAMP 如此经典的组合,我了解得还是不够啊!!
Tags: apache, nagios, php
Categories: technology •
No Comments »