安装centos源
yum install epel-release –y
下载php安装压缩包
wget https://www.php.net/distributions/php-7.3.15.tar.gz
进入php-7.3.15文件目录
安装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
安装cmake3
yum install cmake3 –y
拷贝一份,重命名为cmake
cp /usr/bin/cmake3 /usr/bin/cmake
查看cmake是否为3.0以上版本
cmake –version
第二步:安装libzip1.5.2
安装bzip2-devel依赖包
yum install bzip2 bzip2-devel -y
到官网下载libzip压缩包
wget https://libzip.org/download/libzip-1.6.1.tar.gz
解压进入libzip-1.6.1创建build目录
tar xf libzip-1.6.1.tar.gz
cd libzip-1.6.1
mkdir build
进入build目录里面执行cmake …,make,make安装
cd build
cmake …
make
make install
创建www用户
useradd -M -s /sbin/nologin www
-M:不要自动建立用户的登入目录
-s 用户不能用作登录
Id www 查看
#修改库加载路径
vim /etc/ld.so.conf
#添加如下几行
/usr/local/lib64
/usr/local/lib
/usr/lib
/usr/lib64
使之生效:
ldconfig -v
进入php-7.3.15目录配置
./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
然后编译安装大概10分钟
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
拷贝启动脚本到指定目录
cp /root/php-7.3.15/sapi/fpm/php-fpm.service /usr/lib/systemd/system/
修改配置文件名
cd /usr/local/php/etc/php-fpm.d
cp www.conf.default www.conf
启动PHP
systemctl start php-fpm
允许自启
systemctl enable php-fpm
查看状态
systemctl status php-fpm
ps -ef|grep php-fpm
查看端口
ss -lntup|grep 9000