2021-07-15 Centos7 安装php7,并与php8共存

无道 2021-07-16 0 条评论 一些备忘 阅读222 手机阅读

前言

共存需要编译安装以指定安装目录

下载

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

系统依赖

yum install gcc autoconf gcc-c++ -y
yum install -y libxml2 libxml2-devel openssl openssl-devel bzip2 bzip2-devel libcurl libcurl-devel libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel gmp gmp-devel readline readline-devel libxslt libxslt-devel
yum install -y systemd-devel
yum install -y openjpeg-devel

配置

./configure \
--prefix=/usr/local/php7 \
--with-config-file-path=/usr/local/php7/etc \
--enable-mbstring \
--enable-xmlreader \
--enable-xmlwriter \
--enable-soap \
--enable-calendar \
--with-curl \
--with-zlib \
--with-pdo-sqlite \
--with-pdo-mysql \
--with-mysqli \
--with-mysql-sock \
--enable-mysqlnd \
--disable-rpath \
--enable-inline-optimization \
--with-bz2 \
--with-zlib \
--enable-sockets \
--enable-sysvsem \
--enable-sysvshm \
--enable-pcntl \
--enable-mbregex \
--enable-exif \
--enable-bcmath \
--with-mhash \
--enable-gd \
--with-openssl \
--enable-ftp \
--with-kerberos \
--with-gettext \
--with-xmlrpc \
--with-xsl \
--enable-fpm \
--with-fpm-user=php-fpm \
--with-fpm-group=php-fpm \
--with-fpm-systemd \
--disable-fileinfo \
--with-jpeg=/usr/include \
--with-freetype=/usr/include/freetype2


# --with-libxml-dir=/usr \
# --with-webp=/usr/include/webp \

编译安装

make && make install

步骤

1、php.ini

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

2、php-fpm

/usr/local/php7/etc
cp php-fpm.conf.default php-fpm.conf 
vim php-fpm.conf
error_log = /usr/local/php7/var/php-fpm.log
pid = /usr/local/php7/var/run/php-fpm.pid

3、www.conf

cd etc/php-fpm.d/
cp www.conf.default www.conf

4、fpm-service

# /root/install/php7/php-7.4.21
cp ./sapi/fpm/php-fpm.service /usr/lib/systemd/system/php7-fpm

扩展安装方法

cd /root/install/php7/php-7.4.21/ext/fileinfo && /usr/local/php7/bin/phpize && ./configure --with-php-config=/usr/local/php7/bin/php-config && make && make install 
全文完 [
有帮助?打赏
支付宝打赏
微信打赏
]
标签: php7 centos7
修改: 07月16日 19:34
这篇文章还没有评论呢~
点击刷新/生成验证码