php编译安装多版本共存php5.6-php7.2-php8.2

服务器到期、更新服务器、环境重新安装、记录多版本php服务安装、也可以使用docker、但是还是喜欢编译安装、行动起来吧!

首先下载吧

1:下载php7.2

wget -c  https://www.php.net/distributions/php-7.2.20.tar.gz

2:下载php5.6

wget  -c https://www.php.net/distributions/php-5.6.30.tar.gz

3:下载php8.2

wget -c https://www.php.net/distributions/php-8.2.22.tar.gz


至于为什么不下载最新版、念旧。


先安装7.2 不按顺序来是我一贯作风

tar -zxvf php-7.2.20.tar.gz

#安装lib库+bzip2库+各种库 不安装报错哦 

yum -y install gcc zlib zlib-devel pcre-devel openssl openssl-devel

 yum -y install gcc gcc-c++ libmcrypt-devel mcrypt mhash gd-devel ncurses-devel libxml2-devel bzip2-devel libcurl-devel curl-devel libjpeg-devel libpng-devel freetype-devel net-snmp-devel openssl-deve python-devel zlib-devel freetype libxslt* bison autoconf re2c


#执行编译安装吧

#./configure --prefix=/usr/local/php7.2 --exec-prefix=/usr/local/php7.2 --bindir=/usr/local/php7.2/bin --sbindir=/usr/local/php7.2/sbin --includedir=/usr/local/php7.2/include --libdir=/usr/local/php7.2/lib/php --mandir=/usr/local/php7.2/php/man --with-config-file-path=/usr/local/php7.2/etc --with-mysql-sock=/var/run/mysql/mysql.sock --with-mhash --with-openssl --with-mysqli=shared,mysqlnd --with-pdo-mysql=shared,mysqlnd --with-gd --with-iconv --with-zlib --enable-zip --enable-inline-optimization --disable-debug --disable-rpath --enable-shared --enable-xml --enable-bcmath --enable-shmop --enable-sysvsem --enable-mbregex --enable-mbstring --enable-ftp --enable-pcntl --enable-calendar --enable-exif --enable-sockets --with-xmlrpc --with-libxml-dir --enable-soap --without-pear --with-gettext --enable-session --with-curl --with-jpeg-dir --with-png-dir --with-freetype-dir --with-bz2 --enable-opcache --enable-fpm --with-fpm-user=nginx --with-fpm-group=nginx --without-gdbm --enable-fast-install --disable-fileinfo -gdbm --enable-fast-install --disable-fileinfo

#make 

#make install


#拷贝配置文件 

 cp -a php.ini-production /usr/local/php7.2/etc/php.ini 

 cp /usr/local/php7.2/etc/php-fpm.conf.default /usr/local/php7.2/etc/php-fpm.conf 

cp /usr/local/php7.2/etc/php-fpm.d/www.conf.default /usr/local/php7.2/etc/php-fpm.d/www.conf 

#修改配置文件

vi /usr/local/php7.2/etc/php.ini

 date.timezone = Asia/shanghai #指定时区为上海

 expose_php = Off #禁止显示PHP版本

 short_open_tag = ON #支持PHP短标签

 #修改端口 在

www.conf中 改为9007 

 #启动服务 

 /usr/local/php7.2/sbin/php-fpm


biu 比较顺利 这样7就安装好了  端口号9007


接下来安装5.6

#解压 tar -zxvf php-5.6.30.tar.gz 

#编译安装 

./configure --prefix=/usr/local/php5.6 --exec-prefix=/usr/local/php5.6 --bindir=/usr/local/php5.6/bin --sbindir=/usr/local/php5.6/sbin --includedir=/usr/local/php5.6/include --libdir=/usr/local/php5.6/lib/php --mandir=/usr/local/php5.6/php/man --with-config-file-path=/usr/local/php5.6/etc --with-mysql-sock=/var/run/mysql/mysql.sock --with-mhash --with-openssl --with-mysqli=shared,mysqlnd --with-pdo-mysql=shared,mysqlnd --with-gd --with-iconv --with-zlib --enable-zip --enable-inline-optimization --disable-debug --disable-rpath --enable-shared --enable-xml --enable-bcmath --enable-shmop --enable-sysvsem --enable-mbregex --enable-mbstring --enable-ftp --enable-pcntl --enable-calendar --enable-exif --enable-sockets --with-xmlrpc --with-libxml-dir --enable-soap --without-pear --with-gettext --enable-session --with-curl --with-jpeg-dir --with-png-dir --with-freetype-dir --with-bz2 --enable-opcache --enable-fpm --with-fpm-user=nginx --with-fpm-group=nginx --without-gdbm --enable-fast-install --disable-fileinfo


make make install


#配置处理 (5.6没www 直接在fpm配置里修改端口9005)

cp php.ini-production /usr/local/php5.6/etc/php.ini 

cp /usr/local/php5.6/etc/php-fpm.conf.default /usr/local/php5.6/etc/php-fpm.conf


接下来 安装8.2

tar -zxvf php-8.2.22.tar.gz 

#编译安装8.2 

./configure --prefix=/usr/local/php8.2 --exec-prefix=/usr/local/php8.2 --bindir=/usr/local/php8.2/bin --sbindir=/usr/local/php8.2/sbin --includedir=/usr/local/php8.2/include --libdir=/usr/local/php8.2/lib/php --mandir=/usr/local/php8.2/php/man --with-config-file-path=/usr/local/php8.2/etc --with-mysql-sock=/var/run/mysql/mysql.sock --with-mhash --with-openssl --with-mysqli=shared,mysqlnd --with-pdo-mysql=shared,mysqlnd --enable-gd --with-iconv --with-zlib --with-zip --disable-debug --disable-rpath --enable-shared --enable-xml --enable-bcmath --enable-shmop --enable-sysvsem --enable-mbregex --enable-mbstring --enable-ftp --enable-pcntl --enable-calendar --enable-exif --enable-sockets --with-XMLrpc --with-libxml-dir --enable-soap --without-pear --with-gettext --enable-session --with-curl --with-jpeg-dir --with-png-dir --with-freetype-dir --with-bz2 --enable-opcache --enable-fpm --with-fpm-user=nginx --with-fpm-group=nginx --with-pdo-mysql --with-pdo-pgsql --with-pcre-jit --without-gdbm --enable-fast-install --disable-fileinfo -gdbm --enable-fast-install --disable-fileinfo

 make make install

修改配置

cp php.ini-production /usr/local/php8.2/etc/php.ini 

cp /usr/local/php8.2/etc/php-fpm.conf.default /usr/local/php8.2/etc/php-fpm.conf 

cp /usr/local/php8.2/etc/php-fpm.d/www.conf.default /usr/local/php8.2/etc/php-fpm.d/www.conf


修改端口9008

/usr/local/php8.2/etc/php-fpm.d/www.conf 

#启动服务 

 /usr/local/php8.2/sbin/php-fpm

 /usr/local/php7.2/sbin/php-fpm

 /usr/local/php5.6/sbin/php-fpm

这样一个简单的多版本共存就可以啦


在安装8.2版本过程中可能需要升级libzip 等等各种依赖关系的处理 出现问题 yum安装或者下载编译安装就可以了



打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论