安装必备依赖
yum -y install libxml2 libxml2-devel openssl openssl-devel curl-devel libjpeg-devel libpng-devel freetype-devel libmcrypt-devel libzip-devel pcre-devel sqlite-devel epel-release
安装oniguruma
oniguruma是一个处理正则表达式的库,因此需要安装
wget https://github.com/kkos/oniguruma/archive/v6.9.4.tar.gz -O oniguruma-6.9.4.tar.gz
tar -zxvf oniguruma-6.9.4.tar.gz
cd oniguruma-6.9.4/
./autogen.sh
./configure --prefix=/usr --libdir=/lib64
make && make install
下载安装包并安装
1、下载
wget https://www.php.net/distributions/php-7.4.28.tar.gz
2、解压
tar zxvf php-7.4.28.tar.gz
3、编译
./configure --prefix=/app/php7 \
--with-config-file-path=/app/php7/etc \
--with-config-file-scan-dir=/app/php7/etc/php.d \--enable-mysqlnd \
--with-mysqli \
--with-pdo-mysql \
--enable-fpm \
--with-fpm-user=nginx \
--with-fpm-group=nginx \
--enable-gd \
--with-iconv \
--with-zlib \
--enable-xml \
--enable-shmop \
--enable-sysvsem \
--enable-inline-optimization \
--enable-mbregex \
--enable-mbstring \
--disable-mbregex \
--enable-ftp \--with-openssl \
--enable-pcntl \
--enable-sockets \
--with-xmlrpc \
--with-zip \
--enable-soap \
--without-pear \
--with-gettext \
--enable-session \
--with-curl \
--enable-jpeg-dir \
--enable-freetype-dir \
--enable-bcmath \
--enable-opcache
4、安装
make && make install -j2 #-j2启动两个进程
配置php
1、复制ini配置文件
mkdir -p /app/php7/etc
cp php.ini-production /app/php7/etc/php.ini
2、配置fpm
cd /app/php-7.4.28/sapi/fpm
mkdir -p /app/php7/sbin
cp init.d.php-fpm.in /app/php7/sbin/php-fpm
chmod a+x /app/php7/sbin/php-fpm
cp php-7.4.28/sapi/fpm/php-fpm.conf.in /app/php7/etc/php-fpm.conf
cp php-7.4.28/sapi/fpm/www.conf.in /app/php7/etc/php-fpm.d/