如果想一步到位,則使用下面的流程進行安裝:
第一步: 安裝cmake
yum install epel-release -y
yum install cmake3 -y
cp /usr/bin/cmake3 /usr/bin/cmake
執行命令cmake -version
查看是否安裝成功:
#輸出
cmake version 3.16.1
CMake suite maintained and supported by Kitware (kitware.com/cmake).
第二步:安裝libzip1.5.2
#安裝bzip2-devel依賴包
yum install bzip2 bzip2-devel -y
#安裝libzip
cd ~
wget https://libzip.org/download/libzip-1.5.2.tar.gz
tar xf libzip-1.5.2.tar.gz
cd libzip-1.5.2
mkdir build
cd build
cmake ..
make
#make test
make install
第三步:安裝php依賴
yum install gcc \
gcc-c++ \
libxml2 \
libxml2-devel \
openssl \
openssl-devel \
libcurl \
libcurl-devel \
freetype \
freetype-devel \
libjpeg \
libjpeg-devel \
libpng \
libpng-devel \
libxslt \
libxslt-devel \
systemd-devel \
libicu-devel \
libedit-devel
第四步:創建www用戶
useradd -M -s /sbin/nologin www
修改庫加載路徑
vim /etc/ld.so.conf
#添加如下幾行
/usr/local/lib64
/usr/local/lib
/usr/lib
/usr/lib64
使之生效:
ldconfig -v
或者:
echo /usr/local/lib64 >>/etc/ld.so.conf
echo /usr/local/lib >>/etc/ld.so.conf
echo /usr/lib >>/etc/ld.so.conf
echo /usr/lib64 >>/etc/ld.so.conf
ldconfig -v
最終,再次進行預配置
第五步:下載php源碼並預配置
#安裝wget工具
yum install wget -y
#下載php源碼
wget https://www.php.net/distributions/php-7.3.12.tar.gz
#解壓php tar包
tar xf php-7.3.12.tar.gz
#進入php解壓后的目錄
cd php-7.3.12
#預配置
./configure --prefix=/usr/local/php \
--with-config-file-path=/usr/local/php/etc \
--with-config-file-scan-dir=/usr/local/php/etc/conf.d \
--disable-cgi \
--enable-fpm \
--with-fpm-user=www \
--with-fpm-group=www \
--enable-ftp \
--with-curl \
--with-gd \
--with-gettext \
--with-iconv-dir \
--with-kerberos \
--with-libedit \
--with-openssl \
--with-pcre-regex \
--with-pdo-mysql \
--with-xsl \
--with-zlib \
--with-mhash \
--with-mysqli \
--with-png-dir=/usr/lib \
--with-jpeg-dir=/usr/lib\
--with-freetype-dir=/usr/lib \
--enable-mysqlnd \
--enable-bcmath \
--enable-libxml \
--enable-inline-optimization \
--enable-gd-jis-conv \
--enable-mbregex \
--enable-mbstring \
--enable-opcache \
--enable-pcntl \
--enable-shmop \
--enable-soap \
--enable-sockets \
--enable-sysvsem \
--enable-xml \
--enable-zip \
--enable-calendar \
--enable-intl \
--enable-exif
查看最后輸出是否出現error:
如果沒有error出現,並且出現如下字眼,則進行下一步
Thank you for using PHP
第六步: 進行編譯安裝
make && make install
第七步:創建啟動腳本
cp php.ini-development /usr/local/php/etc/php.ini
cd /usr/local/php/etc/
cp php-fpm.conf.default php-fpm.conf
默認官方提供了一個systemd管理腳本
路徑為:/root/php-7.3.12/sapi/fpm下php-fpm.service
#復制一份配置文件
cp php-fpm.conf.default php-fpm.conf
#拷貝啟動腳本到指定目錄
cp /root/php-7.3.13/sapi/fpm/php-fpm.service /usr/lib/systemd/system/
systemctl daemon-reload
systemctl start php-fpm
systemctl enable php-fpm
systemctl status php-fpm
這個時候還沒完,啟動 會提示你找不到包含的配置文件:
cd /usr/local/php/etc/php-fpm.d/
cp www.conf.default www.conf
systemctl start php-fpm
systemctl status php-fpm
這個時候不出意外就是正常狀態:
查看進程是否存在
ps -ef|grep php-fpm
查看端口是否啟動:
ss -lntup|grep 9000