# /usr/local/php/bin/php -i |grep -i "loaded configuration file"
// 查看PHP配置文件所在位置的命令
// 如果出现PHP warning:的警告信息,就是需要php.ini,找到data.timezone设置
// 将data.timezone = 配置成 data.timezone = Asia/shanghai
# /usr/local/php/bin/php -i |grep -i "loaded configuration file"
Loaded Configuration File => /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 phpinfo
# /usr/local/apache2.4/bin/apachectl graceful //重新加载配置服务
# vim /usr/local/php/etc/php.ini
//搜索log_errors修改
log_errors = On
//搜索error_log修改
error_log = /var/log/php/php_errors.log
//搜索error_reporting修改
error_reporing = E_ALL & ~E_NOTICE
// 搜索display_errors修改
display_errors = Off
# mkdir /var/log/php //
# chmod 777 /var/log/php //需要保证PHP的错误日志所在目录存在,并且权限为可写
# /usr/local/apache2.4/bin/apachectl graceful // 重新加载配置服务
// 测试
# vim /data/wwwroot/ww.123.com/test.php //写入内容,故意把结尾去掉
<?php
echo 111
# curl -A "123" -I -x127.0.0.1:80 www.123.com/test.php
HTTP/1.0 500 Internal Server Error
Date: Sat, 22 May 2021 16:10:47 GMT
Server: Apache/2.4.33 (Unix) PHP/5.6.39
X-Powered-By: PHP/5.6.39
Connection: close
Content-Type: text/html; charset=UTF-8
// 出现了状态码500 ,说明我们访问的页面是存在错误的,需要查看php 的错误日志
# cat /var/log/php/php_errors.log //查看错误日志
[26-Nov-2021 11:10:47 Asia/Shanghai] PHP Parse error: syntax error, unexpected end of file, expecting ',' or ';' in /data/wwwroot/www.123.com/test.php on line 3
// 通过日志可以判断是test.php第三行少了分号
# vim /usr/local/php/etc/php.ini //搜索open_basedir 修改
open_basedir = /tmp:/data/wwwroot/www.123.com
# /usr/local/apache2.4/bin/apachectl graceful //重新加载配置服务
# cp /usr/local/apache2.4/htdocs/1.php /data/wwwroot/aming.com/
# curl -x127.0.0.1:80 -I aming.com/1.php
HTTP/1.0 500 Internal Server Error
Date: Sat, 22 May 2021 16:18:42 GMT
Server: Apache/2.4.33 (Unix) PHP/5.6.39
X-Powered-By: PHP/5.6.39
Connection: close
Content-Type: text/html; charset=UTF-8
// 发现aming.com/1.php不能访问,状态码为500,所以查看一下错误日志
# cat /var/log/php/php_errors.log //查看错误日志
[23-May-2021 00:10:47 Asia/Shanghai] PHP Parse error: syntax error, unexpected end of file, expecting ',' or ';' in /data/wwwroot/www.123.com/test.php on line 3
[23-May-2021 00:18:42 Asia/Shanghai] PHP Warning: Unknown: open_basedir restriction in effect. File(/data/wwwroot/aming.com/1.php) is not within the allowed path(s): (/tmp:/data/wwwroot/www.123.com) in Unknown on line 0
[23-May-2021 00:18:42 Asia/Shanghai] PHP Warning: Unknown: failed to open stream: Operation not permitted in Unknown on line 0
[23-May-2021 00:18:42 Asia/Shanghai] PHP Fatal error: Unknown: Failed opening required '/data/wwwroot/aming.com/1.php' (include_path='.:/usr/local/php/lib/php') in Unknown on line 0
# /usr/local/php/bin/php -m //查看PHP的加载功能模块
[PHP Modules]
bz2
Core
ctype
date
dom
ereg
exif
fileinfo
filter
hash
iconv
json
libxml
mysql
pcre
PDO
pdo_sqlite
Phar
posix
Reflection
session
SimpleXML
SPL
sqlite3
standard
tokenizer
xml
xmlreader
xmlwriter
[Zend Modules]
# cd /usr/local/src/ //进入安装包目录
//下载安装包
# tar zxf redis-2.2.3.tgz //解压安装包
# ls //查看安装包
# cd redis-2.2.3 //进入解压完的文件
# ls
arrays.markdown config.m4 COPYING library.c php_redis.h r
common.h config.w32 CREDITS library.h README.markdown r
# /usr/local/php/bin/phpize //生成configure文件
Configuring for:
PHP Api Version: 20131106
Zend Module Api No: 20131226
Zend Extension Api No: 220131226
\\ 如果报错,yum install -y autoconf
然后用# /usr/local/php/bin/phpize再次执行
# ./configure --with-php-config=/usr/local/php/bin/php-config //配置php路径
# make && make install //编译和安装
# /usr/local/php/bin/php -i |grep extension_dir //查看扩展模块存放目录
sqlite3.extension_dir => no value => no value //在php.ini中自定义该路径
# ls /usr/local/php/lib/php/extensions/no-debug-zts-20131226
opcache.so redis.so
# vim /usr/local/php/etc/php.ini //增加一行配置 (可以放到文件最后一行)
extension = redis.so
# /usr/local/php/bin/php -m |grep redis //查看是否加载了redis模块
redis
# /usr/local/apache2.4/bin/apachectl graceful //重新加载配置httpd服务