=
错误解决方案:php-error-with-zabbix-File(maintenance.inc.php) is not within the allowed path(s)
=
[error] 8150#0: *13 FastCGI sent in stderr: "PHP message: PHP Warning: require_once(): open_basedir restriction in effect. File(/etc/zabbix/web/maintenance.inc.php) is not within the allowed path(s): (/home/wwwroot/default/:/tmp/:/proc/) in /home/wwwroot/default/zabbix/include/classes/core/ZBase.php on line 271
PHP message: PHP Warning: require_once(/etc/zabbix/web/maintenance.inc.php): failed to open stream: Operation not permitted in /home/wwwroot/default/zabbix/include/classes/core/ZBase.php on line 271
PHP message: PHP Fatal error: require_once(): Failed opening required '/etc/zabbix/web/maintenance.inc.php' (include_path='.:/usr/local/php/lib/php') in /home/wwwroot/default/zabbix/include/classes/core/ZBase.php on line 271" while reading response header from upstream, client: 10.2.3.12, server: _, request: "GET /zabbix/ HTTP/1.1", upstream: "fastcgi://unix:/tmp/php-cgi.sock:", host: "192.168.0.12"
2018/04/08 18:41:59 [info] 8150#0: *14 client closed connection while waiting for request, client: 10.2.3.12, server: 0.0.0.0:80
原因排查:
根据nginx的启动线程的权限是www:www,所以我已经修改了zabbix的目录以及/etc/zabbix/web 的目录权限,都是www,这样已经没有了权限问题。
已经重启过了fpm和nginx。
原因分析:根据两点:
1. File(/etc/zabbix/web/maintenance.inc.php) is not within the allowed path(s): (/home/wwwroot/default/:/tmp/:/proc/)
2. PHP Fatal error: require_once(): Failed opening required '/etc/zabbix/web/maintenance.inc.php' (include_path='.:/usr/local/php/lib/php')
推测:应该是某个路径的权限不对。没有权限的原因是 is not within the allowed path(s)
应该去设置某个参数,把这个路径包涵进去。这个参数名应该叫:include_path
解决方法:
寻找php的配置文件php.ini,找到参数include_path 发现没有设置。
那另一个配置在哪里呢?应该在httpd的配置里面或者nginx的配置里面。
由于我本次用了nginx而不是httpd,所以找到nginx里面的配置文件:
vi /usr/local/nginx/conf/fastcgi.conf
fastcgi_param PHP_ADMIN_VALUE "open_basedir=$document_root/:/tmp/:/proc/
加入本次的报错的路径:
fastcgi_param PHP_ADMIN_VALUE "open_basedir=$document_root/:/tmp/:/proc/:/etc/zabbix/web";
重新启动nginx和fastcgi,一切OK了。
/usr/local/nginx/sbin/nginx -s reload
/etc/init.d/php-fpm restart
如果是httpd的,可能可以参考:
https://blog.csdn.net/lzp2011150309/article/details/50725737 php错误提示 open_basedir restriction in effect 解决
=
=
=