- 在线文档(安装说明)
- 安装依赖
yum -y install autoconf build-essential curl libtool \
libssl-dev libcurl4-openssl-dev libxml2-dev libreadline7 \
libreadline-dev libzip-dev libzip4 nginx openssl \
yum -y install libxml2-devel sqlite-devel libcurl-devel oniguruma-devel postgresql-devel readline-devel
wget https://yum.oracle.com/repo/OracleLinux/OL7/latest/x86_64/getPackage/oniguruma-5.9.5-3.el7.x86_64.rpm
wget https://yum.oracle.com/repo/OracleLinux/OL7/latest/x86_64/getPackage/oniguruma-devel-5.9.5-3.el7.x86_64.rpm
yum -y localinstall oniguruma-5.9.5-3.el7.x86_64.rpm
yum -y localinstall oniguruma-devel-5.9.5-3.el7.x86_64.rpm
rm -rf oniguruma-5.9.5-3.el7.x86_64.rpm oniguruma-devel-5.9.5-3.el7.x86_64.rpm
- 安装目录
mkdir /opt/php && cd /opt/php
- 安装包下载
wget https://www.php.net/distributions/php-8.1.12.tar.gz
注意:https://www.php.net/downloads获取最新版本下载链接并替换
- 安装包解压
tar -zxvf php-8.1.12.tar.gz && rm -rf php-8.1.12.tar.gz
- 安装配置
- 编译安装
make && make install
- 配置文件
cp /opt/php/php-8.1.12/php.ini-development /opt/php/php-8.1.12/lib/
mv /opt/php/php-8.1.12/etc/php-fpm.conf.default /opt/php/php-8.1.12/etc/php-fpm.conf
mv /opt/php/php-8.1.12/etc/php-fpm.d/www.conf.default /opt/php/php-8.1.12/etc/php-fpm.d/www.conf
- 环境变量
echo "export PHP_HOME=/opt/php/php-8.1.12" >> /etc/profile
echo "export PATH=\$PHP_HOME/bin:\$PHP_HOME/sbin:\$PATH" >> /etc/profile
- 卸载旧版本
rpm -e --nodeps `rpm -qa | grep -i php`
- 查看新版本
php -v
- 常用命令