Yum

解壓 php-pecl-zip

  • February 28, 2014

我很難擺脫我的 depsolving 錯誤,我只能自己解決這個問題。這一切都始於我想從 PHP 5.2 升級到 PHP 5.3(天堂禁止),我被告知我們有各種各樣的依賴混亂,因為我們有多個 PHP 包,沒有其他人在使用它,所以如果我想要它,我必須自己做。

我設法弄清楚如何安裝 PHP 5.3,但只能通過刪除所有以前版本的 PHP 並進行全新安裝。現在“我的”(某人離開的)程式碼依賴於 PHPExcel,它依賴於 php-pecl-zip,而我顯然沒有。這是我嘗試過的一些方法:

使用 PECL 安裝

# pecl install zip   
No releases available for package "pecl.php.net/zip"  
install failed

很確定這是因為我們的機器對可以與誰交談有非常嚴格的規定。所以我無法通過 PECL 訪問包。

使用 YUM 安裝

# yum install php-pecl-zip
Dependencies Resolved

================================================================================
Package             Arch          Version                 Repository      Size
================================================================================
Installing:
php-pecl-zip        x86_64        1.8.10-2.el5            epel            47 k
Installing for dependencies:
php-common          x86_64        5.1.6-24.el5_4.5        updates        152 k

當我有 5.3 時,為什麼它想要一個 PHP 版本 5.1?

當然,如果我放手,它會吐槽:

Transaction Check Error:
 file /etc/php.ini from install of php-common-5.1.6-24.el5_4.5.x86_64 conflicts with file from package php-5.3.24-7.x86_64

只是為了驗證:

# yum list php
Installed Packages
php.x86_64                          5.3.24-7                           installed

我們能繞過它嗎?隨後進行了一些嘗試

# yum install php-pecl-zip --skip-broken
Transaction Check Error:
 file /etc/php.ini from install of php-common-5.1.6-24.el5_4.5.x86_64 conflicts with file from package php-5.3.24-7.x86_64

跳過損壞什麼都不做

# yum install php-pecl-zip --skip-broken --exclude=php-common
php-pecl-zip-1.8.10-2.el5.x86_64 from epel has depsolving problems
 --> Missing Dependency: php-api = 20041225 is needed by package php-pecl-zip-1.8.10-2.el5.x86_64 (epel)
Packages skipped because of dependency problems:
   php-pecl-zip-1.8.10-2.el5.x86_64 from epel

排除包裹無濟於事

# yum install php-pecl-zip --skip-broken --exclude=php-common --exclude=php-api
php-pecl-zip-1.8.10-2.el5.x86_64 from epel has depsolving problems
 --> Missing Dependency: php-api = 20041225 is needed by package php-pecl-zip-1.8.10-2.el5.x86_64 (epel)

Packages skipped because of dependency problems:
   php-pecl-zip-1.8.10-2.el5.x86_64 from epel

我們可以安裝底層依賴嗎?

# yum install php-api
Package php-common is obsoleted by lift-php, trying to install lift-php-5.3.24-10.x86_64 instead
Resolving Dependencies
--> Running transaction check
---> Package lift-php.x86_64 0:5.3.24-10 set to be updated
--> Processing Conflict: lift-php conflicts php
--> Finished Dependency Resolution
lift-php-5.3.24-10.x86_64 from COMPANY-codex-released has depsolving problems
 --> lift-php conflicts with php
Error: lift-php conflicts with php

這是依賴循環開始的地方。您會注意到我們有 COMPANY-codex-released repos 正在執行。

# yum install php-api --skip-broken
Package php-common is obsoleted by lift-php, trying to install lift-php-5.3.24-10.x86_64 instead
Resolving Dependencies
--> Running transaction check
---> Package lift-php.x86_64 0:5.3.24-10 set to be updated
--> Processing Conflict: lift-php conflicts php
--> Finished Dependency Resolution
lift-php-5.3.24-10.x86_64 from COMPANY-codex-released has depsolving problems
 --> lift-php conflicts with php

Packages skipped because of dependency problems:
   lift-php-5.3.24-10.x86_64 from COMPANY-codex-released

排除lift-php?

# yum install php-api --exclude=lift-php
================================================================================
Package           Arch          Version                   Repository      Size
================================================================================
Installing:
php-common        x86_64        5.1.6-24.el5_4.5          updates        152 k

不。

所以我認為 YUM 處於依賴循環中。

我也做了一些愚蠢的事情來安裝一個新的 EPEL repo,但是 yum 無法解析任何鏡像,所以我不得不解除安裝它。我也不確定這些是對稱動作。

我第一次這樣做我也必須這樣做yum install autoconf

用 PEAR 安裝下載的文件

所以我去http://pecl.php.net/package/zip並下載了,scp’d 到我的機器上。

# pear install -O /home/produser/zip-1.12.4.tgz 
PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/lib/php/20090626/php_zip.dll' - /usr/lib/php/20090626/php_zip.dll: cannot open shared object file: No such file or directory in Unknown on line 0
96 source files, building
running: phpize
Configuring for:
PHP Api Version:         20090626
Zend Module Api No:      20090626
Zend Extension Api No:   220090626
building in /var/tmp/pear-build-rootZ3jpba/zip-1.12.4
running: /var/tmp/zip/configure
checking for egrep... grep -E
checking for a sed that does not truncate output... /bin/sed
checking for cc... cc
checking for C compiler default output file name... a.out
checking whether the C compiler works... yes
checking whether we are cross compiling... no
checking for suffix of executables...
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether cc accepts -g... yes
checking for cc option to accept ANSI C... none needed
checking how to run the C preprocessor... cc -E
checking for icc... no
checking for suncc... no
checking whether cc understands -c and -o together... yes
checking for system library directory... lib
checking if compiler supports -R... no
checking if compiler supports -Wl,-rpath,... yes
checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking target system type... x86_64-unknown-linux-gnu
checking for PHP prefix... /usr
checking for PHP includes... -I/usr/include/php -I/usr/include/php/main -I/usr/include/php/TSRM -I/usr/include/php/Zend -I/usr/include/php/ext -I/usr/include/php/ext/date/lib
checking for PHP extension directory... /usr/lib/php/20090626
checking for PHP installed headers prefix... /usr/include/php
checking if debug is enabled... no
checking if zts is enabled... no
checking for re2c... no
configure: WARNING: You will need re2c 0.13.4 or later if you want to regenerate PHP parsers.
checking for gawk... gawk
checking for zip archive read/writesupport... yes, shared
checking for the location of libz... no
checking pcre install prefix... no
checking libzip... no
checking for the location of zlib... configure: error: zip support requires ZLIB. Use --with-zlib-dir=<DIR> to specify prefix where ZLIB include and library are located
ERROR: `/var/tmp/zip/configure' failed

所以前幾個警告實際上是新的。剛才從未見過他們。也許這是一個新的線索。

(編輯:我認為這個啟動錯誤是因為我進入/etc/php.ini並取消註釋extension=php_zip.dll。當我評論該行時,它就消失了。)

但是 zlib 在那裡:

# yum install zlib
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
Excluding Packages in global exclude list
Finished
Excluding Packages from CentOS-5 - Plus
Finished
Setting up Install Process
Package zlib-1.2.3-3.x86_64 already installed and latest version
Nothing to do  

編輯:

# rpm -ql zlib
/usr/lib64/libz.so.1
/usr/lib64/libz.so.1.2.3
/usr/share/doc/zlib-1.2.3
/usr/share/doc/zlib-1.2.3/README

# tar xzf zip-1.12.4.tgz
# cd zip-1.12.4
# phpize
# ./configure --with-zlib-dir=/usr/lib64/libz.so.1
configure: error: Can not find zlib headers under "/usr/lib64/libz.so.1"
# ./configure --with-zlib-dir=/usr/lib64/libz.so.1.2.3
configure: error: Can not find zlib headers under "/usr/lib64/libz.so.1.2.3"
# ./configure --with-zlib-dir=/usr/share/doc/zlib-1.2.3 #not that i expect this one to work
configure: error: Can not find zlib headers under "/usr/share/doc/zlib-1.2.3"
# ./configure --with-zlib-dir=/usr/share/doc/zlib-1.2.3/README #not that i expect this one to work
configure: error: Can not find zlib headers under "/usr/share/doc/zlib-1.2.3/README"

所以即使包管理器說那是 zlib 的位置,並且我已經開始手動編譯它,它仍然不起作用。

重新安裝zlib?似乎執行得很好

# yum reinstall zlib
Downloading Packages:
zlib-1.2.3-3.x86_64.rpm                                  |  51 kB     00:00     
Running rpm_check_debug
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
 Erasing        : zlib                                                     1/2 
 Installing     : zlib                                                     1/2 

Removed:
 zlib.x86_64 0:1.2.3-3                                                         

Installed:
 zlib.x86_64 0:1.2.3-3                                                         

Complete!

編輯

感謝這些人:http ://ubuntuforums.org/showthread.php?t=692704我意識到我需要安裝 zlib-devel。為了更好地衡量,為了消除我的一個警告,我也做了 re2c。

# yum install zlib-devel
Success

# pear install zip-1.12.4.tgz 
make: *** [php_zip.lo] Error 1
ERROR: `make' failed

# yum install re2c
Success

# pear install zip-1.12.4.tgz 
...  
creating libtool
appending configuration tag "CXX" to libtool
configure: creating ./config.status
config.status: creating config.h
running: make
/bin/sh /var/tmp/pear-build-root4xHrWH/zip-1.12.4/libtool --mode=compile cc  -I. -I/var/tmp/zip -DPHP_ATOM_INC -I/var/tmp/pear-build-root4xHrWH/zip-1.12.4/include -I/var/tmp/pear-build-root4xHrWH/zip-1.12.4/main -I/var/tmp/zip -I/usr/include/php -I/usr/include/php/main -I/usr/include/php/TSRM -I/usr/include/php/Zend -I/usr/include/php/ext -I/usr/include/php/ext/date/lib -I/var/tmp/zip/lib  -DHAVE_CONFIG_H  -g -O2   -c /var/tmp/zip/php_zip.c -o php_zip.lo
mkdir .libs
cc -I. -I/var/tmp/zip -DPHP_ATOM_INC -I/var/tmp/pear-build-root4xHrWH/zip-1.12.4/include -I/var/tmp/pear-build-root4xHrWH/zip-1.12.4/main -I/var/tmp/zip -I/usr/include/php -I/usr/include/php/main -I/usr/include/php/TSRM -I/usr/include/php/Zend -I/usr/include/php/ext -I/usr/include/php/ext/date/lib -I/var/tmp/zip/lib -DHAVE_CONFIG_H -g -O2 -c /var/tmp/zip/php_zip.c  -fPIC -DPIC -o .libs/php_zip.o
In file included from /var/tmp/zip/php_zip.c:30:
/usr/include/php/ext/pcre/php_pcre.h:29:18: error: pcre.h: No such file or directory
In file included from /var/tmp/zip/php_zip.c:30:
/usr/include/php/ext/pcre/php_pcre.h:37: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token
/usr/include/php/ext/pcre/php_pcre.h:38: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token
/usr/include/php/ext/pcre/php_pcre.h:44: error: expected specifier-qualifier-list before ‘pcre’
/var/tmp/zip/php_zip.c: In function ‘php_zip_pcre’:
/var/tmp/zip/php_zip.c:672: error: ‘pcre’ undeclared (first use in this function)
/var/tmp/zip/php_zip.c:672: error: (Each undeclared identifier is reported only once
/var/tmp/zip/php_zip.c:672: error: for each function it appears in.)
/var/tmp/zip/php_zip.c:672: error: ‘re’ undeclared (first use in this function)
/var/tmp/zip/php_zip.c:673: error: ‘pcre_extra’ undeclared (first use in this function)
make: *** [php_zip.lo] Error 1
ERROR: `make' failed

編輯

現在這些傢伙(http://www.linuxquestions.org/questions/linux-software-2/install-zip-extension-using-pear-840755/)說

# yum install pcre-devel

這對我來說不太適用,但是

# yum install COMPANY-pcre-devel

工作正常

# pear install zip-1.12.4.tgz 

同樣犯錯誤。

編輯

http://www.linuxquestions.org/questions/red-hat-31/rpm-error-cannot-create-sourcedir-165733/ http://rpm.pbone.net/index.php3/stat/26/dist /55/size/571124/name/pcre-6.6-2.el5_1.7.src.rpm

# yum install rpm-build
# rpmbuild --rebuild pcre-6.6-2.el5_1.7.src.rpm  # manually downloaded this exact version of the rpm
TONS of output, but the tests all passed, so it seems to have worked...
# cd /usr/src/redhat/RPMS/x86_64
# rpm -ivh pcre-devel-6.6-2.7.x86_64.rpm 
# yum list installed | grep pcre
pcre.x86_64                                  6.6-2.7                   installed
pcre-devel.x86_64

                       6.6-2.7                   installed

繁榮!另一個依賴下降。

# cd dir/to/manually/uploaded/zip.tgz
# pear install zip-1.12.4.tgz 

Build process completed successfully
Installing '/usr/lib/php/20090626/zip.so'
install ok: channel://pecl.php.net/zip-1.12.4
configuration option "php_ini" is not set to php.ini location
You should add "extension=zip.so" to php.ini

是的先生。

# vi /etc/php.ini
add extension=zip.so
  • 無法從我的伺服器訪問 pecl 伺服器,因此請從http://pecl.php.net/package/zip下載 tarball並手動將其放在伺服器上
  • yum install zlib-devel
  • yum install pcre-devel對我不起作用,所以我不得不去 http://rpm.pbone.net/index.php3/stat/26/dist/55/size/571124/name/pcre-6.6-2.el5_1.7 .src.rpm 以獲取我的 depsolving 錯誤中列出的確切 RPM 版本。
  • yum install rpm-build
  • scp pcre-6.6-2.el5_1.7.src.rpm到我的伺服器
  • rpmbuild --rebuild pcre-6.6-2.el5_1.7.src.rpm
  • cd /usr/src/redhat/RPMS/x86_64
  • rpm -ivh pcre-devel-6.6-2.7.x86_64.rpm
  • yum list installed | grep pcre看看它是否有效
  • cd dir/to/manually/uploaded/zip.tgz
  • pear install zip-1.12.4.tgz
  • vi /etc/php.ini
  • 添加extension=zip.so到 php.ini

完整的詳細資訊和引用的所有頁面都在上面的描述和編輯中。

引用自:https://unix.stackexchange.com/questions/114821