安装php
安装依赖
yum install libxml2 libxml2-devel curl-devel openjpeg openjpeg-devel openjpeg-libs libjpeg libjpeg-devel libpng freetype libpng-devel freetype-devel openssl openssl-devel
创建源码保存目录,下载,解压
mkdir -p /usr/local/src/php
cd /usr/local/src/php
wget -c http://cn2.php.net/get/php-7.3.15.tar.gz
tar -xzvf php-7.3.13.tar.gz
cd 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/php.d \
--with-mhash \
--disable-debug \
--disable-rpath \
--enable-mysqlnd \
--with-mysqli \
--with-pdo-mysql \
--enable-fpm \
--with-fpm-user=www \
--with-fpm-group=www \
--with-gd \
--with-iconv \
--with-zlib \
--enable-bcmath \
--enable-xml \
--enable-shmop \
--enable-sysvsem \
--enable-inline-optimization \
--enable-mbregex \
--enable-mbstring \
--enable-ftp \
--with-openssl \
--enable-pcntl \
--enable-sockets \
--with-xmlrpc \
--enable-zip \
--enable-soap \
--without-pear \
--with-gettext \
--enable-session \
--with-curl \
--with-jpeg-dir \
--with-png-dir \
--with-freetype-dir
checking for libzip... not found
configure: error: Please reinstall the libzip distribution
解决方案
1)移除旧的libzip:
yum remove libzip
2)安装新版本:
wget https://libzip.org/download/libzip-1.5.1.tar.gz
tar -zxvf libzip-1.5.1.tar.gz
cd libzip-1.5.1
mkdir build
cd build
cmake ..
make && make install
注意:如果提示cmake版本过低,需新版本,则需要重新安装cmake。
注意:低版本的可能不需要cmake,例如1.2版本:
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
configure: error: off_t undefined; check your library configuration
vim /etc/ld.so.conf
#添加如下几行
/usr/local/lib64
/usr/local/lib
/usr/lib
/usr/lib64
#保存退出
:wq
ldconfig -v # 使之生效
编译,安装
make -j4
make install
/usr/local/include/zip.h:59:21: 致命错误:zipconf.h:没有那个文件或目录
ln -s /usr/local/lib/libzip/include/zipconf.h /usr/local/include/
重新编译
设置环境变量
vim /etc/profile
#文件末尾加入如下两行代码
PATH=$PATH:/usr/local/php/bin/:/usr/local/php/sbin/
export PATH
使之立即生效
source /etc/profile
复制示例配置
cp /usr/local/src/php/php-7.3.15/php.ini-development /usr/local/php/etc/php.ini
cp /usr/local/src/php/php-7.3.15/php.ini-production /usr/local/php/etc/php.ini
进入ini目录,复制fpm示例配置
cd /usr/local/php/etc
cp php-fpm.conf.default php-fpm.conf
进入php-fpm.d目录,复制www.conf
cd php-fpm.d
cp www.conf.default www.conf
设置php-fpm开机启动
cp /usr/local/src/php/php-7.3.15/sapi/fpm/php-fpm.service /usr/lib/systemd/system/
重新载入 systemd
systemctl daemon-reload
启用开机启动
systemctl enable php-fpm
启动php-fpm
systemctl start php-fpm
查看状态
systemctl status php-fpm
● php-fpm.service - The PHP FastCGI Process Manager
Loaded: loaded (/usr/lib/systemd/system/php-fpm.service; disabled; vendor preset: disabled)
Active: active (running) since 四 2020-03-05 13:17:25 CST; 8s ago
Main PID: 19006 (php-fpm)
CGroup: /system.slice/php-fpm.service
├─19006 php-fpm: master process (/usr/local/php/etc/php-fpm.conf)
├─19007 php-fpm: pool www
└─19008 php-fpm: pool www
3月 05 13:17:25 iZuf6hrvuisgfweizxo64sZ systemd[1]: Started The PHP FastCGI Process Manager.