【环境】
使用 remi 源在CentOS 8 快速安装 PHP 5.6 。
参考:https://stackoverflow.com/questions/32874708/php56-centos-remi-repo
参考:https://serverfault.com/questions/706349/install-php7-from-remi-repo
参考:http://blog.remirepo.net/pages/English-FAQ
安装 remi :
wget http://rpms.famillecollet.com/enterprise/remi-release-8.rpm && rpm -Uvh remi-release-8.rpm
安装 PHP 5.6 :
dnf install --enablerepo=remi php56 php56-php-fpm dnf install --enablerepo=remi php56-php-cli php56-php-json php56-php-xml php56-php-bcmath php56-php-gd php56-php-imap php56-php-xmlrpc php56-php-opcache php56-php-mbstring php56-php-intl php56-php-soap php56-php-mcrypt php56-php-pdo php56-php-mysqlnd php56-php-zip
关键文件路径:
查看PHP安装路径:
find / -name php
输出:
/opt/remi/php56/root/usr/lib64/php /opt/remi/php56/root/usr/bin/php /opt/remi/php56/root/usr/share/php /opt/remi/php56/root/var/lib/php
查看PHP-fpm安装路径:
find / -name php-fpm
输出:
/opt/remi/php56/root/usr/sbin/php-fpm /opt/remi/php56/root/etc/sysconfig/php-fpm /opt/remi/php56/root/var/run/php-fpm /opt/remi/php56/root/var/log/php-fpm
其他路径:
/etc/opt/remi/php56/php.ini /etc/opt/remi/php56/php-fpm.conf /etc/opt/remi/php56/php-fpm.d/www.conf /var/opt/remi/php56/run/php-fpm/www.sock /var/opt/remi/php56/run/php-fpm/php-fpm.pid /var/opt/remi/php56/lib/php/session
建立PHP程序的软连接:
sudo ln -s /opt/remi/php56/root/usr/bin/php /usr/bin/php
修改全局环境变量:/etc/profile
export PATH=/opt/remi/php56/root/usr/bin:$PATH
刷新环境变量:
source /etc/profile
www.conf设置:
编辑:/etc/opt/remi/php56/php-fpm.d/www.conf
修改用户和组为nginx:
user = nginx group = nginx
备注:
listen = /var/opt/remi/php56/run/php-fpm/www.sock
或
listen = 127.0.0.1:9000
php-fpm 服务设置:
编辑:/etc/rc.d/init.d/php-fpm
php_fpm_BIN=/opt/remi/php56/root/usr/sbin/php-fpm php_fpm_CONF=/etc/opt/remi/php56/php-fpm.conf php_fpm_PID=/var/opt/remi/php56/run/php-fpm/php-fpm.pid
dos2unix 转换/设置执行权限/注册成服务/设置开机启动:
dos2unix /etc/init.d/php-fpm && chmod a+x /etc/init.d/php-fpm && chkconfig --add php-fpm && chkconfig php-fpm on
【排错】
报错:Can’t find PHP headers in /opt/remi/php56/root/usr/include/php
执行:/opt/remi/php56/root/usr/bin/phpize 时报错。
需要安装 php56-php-devel :
dnf install --enablerepo=remi php56-php-devel
报错:Problem: cannot install the best candidate for the job – nothing provides libedit-devel(x86-64) needed by php56-php-devel-5.6.40-25.el8.remi.x86_64
参考:https://stackoverflow.com/questions/58400089/centos-libedit-devel-not-found
需要安装 libedit-devel :
dnf --enablerepo=powertools install libedit-devel
报错:502
编辑:/etc/opt/remi/php56/php-fpm.d/www.conf
listen.mode = 0666
修改权限:
chmod 0666 /var/opt/remi/php56/run/php-fpm/www.sock
报错:session
编辑:/etc/opt/remi/php56/php.ini
session.save_path = "/var/opt/remi/php56/lib/php/session"
修改权限:
chown -R nginx:nginx /var/opt/remi/php56/lib/php/session
修改 Nginx 下server参数:
参考 /etc/opt/remi/php56/php-fpm.d/www.conf
listen = /var/opt/remi/php56/run/php-fpm/www.sock
在 nginx.conf 中设置:
fastcgi_pass unix:/var/opt/remi/php56/run/php-fpm/www.sock;
报错:connect() to unix:/var/opt/remi/php56/run/php-fpm/www.sock failed
修改权限:
chown -R nginx:nginx /var/opt/remi/php56/run/php-fpm/
报错:open(/var/opt/remi/php56/lib/php/session/sess_4bb2fge1p71uur0u00hehjnm37, O_RDWR) failed: Permission denied (13
修改权限:
chown -R 777 /var/opt/remi/php56/lib/php/session/
报错:phpmyadmin /tmp/ 不可写
修改权限:
chown -R 777 tmp/
同时删除:
rm -rf tmp/twig/
报错:PHP Warning: Unknown: It is not safe to rely on the system’s timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected the timezone ‘UTC’ for now, but please set date.timezone to select your timezone. in Unknown on line 0
编辑:php.ini
date.timezone = UTC # 世界标准时间 date.timezone = PRC # 北京时间
【参考】
参考:https://amon.org/php74
参考:https://amon.org/php-mysql
参考:https://amon.org/php73
参考:https://amon.org/php72
参考:https://amon.org/php56
参考:https://amon.org/php5217
内核下载:https://rpms.remirepo.net/wizard/
扩展下载:https://rpms.remirepo.net/enterprise/8/
扩展下载:https://centos.pkgs.org/8/remi-x86_64/
参考:https://tecadmin.net/install-php7-on-centos7/
参考:https://blog.remirepo.net/post/2018/12/06/PHP-version-7.3.0-is-released
参考:https://www.itsupportwale.com/blog/how-to-install-php-7-3-on-centos-8/
参考:https://computingforgeeks.com/how-to-install-php-7-3-php-7-3-fpm-on-rhel-8/
参考:https://serverfault.com/questions/706349/install-php7-from-remi-repo