1.安装依赖 (我也是百度搜索的)
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.x86_64
安装oniguruma库
wget https://github.com/kkos/oniguruma/releases/download/v6.9.5_rev1/onig-6.9.5-rev1.tar.gz -O onig-6.9.5.tar.gz# 解压 并且进入目录 ->指定路径 ./configure --prefix=/usr --libdir=/lib64make && make install
php官网进行下载,下载要安装的版本
–prefix=/usr/local/php7 //php安装目录–with-config-file-path=/usr/local/php7/etc //php配置目录–with-config-file-scan-dir=/usr/local/php7/etc/php.d //php.d目录--with-fpm-user=nginx \ 指定用户--with-fpm-group=nginx \ 指定组# 官网地址https://www.php.net/downloads.php# 解压tar xf php-7.4.32.tar.gz# 进入目录# 编译安装./configure --prefix=/usr/local/php7 \--with-config-file-path=/usr/local/php7/etc \--with-config-file-scan-dir=/usr/local/php7/etc/php.d \--enable-mysqlnd \--with-mysqli \--with-pdo-mysql \--enable-fpm \--with-fpm-user=nginx \--with-fpm-group=nginx \--with-gd \--with-iconv \--with-zlib \--enable-xml \--enable-shmop \--enable-sysvsem \--enable-inline-optimization \--enable-mbregex \--enable-mbstring \--enable-ftp \--with-openssl \--enable-pcntl \--enable-sockets \--with-xmlrpc \--enable-zip \--enable-soap \--without-pear \--with-gettext \--enable-session \--with-curl \--with-jpeg-dir \--with-freetype-dir \--enable-opcache# 安装的时候非常慢make && make install
配置php
#进入目录 cd /root/php-7.4.32cp php.ini-development /usr/local/php7/etc/php.inicp sapi/fpm/www.conf /usr/local/php7/etc/php-fpm.d/www.confcp sapi/fpm/php-fpm.conf /usr/local/php7/etc/php-fpm.confcp sapi/fpm/init.d.php-fpm.in /etc/init.d/php-fpm
修改 /etc/init.d/php-fpm
vim /etc/init.d/php-fpmphp_fpm_BIN=/usr/local/php7/sbin/php-fpmphp_fpm_CONF=/usr/local/php7/etc/php-fpm.confphp_fpm_PID=/usr/local/php7/var/run/php-fpm.pid
来源地址:https://blog.csdn.net/qq_41961206/article/details/127242842