PHP主配置文件是/usr/local/php/etc/php.ini:
[root@centos6 ~]# /usr/local/php/bin/php -i |head
phpinfo()
PHP Version => 5.4.36
System => Linux centos6.5-1 2.6.32-431.el6.i686 #1 SMP Fri Nov 22 00:26:36 UTC 2013 i686
Build Date => Jan 14 2017 00:52:17
Configure Command => './configure' '--prefix=/usr/local/php' '--with-apxs2=/usr/local/apache2/bin/apxs' '--with-config-file-path=/usr/local/php/etc' '--with-mysql=/usr/local/mysql' '--with-libxml-dir' '--with-gd' '--with-jpeg-dir' '--with-png-dir' '--with-freetype-dir' '--with-iconv-dir' '--with-zlib-dir' '--with-bz2' '--with-openssl' '--with-mcrypt' '--enable-soap' '--enable-gd-native-ttf' '--enable-mbstring' '--enable-sockets' '--enable-exif' '--disable-ipv6'
Server API => Command Line Interface
Virtual Directory Support => disabled
Configuration File (php.ini) Path => /usr/local/php/etc
Loaded Configuration File => /usr/local/php/etc/php.ini
该配置文件以分号“;”作为注释符号,可以使用参数 disable_functions 禁用一些高风险的函数:
[root@centos6 ~]# vim /usr/local/php/etc/php.ini
……
; This directive allows you to disable certain functions for security reasons.
; It receives a comma-delimited list of function names. This directive is
; *NOT* affected by whether Safe Mode is turned On or Off.
; http://php.net/disable-functions
disable_functions = eval,assert,popen,passthrn,escapeshllarg,escapes
hellcmd,passthru,exec,system,chroot,scandir,chgrp,chown,escapeshellc
md,escapeshellarg,shell_exec,proc_get_status,ini_alter,ini_restore,d
l,pfsockopen,openlog,syslog,readlink,syslink,leak,popepassthru,strea
m_socket_server,popen,proc_open,proc_close
可以打开display_errors=On(默认是Off)在浏览器中显示错误信息
; On or stdout = Display errors to STDOUT
; Default Value: On
; Development Value: On
; Production Value: Off
; http://php.net/display-errors
display_errors = On
重新加载配置文件
[root@centos6 ~]# apachectl -t
Syntax OK
[root@centos6 ~]# apachectl graceful
打开我们论坛页面,人为加点错误
[root@centos6 ~]# vim /data/www/forum.php