1

采用源码的方式安装PHP,在编译(./configure ....)时往往会遇到各种各样的报错和提示,整理一些可能会遇到的安装问题和相关解决方法,持续更新

1. Please reinstall the libzip distribution

参考资料
https://www.cnblogs.com/gyfluck/p/10478386.html

升级Cmake,当前服务器的cmake版本较低,需要重新安装最高版本
当前cmake是最新版本直接跳过此步骤

# 删除当前已安装

yum remove cmake

# 下载
wget https://cmake.org/files/v3.14/cmake-3.14.5.tar.gz

# 解压缩
tar zxvf cmake-3.14.5.tar.gz

# 配置
./configure --prefix=/usr/local/cmake

# 安装
 make && make install
 
 # 创建链接
 ln -s /usr/local/cmake/bin/cmake /usr/bin/cmake
 
 # 查看版本
 cmake -version

安装最新版本的libzip

# 删除旧版本
yum remove libzip libzip-devel

# 下载新版本
curl 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

2. off_t undefined; check your library configuration

参考资讯
https://blog.csdn.net/github_38336924/article/details/88898655

第一步

echo '/usr/local/lib64
/usr/local/lib
/usr/lib
/usr/lib64'>>/etc/ld.so.conf

第二步

ldconfig -v

3. unrecognized options: –with-mcrypt, –enable-gd-native-ttf

参考资料
https://www.qinziheng.com/php/4869.htm

将以上两个编译选项删除

4. unrecognized options: --with-mysql

参考资料
https://blog.csdn.net/zhou75771217/article/details/83303058

php7版本不支持mysql模块
改用--with-pdo-mysql

5. virtual memory exhausted: Cannot allocate memory

参考资料
https://www.cnblogs.com/chenpingzhao/p/4820814.html

原因:服务器的虚拟内存不足引起的报错
解决:自行分配虚拟内存,再进行编译

查看当前配置

free -m

Step1 创建虚拟内存文件

mkdir /home/opt/images
rm -rf /home/opt/images/swap
dd if=/dev/zero of=/home/opt/images/swap bs=1024 count=2048000 

Step2 启用文件

mkswap /home/opt/images/swap

Step3 查看是否配置成功,执行 free -m

              total        used        free      shared  buff/cache   available
Mem:            992         178         137           0         676         670
Swap:          1999         112        1887

Step4 回到php安装目录,重新编译

make && make install

Step5 使用完毕,关闭文件

cd /home/opt/images/
swapoff swap
rm -f /home/opt/images/swap

6. No package ‘sqlite3‘ found

sudo apt-get install libsqlite3-dev

7. Please reinstall the BZip2 distribution

sudo apt-get install libbz2-dev
sudo yum install bzip2-devel

8. Package requirements (libcurl >= 7.15.5) were not met

参考地址:https://www.cpming.top/p/package-requirements-libcurl-7-15-5-were-not-met

# Ubuntu / Debian
sudo apt-get install libcurl4-openssl-dev

# RHEL / CentOS
sudo yum install libcurl-devel

# Mac OS
brew install curl

ken_wong
180 声望6 粉丝