编译安装PHP

编译安装PHP - 7.3.16

1 ) 安装依赖包:

yum install -y gcc gcc-c++  make zlib zlib-devel pcre pcre-devel  libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel openssl openssl-devel openldap openldap-devel nss_ldap openldap-clients openldap-servers libzip libzip-devel libxslt libxslt-devel

yum remove -y libzip

wget https://nih.at/libzip/libzip-1.2.0.tar.gz
tar -zxvf libzip-1.2.0.tar.gz
cd libzip-1.2.0
./configure && make && make install

cp /usr/local/lib/libzip/include/zipconf.h /usr/local/include/zipconf.h
#添加搜索路径到配置文件
vim /etc/ld.so.conf 

/usr/local/lib64
/usr/local/lib
/usr/lib
/usr/lib64

## 保存退出:
#然后 更新配置
ldconfig -v

2 ) 下载php-7.3.16 安装包

wget https://www.php.net/distributions/php-7.3.16.tar.gz
tar -zxf php-7.3.16.tar.gz
cd php-7.3.16

./configure --prefix=/data/soft/php7 --with-pdo --with-zlib-dir --with-freetype-dir --enable-mbstring --with-libxml --enable-soap --enable-calendar --with-curl --with-gd --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-zip --with-pcre-regex --with-pdo-mysql --with-mysqli --with-jpeg --with-png --with-openssl --with-fpm-user=fmw --with-fpm-group=fmw  --with-libdir=/lib/x86_64-linux-gnu/ --enable-ftp --with-gettext --with-xmlrpc --with-xsl --enable-opcache --enable-fpm --with-iconv --with-xpm

make && make install  

ln -s /data/soft/php7 /data/soft/php
cp php.ini-production /data/soft/php7/etc/php.ini 
cd /data/soft/php7/etc;
cp php-fpm.conf.default php-fpm.conf
cd /data/soft/php/etc/php-fpm.d
cp www.conf.default www.conf

## 添加环境变量:
cd /etc/profile.d/
vim php-fpm.sh
PATH=$PATH:$HOME/bin:/data/soft/php/bin/;/data/soft/php/sbin
export PATH

## 全局变量生效:
source /etc/profile

## 添加启动文件: 
cp /data/src/php-7.3.16/sapi/fpm/php-fpm.service /usr/lib/systemd/system/
systemctl enable php-fpm
systemctl restart php-fpm.service
systemctl status php-fpm.service


原文地址:https://www.cnblogs.com/zhenxing06/p/12706890.html