PHP configuration
View the location of the PHP configuration file
# /usr/local/php/bin/php -i |grep -i "loaded configuration file"
Ban some functions with security risks
disable_functions=
phpinfo,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
Restart the httpd service to make it effective
Configure error_log
Set php error log
# vi /usr/local/php/etc/php.ini
Modify the following
log_errors If you want PHP to record error logs, you need to set it to on
error_log set error log path
error_reporting sets the level of error log, E_ALL means all types of logs, & means and, ~ means exclude, which means to exclude notice-related logs on the basis of E_ALL
# mkdir /var/log/php Need to ensure that the directory where the PHP error log exists exists
# chmod 777 /var/log/php
# /usr/local/apache2.4/bin/apachectl graceful
test
Write error content in it
access
# curl -A"123" -I -x127.0.0.1:80 www.0209.com/test.php
A status code of 500 appears, indicating that the accessed page is incorrect
Check the PHP error log to determine the cause of the error
# cat /var/log/php/php_error.log
Configure open_basedir
Configuration file
# vi /usr/local/php/etc/php.ini
Search open_basedir
Reload configuration
# /usr/local/apache2.4/bin/apachectl graceful
test
# cp /usr/local/apache2.4/htdocs/1.php /data/wwwroot/gmd.com/
# curl -x127.0.0.1:80 -I gmd.com/1.php
Can not access
Set open_basedir for a single virtual machine
# vi /usr/local/apache2.4/conf/extra/httpd-vhosts.conf
<VirtualHost *:80>
DocumentRoot "/data/wwwroot/www.0209.com"
ServerName www.0209.com
ServerAlias 0209.com
CustomLog "|/usr/local/apache2.4/bin/rotatelogs -l logs/0209.com-access_%Y%m%d.log 86400"
php_admin_value open_basedir "/data/wwwroot/www.0209.com/:/tmp/"
</VirtualHost>
Reload configuration
# /usr/local/apache2.4/bin/apachectl -t
# /usr/local/apache2.4/bin/apachectl graceful
PHP dynamic extension module installation
Check which modules are loaded
# /usr/local/php/bin/php -m
Install redis extension module
# cd /usr/local/src/
# wget http://pecl.php.net/get/redis-2.2.5.tgz
# tar -zxvf redis-2.2.5.tgz
# cd redis-2.2.5
# yum install -y autoconf
# /usr/local/php/bin/phpize Generate configure file
# ./configure --with-php-config=/usr/local/php/bin/php-config
# make
# make install
# /usr/local/php/bin/php -i |grep extension_dir
# ls /usr/local/php/lib/php/extensions/no-debug-zts-20131226/
# vi /usr/local/php/etc/php.ini
Finally add
extension=redis.so
Check whether the module is loaded
# /usr/local/php/bin/php -m |grep redis
# cd /usr/local/apache2.4/htdocs/
Browser load module
# cd /usr/local/apache2.4/htdocs/
# vi index.php
<?php
phpinfo();
?>
Reload
# /usr/local/apache2.4/bin/apachectl -t
# /usr/local/apache2.4/bin/apachectl graceful
Browser search 192.168.89.128/index.php