一、前期准备
1、更新yum
yum -y update
2、安装依赖
yum -y install libxml2 libxml2-devel openssl openssl-devel bzip2 bzip2-devel libcurl libcurl-devel libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel gmp gmp-devel libmcrypt libmcrypt-devel readline readline-devel libxslt libxslt-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel ncurses curl gdbm-devel db4-devel libXpm-devel libX11-devel gd-devel gmp-devel expat-devel xmlrpc-c xmlrpc-c-devel libicu-devel libmcrypt-devel libmemcached-devel libzip gcc-c++
3、安装cmake
// 下载安装包至 /usr/local/src 目录下
wget https://github.com/Kitware/CMake/releases/download/v3.14.3/cmake-3.14.3.tar.gz -P /usr/local/src
// 解压并进入解压后目录
cd /usr/local/src
tar -zxvf cmake-3.14.3.tar.gz
cd cmake-3.14.3
// 安装(需要一小段时间,耐心等待)
./bootstrap
make
make install
4、卸载旧版libzip,安装新版libzip
此操作可解决php7.3编译错误 configure: error: Please reinstall the libzip distribution
// 卸载旧版libzip
yum -y remove libzip
// 下载新版libzip至 /usr/local/src 目录下
wget https://libzip.org/download/libzip-1.5.2.tar.gz -P /usr/local/src
// 解压并进入解压后目录
cd /usr/local/src
tar -zxvf libzip-1.5.2.tar.gz
cd libzip-1.5.2
// 创建 build 文件夹并进入
mkdir build
cd build
// cmake .. (注意cmake命令后的两个英文点)
cmake ..
make
make install
5、动态函数库加载的配置新版 lib
此操作可解决php7.3编译错误 error: off_t undefined; check your library configuration
vi /etc/ld.so.conf
// 添加下面几行,如图 5-1
/usr/local/lib64
/usr/local/lib
/usr/lib
/usr/lib64

// 更新配置
ldconfig -v
2、下载安装php7.3
1、下载安装php7.3
// 下载php7.3至 /usr/local/src
wget https://www.php.net/distributions/php-7.3.9.tar.gz -P /usr/local/src
// 解压并进入文件夹
cd /usr/local/src
tar -zxvf php-7.3.9.tar.gz
cd php-7.3.9
// 编译
./configure \
--prefix=/usr/local/php\
--enable-fpm\
--with-fpm-user=www\
--with-fpm-group=www\
--with-config-file-path=/usr/local/php/conf\
--disable-rpath\
--enable-soap\
--with-libxml-dir\
--with-xmlrpc\
--with-openssl\
--with-mhash\
--with-pcre-regex\
--with-zlib\
--enable-bcmath\
--with-bz2\
--enable-calendar\
--with-curl\
--enable-exif\
--with-pcre-dir\
--enable-ftp\
--with-gd\
--with-openssl-dir\
--with-jpeg-dir\
--with-png-dir\
--with-zlib-dir\
--with-freetype-dir\
--enable-gd-jis-conv\
--with-gettext\
--with-gmp\
--with-mhash\
--enable-mbstring\
--with-onig\
--with-mysqli=mysqlnd\
--with-pdo-mysql=mysqlnd\
--with-zlib-dir\
--with-readline\
--enable-shmop\
--enable-sockets\
--enable-sysvmsg\
--enable-sysvsem \
--enable-sysvshm \
--enable-wddx\
--with-libxml-dir\
--with-xsl\
--enable-zip\
--with-pear
// 安装
make
make install
2、复制生成配置文件
cp /usr/local/src/php-7.3.9/php.ini-production /usr/local/php/conf/php.ini
cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf
cp /usr/local/php/etc/php-fpm.d/www.conf.default /usr/local/php/etc/php-fpm.d/www.conf
3、编辑 /etc/profile 文件,配置环境变量
// 编辑配置文件
vi /etc/profile
// 添加下面内容
php=/usr/local/php/bin
PATH=$PATH:$php
export PATH

// 保存并退出编辑后,执行 srource /etc/profile 使配置文件生效
source /etc/profile
网友评论