centos8升级php70到php7.4

一,下载php7.4
1,官方网站:

https://www.php.net/
2,下载
wget https://www.php.net/distributions/php-7.4.2.tar.gz

二,查看本地的centos的版本
[root@localhost lib]# cat /etc/redhat-release
CentOS Linux release 8.1.1911 (Core)
说明:在linux上以编译方式安装软件时,多数人都习惯把软件安装到 /usr/local目录下

三,解压和配置
tar -zxvf php-7.4.2.tar.gz
cd php-7.4.2/
./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’
说明:上面的configure命令的参数是php-7.4.2可用的参数,
一些旧的不可用的参数会在configure时给出提示,
大家不要使用已经废弃的参数,避免安装完成后不能正常使用
安装依赖:
yum install libsqlite3x-devel -y
yum install libzip-devel
wget https://github.com/kkos/oniguruma/archive/v6.9.4.tar.gz -O oniguruma-6.9.4.tar.gz
tar -zxf oniguruma-6.9.4.tar.gz
cd oniguruma-6.9.4
yum install automake -y
yum install libtool -y
./autogen.sh && ./configure --prefix=/usr
make && make install

cd php-7.4.2/
make -j8 && make install

四,配置过程中遇到各种报错信息的处理
1,报错:Package ‘libxml-2.0’, required by ‘virtual:world’, not found
解决:
yum install libxml2-devel
2,报错:Package ‘krb5’, required by ‘virtual:world’, not found
解决:
yum install krb5-devel
3,报错:Package ‘openssl’, required by ‘virtual:world’, not found
解决:
yum install openssl-devel
4,报错:Package ‘sqlite3’, required by ‘virtual:world’, not found
解决:
yum install sqlite-devel
5,报错:Package ‘libcurl’, required by ‘virtual:world’, not found
解决:
yum install libcurl-devel
6,报错:Package ‘oniguruma’, required by ‘virtual:world’, not found
解决:
参见:CentOS 8 安装 oniguruma 和 oniguruma-devel 一文
地址:https://www.cnblogs.com/architectforest/p/12433640.html
7,报错:Package ‘libxslt’, required by ‘virtual:world’, not found
解决:
yum install libxslt-devel
8,报错:Package ‘libjpeg’, required by ‘virtual:world’, not found
解决:
yum install libjpeg-devel
9,报错:Package ‘libzip’, required by ‘virtual:world’, not found
解决:
yum install libzip-devel
10,报错:configure: error: Please reinstall the BZip2 distribution
解决:
yum -y install bzip2-devel
11,报错:Package ‘libpng’, required by ‘virtual:world’, not found
解决:
yum install libpng-devel
12,报错:Package ‘freetype2’, required by ‘virtual:world’, not found
解决:
yum install freetype-devel
五,配置
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

猜你喜欢

转载自blog.csdn.net/songxi_bo/article/details/105879612