php 源码安装常见问题

84 篇文章 4 订阅

本文章下载源安装的都是默认一个版本,如果需要安装其他版本,跳转:https://pkgs.org/download/libzip 
 

懒人必备(只是常见部分问题)

yum install -y autoconf glibc-headers gcc-c++ krb5-devel libwebp-devel libzip libzip-devel sqlite-devel oniguruma  curl-devel  bzip2 bzip2-devel libjpeg-devel libpng-devel freetype-devel libxslt libxslt-devel libzip-devel oniguruma-devel

 安装imagick

configure: error: not found. Please provide a path to MagickWand-config or Wand-config program. 

yum install ImageMagick-devel

Cannot find autoconf. Please check your autoconf installation and the$PHP_AUTOCONF environment variable. Then, rerun this script.

yum install autoconf

make: *** [sapi/cli/php] Error 1

在安裝 PHP 到系统中时要是发生「undefined reference to libiconv_open'」之类的错误信息,那表示在「./configure 」沒抓好一些环境变数值。错误发生点在建立「-o sapi/cli/php」是出错,没給到要 link 的 iconv 函式库参数。 解决方法:编辑Makefile 大约77 行左右的地方: EXTRA_LIBS = ..... -lcrypt 在最后加上 -liconv,例如: EXTRA_LIBS = ..... -lcrypt -liconv 然后

make clean && make

/usr/local/include/zip.h:59:21: fatal error: zipconf.h: No such file or dire


cp /usr/local/lib/libzip/include/zipconf.h /usr/local/include/zipconf.h

error: C++ preprocessor "/lib/cpp" fails sanity check错误解决方法

yum install glibc-headers

yum install gcc-c++ 

Cannot find autoconf. Please check your autoconf installation and the
$PHP_AUTOCONF environment variable. Then, rerun this script.

 

yum install autoconf

Package 'krb5', required by 'virtual:world', not found

yum install krb5-devel

configure: error: Package requirements (libwebp) were not met:No package 'libwebp' found
 

yum install libwebp-devel

或者 


//libwebp-devel
wget http://mirror.centos.org/centos/7/os/x86_64/Packages/libwebp-devel-0.3.0-7.el7.x86_64.rpm

yum localinstall libwebp-devel-0.3.0-7.el7.x86_64.rpm

configure: error: Package requirements (libzip >= 0.11) were not met: Requested 'libzip >= 0.11' but version of libzip is 0.10.1 

方法一:yum命令自动安装,如果你源没有的话只能走方法二

yum  install libzip
yum  install libzip-devel

方法二:下载源安装

下载源安装libzip 0.11和libzip-devel 0.11版本,

//安装libzip
wget http://packages.psychotic.ninja/7/plus/x86_64/RPMS//libzip-0.11.2-6.el7.psychotic.x86_64.rpm

yum localinstall libzip-0.11.2-6.el7.psychotic.x86_64.rpm

//安装libzip-devel
wget http://packages.psychotic.ninja/7/plus/x86_64/RPMS//libzip-devel-0.11.2-6.el7.psychotic.x86_64.rpm

yum localinstall libzip-devel-0.11.2-6.el7.psychotic.x86_64.rpm

方法三:

先删除旧版本
yum remove -y libzip
#下载编译安装
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


 /usr/bin/mkdir -p '/usr/local/lib/pkgconfig'
 /usr/bin/install -c -m 644 libzip.pc '/usr/local/lib/pkgconfig'


在变量 PKG_CONFIG_PATH 追加刚刚编译生成的/usr/local/lib/pkgconfig,“ :” 是分隔符

export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/lib/pkgconfig
再echo一下PKG_CONFIG_PATH

[root@localhost]# echo $PKG_CONFIG_PATH
/usr/local/pcre2/lib/pkgconfig/:/usr/local/lib/pkgconfig
这样就成功追加到PKG_CONFIG_PATH了

configure: error: Package requirements (sqlite3 > 3.7.4) were not met:No package 'sqlite3' found

yum install sqlite-devel

configure: error: Package requirements (oniguruma) were not met:No package 'oniguruma' found

方法一

yum install oniguruma
yum install oniguruma-devel

方法二

到centos官网oniguruma-6.7.0-1.el7 | Build Info | CentOS Community Build Service

wget http://www6.atomicorp.com/channels/atomic/centos/7/x86_64/RPMS/oniguruma-5.9.5-3.el7.art.x86_64.rpm

 yum localinstall oniguruma-5.9.5-3.el7.art.x86_64.rpm


wget http://www6.atomicorp.com/channels/atomic/centos/7/x86_64/RPMS/oniguruma-devel-5.9.5-3.el7.art.x86_64.rpm

yum localinstall oniguruma-devel-5.9.5-3.el7.art.x86_64.rpm

拓展安装报错:Warning: PHP Startup: Invalid library (maybe not a PHP library) '*.so' in Unknown on lin

解决方法

make clean    //清除上次的make命令所产生的object文件(后缀为“.o”的文件)及可执行文件。

然后再来一次 ./configure ******的编译

Warning: Module 'mysqli' already loaded in Unknown on line 0

出现这个时候,证明重复加载了,去php.ini把对应的extension 屏蔽就好了,然后再php -m查看一下对应扩展是否加载了

checking for cURL 7.15.5 or greater... configure: error: cURL version 7.15.5 or later is required to compile php with cURL support 

或者requirements (libxml-2.0 >= 2.7.6)

 执行以下命令安装最新版本的curl即可

yum install -y curl-devel

configure: error: xml2-config not found. Please check your libxml2 installation. 

#rpm -qa |grep  libxml2
libxml2-2.6.26-2.1.12
libxml2-python-2.6.26-2.1.12
重新安装libxml2和libxml2-devel包
​yum install libxml2
yum install libxml2-devel -y
安装完之后查找xml2-config文件是否存在
# find / -name "xml2-config"
/usr/bin/xml2-config
如果存在的话重新安装php
# ./configure
之后再进行编译​
make && make install

configure: error: Please reinstall the BZip2 distribution 

执行以下命令安装对应开发包即可 

yum install bzip2 bzip2-devel

configure: error: jpeglib.h not found.

执行以下命令安装对应开发包即可 

yum -y install libjpeg-devel

configure: error: png.h not found.


执行以下命令安装对应开发包即可 

yum install libpng-devel

Configure: error: freetype.h not found

执行以下命令安装对应开发包即可 

yum install freetype-devel

xslt-config not found. Please reinstall the libxslt >= 1.1.0 distribution

yum -y install libxslt libxslt-devel

configure: error: Please reinstall the libzip distribution 

yum install libzip-devel

checking for libzip... configure: error: system libzip must be upgraded to version >= 0.11

libzip的版本问题,去官网下载最新的安装Download · libzip

先删除旧版本
yum remove -y libzip

wget https://nih.at/libzip/libzip-1.2.0.tar.gz
tar -xf 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 # 使之生效

Cannot find OpenSSL's evp.h

这错误是缺少openssl相关的库导致的,安装一下openssl的库就好了 

yum install openssl openssl-devel

configure: error: Package requirements (libsodium >= 1.0.8) were not met:

No package 'libsodium' found

Consider adjusting the PKG_CONFIG_PATH environment variable if you
installed software in a non-standard prefix.

Alternatively, you may set the environment variables LIBSODIUM_CFLAGS
and LIBSODIUM_LIBS to avoid the need to call pkg-config.

安装 libsodium

wget https://download.libsodium.org/libsodium/releases/libsodium-1.0.18-stable.tar.gz
tar -zxf libsodium-1.0.18-stable.tar.gz
cd libsodium-stable
./configure 
make && make install

方法一:临时生效,重新登录即失效
export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig
方法二:永久生成
vim /etc/profile
在profile文件加上
export  PKG_CONFIG_PATH=/usr/local/lib/pkgconfig
然后执行
source /etc/profile

执行一下命令能看到图示结果证明安装成功了 

pkg-config --list-all | grep libsodium

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值