php_admin_value[open_basedir]=/data/wwwroot/aming.com:/tmp/
php_admin_value[open_basedir]=/data/wwwroot/test.com:/tmp/ - 如果路径出错,就会无法正常访问,导致404页面 curl直接连会提示“No input file specified.”
[root@hf-01 php-fpm.d]# vim /usr/local/php-fpm/etc/php-fpm.d/www.conf
[www]
listen = /tmp/php-fcgi.sock
listen.mode = 666
user = php-fpm
group = php-fpm
pm = dynamic
pm.max_children = 50
pm.start_servers = 20
pm.min_spare_servers = 5
pm.max_spare_servers = 35
pm.max_requests = 500
rlimit_files = 1024
request_slowlog_timeout = 1
slowlog = /usr/local/php-fpm/var/log/www-slow.log
php_admin_value[open_basedir]=/data/wwwroot/test.com:/tmp/
[root@hf-01 php-fpm.d]# /etc/init.d/php-fpm restart
Gracefully shutting down php-fpm . done
Starting php-fpm done
[root@hf-01 php-fpm.d]#
[root@hf-01 php-fpm.d]# curl -x127.0.0.1:80 test.com/sleep.php -I
HTTP/1.1 200 OK
Server: nginx/1.12.1
Date: Tue, 09 Jan 2018 22:56:24 GMT
Content-Type: text/html; charset=UTF-8
Connection: keep-alive
X-Powered-By: PHP/5.6.30
[root@hf-01 php-fpm.d]#
[root@hf-01 php-fpm.d]# vi /usr/local/php-fpm/etc/php.ini
搜索 /display_errors
将display_errors = Off
搜索 /error_log,添加error_log
;error_log = php_errors.log
; Log errors to syslog (Event Log on Windows).
;error_log = syslog
error_log = /usr/local/php-fpm/var/log/php_errors.log //这一段定义错误日志
搜索error_reporting
注释掉自带的error_reporting
;error_reporting = E_ALL & ~E_DEPRECATED & ~E_STRICT
error_reporting = E_ALL //定义错误日志的级别,所有
保存退出
[root@hf-01 php-fpm.d]# grep error_log /usr/local/php-fpm/etc/php.ini
; server-specific log, STDERR, or a location specified by the error_log
; Set maximum length of log_errors. In error_log information about the source is
;error_log = php_errors.log
;error_log = syslog
error_log = /usr/local/php-fpm/var/log/php_errors.log
; OPcache error_log file name. Empty string assumes "stderr".
;opcache.error_log=
[root@hf-01 php-fpm.d]# [root@hf-01 php-fpm.d]# ls /usr/local/php-fpm/var/log/
php-fpm.log www-slow.log
[root@hf-01 php-fpm.d]#
[root@hf-01 php-fpm.d]# touch /usr/local/php-fpm/var/log/php_errors.log
[root@hf-01 php-fpm.d]# chmod 777 /usr/local/php-fpm/var/log/php_errors.log
[root@hf-01 php-fpm.d]#
[root@hf-01 php-fpm.d]# /etc/init.d/php-fpm restart
Gracefully shutting down php-fpm . done
Starting php-fpm done
[root@hf-01 php-fpm.d]#
[root@hf-01 php-fpm.d]# curl -x127.0.0.1:80 test.com/sleep.php -I
HTTP/1.1 404 Not Found
Server: nginx/1.12.1
Date: Tue, 09 Jan 2018 23:35:31 GMT
Content-Type: text/html; charset=UTF-8
Connection: keep-alive
X-Powered-By: PHP/5.6.30
[root@hf-01 php-fpm.d]#
[root@hf-01 php-fpm.d]# cat /usr/local/php-fpm/var/log/php_errors.log
[09-Jan-2018 23:35:31 UTC] PHP Warning: Unknown: open_basedir restriction in effect. File(/data/wwwroot/test.com/sleep.php) is not within the allowed path(s): (/data/wwwroot/111test.com:/tmp/) in Unknown on line 0
[09-Jan-2018 23:35:31 UTC] PHP Warning: Unknown: failed to open stream: Operation not permitted in Unknown on line 0
[root@hf-01 php-fpm.d]#
[root@hf-01 php-fpm.d]# vim /usr/local/php-fpm/etc/php-fpm.d/www.conf
[root@hf-01 php-fpm.d]# /etc/init.d/php-fpm restart
Gracefully shutting down php-fpm . done
Starting php-fpm done
[root@hf-01 php-fpm.d]# curl -x127.0.0.1:80 test.com/sleep.php -I
HTTP/1.1 200 OK
Server: nginx/1.12.1
Date: Tue, 09 Jan 2018 23:39:30 GMT
Content-Type: text/html; charset=UTF-8
Connection: keep-alive
X-Powered-By: PHP/5.6.30
[root@hf-01 php-fpm.d]#