1.首先更新依賴包。php
yum -y update
mysql
2.安裝依賴包c++
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.轉到 /usr/local/src 目錄,下載php7.3.5git
cd /usr/local/src
wget https://www.php.net/distributions/php-7.3.5.tar.gz
4.解壓安裝包,並進入目錄github
tar -zxvf php-7.3.5.tar.gz
cd php-7.3.5
5.添加用戶和組sql
groupadd www
useradd -g www www
bootstrap
6.開始編譯api
./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
這裏會提示 configure: error: Please reinstall the libzip distribution,咱們須要溢出libzip,手動安裝最新版本,php7
先編譯安裝最新版cmakecurl
cd /usr/local/src
wget https://github.com/Kitware/CMake/releases/download/v3.14.3/cmake-3.14.3.tar.gz
tar -zxvf cmake-3.14.3.tar.gz
cd cmake-3.14.3
./bootstrap
make && make install
再編譯安裝libzip
yum remove libzip -y
cd /usr/local/src
wget https://libzip.org/download/libzip-1.5.2.tar.gz
tar -zxvf libzip-1.5.2.tar.gz
cd libzip-1.5.2
mkdir build
cd build
cmake ..
make && make install
再次編譯php7.3,繼續報錯 error: off_t undefined; check your library configuration
執行如下命令
vi /etc/ld.so.conf
#添加以下幾行
/usr/local/lib64
/usr/local/lib
/usr/lib
/usr/lib64
#保存退出
:wq
ldconfig -v # 使之生效
再次編譯PHP7.3
make && make install
7.編譯完成後,添加環境變量
vi /etc/profile
#添加如下內容到最後
PATH=$PATH:/usr/local/php/bin
export PATH
#刷新環境變量
source /etc/profile
8.編輯配置文件
cp 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
9.把systemctl文件加入開機啓動文件
cp sapi/fpm/php-fpm.service /usr/lib/systemd/system/php-fpm.servicesystemctl start php-fpm.servicesystemctl enable php-fpm.service --------------------- 版權聲明:本文爲CSDN博主「ijijni」的原創文章,遵循CC 4.0 by-sa版權協議,轉載請附上原文出處連接及本聲明。原文連接:https://blog.csdn.net/ijijni/article/details/89913738