您的位置:首页 > 运维架构 > Nginx

[原创]配置php+nginx 时遇到的”file not found","access denied"奇怪问题的解决过程

2015-03-23 14:54 1196 查看
在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/没有在其中,将目录加入一切正常。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐