open_basedir restriction in effect: eAccelerator与open_basedir

今天在查阅apache的错误日志时发现有很多的warning,都跟open_basedir有关,如:

2011/09/25 21:27:54 [error] 3927#0: *146 FastCGI sent in stderr: “PHP Warning: require(): open_basedir restriction in effect. File() is not within the allowed path(s): (/srv/http/:/home/:/tmp/:/usr/share/pear/) in /srv/http/xxx.php on line 913” while reading upstream, client: x.x.x.x, server: example.com, request: “GET / HTTP/1.1”, upstream: “fastcgi://unix:/var/run/php-fpm/php-fpm-kelltan.sock:”, host: “example.com”, referrer: “http://example.com/”

检查php.ini的配置也没发现什么问题,google一番也没有有用的信息,只好自己动手找原因。重新查看了日志,发现这个警告出现在我安装eAccelerator之后,所以觉得这个错误应该跟eAccelerator有关。

在阅读了eAccelerator的wiki,然后又做了一番研究后发现,默认的eAccelerator编译选项跟open_basedir是不相容的,根据wiki上介绍,只要在编译的时候加上参数“ –without-eaccelerator-use-inode”,便可解决这个问题:

$ cd /PATH/TO/eaccelerator-0.9.6.1
$ make clean
$ ./configure --without-eaccelerator-use-inode
$ make
# make install

好了,重新编译完后,记得删掉eAccelerator之前产生的文件,然后重新启动apache:

# rm -rf /var/cache/eaccelerator/*
# /etc/rc.d/httpd restart

好了,一切重归宁静。