1. 更新yum源
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup mkdir /etc/yum.repos.d/bak mv /etc/yum.repos.d/CentOS-Linux-* /etc/yum.repos.d/bak
wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-vault-8.5.2111.repo
yum clean all && yum makecache
2. 安装依赖
(1) sqlite3
yum install sqlite-devel
或者下载安装包 编译安装
cd /opt
wget https://www.sqlite.org/2022/sqlite-autoconf-3380200.tar.gz
tar -zxvf sqlite-autoconf-3380200.tar.gz
cd sqlite-autoconf-3380200
./configure --prefix=/usr/local
make && make install
# 然后,把旧版本的去掉:
mv /usr/bin/sqlite3 /usr/bin/sqlite3_old
ln -s /usr/local/bin/sqlite3 /usr/bin/sqlite3
(2) oniguruma
wget https://github.com/kkos/oniguruma/archive/v6.9.4.tar.gz -O oniguruma-6.9.4.tar.gz
tar -xvf oniguruma-6.9.4.tar.gz
cd oniguruma-6.9.4/
./autogen.sh
./configure --prefix=/usr --libdir=/lib64 # 64位的系统一定要标识 --libdir=/lib64 否则还是不行
make && make install
(3) libzip 或者(libzip >= 0.11)
#卸载老版本的libzip
yum remove libzip
#下载安装libzip-1.2.0
wget https://libzip.org/download/libzip-1.2.0.tar.gz
tar -zxvf libzip-1.2.0.tar.gz
cd libzip-1.2.0
./configure
make && make install
安装完成后,查看是否存在/usr/local/lib/pkgconfig目录,如果存在,执行如下命令来设置PKG_CONFIG_PATH:
export PKG_CONFIG_PATH="/usr/local/lib/pkgconfig/"
3. 下载php7.4的源文件包
wget https://www.php.net/distributions/php-7.4.2.tar.gz
4. 解压进入目录开始安装
./configure '--prefix=/usr/local/php74' '--with-config-file-path=/usr/local/php74/etc' '--enable-mysqlnd' '--with-mysqli=mysqlnd' '--with-pdo-mysql=mysqlnd' '--with-mysql-sock=/tmp/mysql.sock' '--with-freetype' '--enable-gd' '--with-jpeg' '--with-zlib' '--with-expat' '--enable-xml' '--enable-bcmath' '--enable-shmop' '--enable-sysvsem' '--enable-inline-optimization' '--enable-mbregex' '--enable-mbstring' '--enable-ftp' '--with-openssl' '--enable-sockets' '--with-xmlrpc' '--with-zip' '--enable-soap' '--without-pear' '--with-gettext' '--enable-session' '--with-iconv' '--with-mhash' '--with-curl' '--enable-intl' '--enable-pcntl' '--enable-fpm' '--enable-opcache' '--enable-fileinfo'
make -j8 && make install
5. 配置
cp -av php.ini-production /usr/local/php74/etc/php.ini
cp /usr/local/php74/etc/php-fpm.conf.default /usr/local/php74/etc/php-fpm.conf
cp -av /usr/local/php74/etc/php-fpm.d/www.conf.default /usr/local/php74/etc/php-fpm.d/www.conf
cp -av sapi/fpm/init.d.php-fpm /etc/init.d/php74-fpm
chmod +x /etc/init.d/php74-fpm
# mv /etc/init.d/php-fpm /etc/init.d/php70-fpm # 如果有老板本的php修改