[root@hf-01 111.com]# ls 11.png 123.php admin index.php inedx.php upload [root@hf-01 111.com]# vi index.php [root@hf-01 111.com]# cd /usr/local/src/php-5.6.30/ [root@hf-01 php-5.6.30]# cp php.ini-development /usr/local/php/etc/php.ini [root@hf-01 php-5.6.30]# /usr/local/apache2.4/bin/apachectl graceful [root@hf-01 php-5.6.30]# 這時用瀏覽器訪問看到配置文件的路徑
[root@hf-01 php-5.6.30]# vim /usr/local/php/etc/php.ini 搜索 /disable 在disable_functions =後禁掉一些危險的函數 disable_functions =eval,assert,popen,passthru,escapeshellarg,escapeshellcmd,passthru,exec,system,chroot,scandir,chgrp,chown,escapeshellcmd,escapeshellarg,shell_exec,proc_get_status,ini_alter,ini_restore,dl,pfsockopen,openlog,syslog,readlink,symlink,leak,popepassthru,stream_socket_server,popen,proc_open,proc_close,phpinfo 而後保存
[root@hf-01 php-5.6.30]# /usr/local/apache2.4/bin/apachectl graceful [root@hf-01 php-5.6.30]#
[root@hf-01 php-5.6.30]# vim /usr/local/php/etc/php.ini 搜索/timezone 在date.timezone定義時區 須要刪除 ; 分號 date.timezone = Asia/shanghai 搜索/display 須要刪除 ; 分號 將display_errors = On更改成display_errors = Off 而後保存退出
[root@hf-01 php-5.6.30]# /usr/local/apache2.4/bin/apachectl -t Syntax OK [root@hf-01 php-5.6.30]# /usr/local/apache2.4/bin/apachectl graceful [root@hf-01 php-5.6.30]#
搜索/log_errors,將錯誤日誌文件打開 log_errors = On 搜索/error_log,將錯誤日誌文件定義到tmp目錄下 須要刪除 ; 分號 error_log = /tmp/php_errors.log 而後保存退出
[root@hf-01 php-5.6.30]# curl -A "a" -x127.0.0.1:80 http://111.com/index.php [root@hf-01 php-5.6.30]# ls /tmp/ mysql.sock php_errors.log
10 查看php_errors.log文件,會看到屬主屬組是daemonphp
[root@hf-01 php-5.6.30]# ls -l /tmp/php_errors.log -rw-r--r-- 1 daemon daemon 135 12月 27 07:30 /tmp/php_errors.log [root@hf-01 php-5.6.30]#
[root@hf-01 php-5.6.30]# ps aux |grep httpd root 2539 0.0 1.2 258304 12708 ? Ss 04:26 0:01 /usr/local/apache2.4/bin/httpd -k graceful daemon 3685 0.0 0.9 545132 9580 ? Sl 07:30 0:00 /usr/local/apache2.4/bin/httpd -k graceful daemon 3686 0.0 0.9 545132 9580 ? Sl 07:30 0:00 /usr/local/apache2.4/bin/httpd -k graceful daemon 3687 0.0 1.2 610668 12388 ? Sl 07:30 0:00 /usr/local/apache2.4/bin/httpd -k graceful root 3776 0.0 0.0 112676 984 pts/0 R+ 07:33 0:00 grep --color=auto httpd [root@hf-01 php-5.6.30]#
[root@hf-01 php-5.6.30]# grep error_log /usr/local/php/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 = /tmp/php_errors.log ;error_log = syslog ; OPcache error_log file name. Empty string assumes "stderr". ;opcache.error_log= [root@hf-01 php-5.6.30]#
- 能夠先建立好/tmp/php_errors.log文件,而後賦予chmod 777權限
[root@hf-01 php-5.6.30]# cat /tmp/php_errors.log //會告訴你由於安全的緣由,這個函數已經被禁掉了 [26-Dec-2017 23:30:19 UTC] PHP Warning: phpinfo() has been disabled for security reasons in /data/wwwroot/111.com/index.php on line 2 [root@hf-01 php-5.6.30]#
[root@hf-01 php-5.6.30]# vim /usr/local/php/etc/php.ini 搜索/open_basedir,並上刪除 ; 號 open_basedir = /data/wwwroot/111.com:/tmp 而後保存退出
[root@hf-01 php-5.6.30]# curl -A "a" -x127.0.0.1:80 http://111.com/index.php -I HTTP/1.1 200 OK Date: Wed, 27 Dec 2017 00:04:36 GMT Server: Apache/2.4.29 (Unix) PHP/5.6.30 X-Powered-By: PHP/5.6.30 Content-Type: text/html; charset=UTF-8 [root@hf-01 php-5.6.30]#
[root@hf-01 php-7.1.6]# vim /usr/local/apache2.4/conf/extra/httpd-vhosts.conf php_admin_value open_basedir "/data/wwwroot/111.com:/tmp/" 而後保存退出
[root@hf-01 php-7.1.6]# /usr/local/apache2.4/bin/apachectl -t Syntax OK [root@hf-01 php-7.1.6]# /usr/local/apache2.4/bin/apachectl graceful [root@hf-01 php-7.1.6]#
[root@hf-01 php-7.1.6]# curl -A "a" -x127.0.0.1:80 http://111.com/index.php 111.com[root@hf-01 php-7.1.6]#