WordPress升级到5.2后,就开始提示我应该升级php 7了,刚好cosy主题的更新也提示支持php 7,因此就着手将主机里的php从5.6.30升级到7.3.9,说简单也简单,下载最新的版本,照着安装文档即可。可是安装的过程还是遇到一些问题,如libzip、ldconfig,以及–with-mysql等……

一、安装过程

1.1 更新libzip

此处以更新1.3.2版本为例,1.5.1版本的见下方

yum -y remove libzip-devel
wget https://libzip.org/download/libzip-1.3.2.tar.gz
tar xvf libzip-1.3.2.tar.gz
cd libzip-1.3.2
./configure
make && make install

更新1.5.1版本

yum -y install cmake
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

1.2 更新ld.so.conf

# 添加搜索路径到配置文件
echo '/usr/local/lib64
/usr/local/lib
/usr/lib
/usr/lib64'>>/etc/ld.so.conf
# 更新配置
ldconfig -v

1.3 安装php 7.3.9

wget https://www.php.net/distributions/php-7.3.9.tar.gz
tar -zxf php-7.3.9.tar.gz
cd php-7.3.9/
./configure --prefix=/usr/local/php-7.3.9 --with-libdir=lib64 --enable-fpm --enable-mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --enable-mysqlnd-compression-support --enable-opcache --enable-pcntl --enable-mbstring --enable-soap --enable-zip --enable-calendar --enable-bcmath --enable-exif --enable-ftp --enable-intl --with-openssl --with-zlib --with-curl --with-gd --with-jpeg-dir=/usr/lib64 --with-png-dir=/usr/lib64 --with-freetype-dir=/usr/lib64 --with-xpm-dir=/usr/lib64 --with-zlib --with-gettext --with-mhash --with-ldap
make
make install

#安装完成
cd /usr/local/
ln -s php-7.3.9 php

1.4 安装yaf

wget http://pecl.php.net/get/yaf-3.0.8.tgz
tar -zxf yaf-3.0.8.tgz
cd yaf-3.0.8/
/usr/local/php-7.3.9/bin/phpize
./configure --with-php-config=/usr/local/php-7.3.9/bin/php-config
make
make install

二、问题汇总

安装过程中遇到了以下问题:

  1. system libzip must be upgraded to version >= 0.11,遇到此问题参照1.1更新libzip即可。
  2. 出现error: off_t undefined; check your library configuration,遇到此问题参照1.2更新ld.so.conf
  3. –with-mysql已经不被支持,编译参数使用–enable-mysqlnd –with-mysqli=mysqlnd –with-pdo-mysql=mysqlnd

三、后记

一开始编译参数有误,没有配置–with-mysqli,结果更新php到7.3.9后Wordpress直接报错,打开了DEBUG模式才发现是数据库连接的问题,加上mysqli的配置后随即恢复正常。

其他方面嘛,小网站,着实没有什么直观上的感受差异。