PHP相关配置

查看php配置文件位置

/usr/local/php/bin/php -i|grep -i "loaded configuration file"

Loaded Configuration File => /usr/local/php/etc/php.ini

没有php.ini 那么就需要复制模板过来

cd /usr/local/src/php-5.6.30/
cp php.ini-development /usr/local/php/etc/php.ini

编辑php配置文件

vim /usr/local/php/etc/php.ini

禁止危险函数

vim /usr/local/php/etc/php.ini

搜索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

预览

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

生效配置

/usr/local/apache2.4/bin/apachectl -t
/usr/local/apache2.4/bin/apachectl graceful

效果:

禁用函数后,这些函数就无法被调用,例如phpinfo作用是显示php的配置,而禁用后使用网页无法显示出来;

定义时区

搜索date.timezone 修改date.timezone =为 date.timezone = Asia/Shanghai

关闭错误信息显示

搜索display_errors 将display_errors = On改为 display_errors = Off

定义错误日志

搜索error_log = 修改error_log = 目录为 error_log = /tmp/php_errors.log

定义错误日志级别

搜索error_reporting = 在error_reporting = E_ALL 修改为 error_reporting = E_ALL & ~E_NOTICE

open_basedir参数设定

open_basedir的作用是限制php在指定的目录里活动 vim /usr/local/php/etc/php.ini ** 搜索error_log =修改为指定目录** open_basedir = /data/wwwroot/111.com:/tmp

推荐在虚拟配置中设置 vim /usr/local/apache2.4/conf/extra/httpd-vhosts.conf 针对网站站点增加代码 php_admin_value open_basedir "/data/wwwroot/111.com:/tmp/"