查看php配置文件位置
# vim /data/wwwroot/php/index.php
在浏览器中访问
# cd /usr/local/src/php-5.6.30/ # cp php.ini-development /usr/local/php/etc/php.ini # /usr/local/apache2.4/bin/apachectl -t # /usr/local/apache2.4/bin/apachectl graceful
# /usr/local/php/bin/php -i|grep -i "loaded configuration file"
# vim /usr/local/php/etc/php.ini disable_functions = eval,assert,popen,passthru,escapeshellarg,escapeshellcmd,exec,system,chroot,scandir,chgrp,chown,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 graceful
# vim /usr/local/php/etc/php.ini date.timezone = Asia/Shanghai 或 Asia/Chongqing
不需要把错误信息显示到浏览器里
display_errors = Off
以上这个命令会显示空白页
log_errors = On //开启错误日志 error_log = /tmp/php_errors.log //定义错误日志的路径 error_reporting = E_ALL //错误报告级别(最不严谨的)
模拟一个错误(php文件里的代码写错,状态码为500)
# vim /data/wwwroot/php/aa.php
开启open_basedir,写了一个不存在的路径(状态码为500)
open_basedir = /data/wwwroot/php1:/tmp
/usr/local/php/etc/php.ini这个文件相关的词
timezone
disable_functions
error_log,log_errors,display_errors,error_reporting
open_basedir
php_admin-value open_basedir "/data/wwwroot/www.php.com:/tmp" //这个在httpd的虚拟主机中配置
php动态扩展模块的安装
安装php时,我所有的模块全部为静态的,并没有任何动态的模块。所谓动态,就是一个独立存在的.so文件,在httpd中php就是以动态模块的形式被加载的。php一旦编译完成后,要想再增加一个功能模块的话,要么重新编译php,要么直接编译一个扩展模块(生成一个.so文件),然后在php.ini中配置就可以被加载使用了。
查看php加载了哪些模块
# /usr/local/php/bin/php -m
安装一个redis的模块
# cd /usr/local/src/ # wget https://codeload.github.com/phpredis/phpredis/zip/develop # mv develop phpredis-develop.zip # unzip phpredis-develop.zip # cd phpredis-develop/ # /usr/local/php/bin/phpize Cannot find autoconf. Please check your autoconf installation and the $PHP_AUTOCONF environment variable. Then, rerun this script. # yum install autoconf -y # /usr/local/php/bin/phpize //生成一个configure文件 # ./configure --with-php-config=/usr/local/php/bin/php-config # make && make install Installing shared extensions: /usr/local/php/lib/php/extensions/no-debug-zts-20131226/
# vim /usr/local/php/etc/php.ini //加入"extension=redis.so"
php源码包自带的扩展模块位置(/usr/local/src/php-5.6.30/ext)
# cd /usr/local/src/php-5.6.30/ext/zip # /usr/local/php/bin/phpize # ./configure --with-php-config=/usr/local/php/bin/php-config # make && make install # vim /usr/local/php/etc/php.ini //加入"extension=zip.so"