在centos 7中按照我的随笔转载文章”[转载]CentOS 下安装LEMP服务(Nginx、MariaDB/MySQL和PHP)“安装好后,结果无法显示phpinfo()信息,出现过“file not found”,”No iput file is specifed”,”access denied”等各种奇怪错误,百度了各种文章都说是/etc/nginx/conf.d/default.conf配置里的路径root配置不正确造成的,但检查了几千遍也没发现有问题。经过查看/var/logs/nginx/error.log日志发现了问题所在:

2015/03/23 20:54:57 [error] 3246#0: *4 FastCGI sent in stderr: “PHP message: PHP Warning: Unknown: open_basedir restriction in effect. File(/usr/share/nginx/html/test.php) is not within the allowed path(s): (.:/tmp/) in Unknown on line 0
PHP message: PHP Warning: Unknown: failed to open stream: Operation not permitted in Unknown on line 0
Unable to open primary script: /usr/share/nginx/html/test.php (Permission denied)” while reading response header from upstream, client: 192.168.1.101, server: localhost, request: “GET /test.php HTTP/1.1”, upstream: “fastcgi://127.0.0.1:9000”, host: “192.168.1.107”
2015/03/23 20:54:57 [error] 3246#0: *4 FastCGI sent in stderr: “PHP message: PHP Warning: Unknown: open_basedir restriction in effect. File(/usr/share/nginx/html/test.php) is not within the allowed path(s): (.:/tmp/) in Unknown on line 0

很显然问题在php.ini的open_basedir限制了能够读取的文件夹,只设置了open_basedir=.:/tmp/,而/usr/share/nginx/html/没有在其中,将目录加入一切正常。

版权声明:本文为zzyyxxjc原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://www.cnblogs.com/zzyyxxjc/p/4359812.html