編譯安裝php 5.5 缺少依賴包 及解決方案


必要時可以用 YUM 選擇安裝以下相關軟件包:

#yum install gcc gcc-c++ autoconf libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel libidn libidn-devel openssl openssl-devel openldap openldap-devel nss-ldap openldap-clients openldap-servers bison bison-devel readline readline-devel libmcrypt libmcrypt-devel net-snmp-devel libXpm* libxml2 libxml2-devel patch

一、安裝相關依賴包(即支持庫)

1、libiconv (對文本進行編碼間的轉換,用它來處理中文各種編碼之間的轉換)

[root@test lnmp]# tar -xzf libiconv-1.14.tar.gz

[root@test lnmp]# cd libiconv-1.14

[root@test libiconv-1.14]# ./configure

[root@test libiconv-1.14]# make && make install

2、libmcrypt (實現加密功能的庫)

[root@test lnmp]# tar -xzf libmcrypt-2.5.8.tar.gz

[root@test lnmp]# cd libmcrypt-2.5.8

[root@test libmcrypt-2.5.8]# ./configure

[root@test libmcrypt-2.5.8]# make && make install

[root@test libmcrypt-2.5.8]# cd libltdl/

[root@test libltdl]# ./configure --enable-ltdl-install

[root@test libltdl]# make && make install

3、mhash (哈稀函數庫)

[root@test lnmp]# tar xjf mhash-0.9.9.9.tar.bz2

[root@test lnmp]# cd mhash-0.9.9.9

[root@test mhash-0.9.9.9]# ./configure

[root@test mhash-0.9.9.9]# make && make install

[root@test mhash-0.9.9.9]# ln -s /usr/local/lib/libmcrypt.la /usr/lib/libmcrypt.la

[root@test mhash-0.9.9.9]# ln -s /usr/local/lib/libmcrypt.so /usr/lib/libmcrypt.so

[root@test mhash-0.9.9.9]# ln -s /usr/local/lib/libmcrypt.so.4 /usr/lib/libmcrypt.so.4

[root@test mhash-0.9.9.9]# ln -s /usr/local/lib/libmcrypt.so.4.4.8 /usr/libmcrypt.so.4.4.8

[root@test mhash-0.9.9.9]# ln -s /usr/local/lib/libmhash.a /usr/lib/libmhash.a

[root@test mhash-0.9.9.9]# ln -s /usr/local/lib/libmhash.la /usr/lib/libmhash.la

[root@test mhash-0.9.9.9]# ln -s /usr/local/lib/libmhash.so /usr/lib/libmhash.so

[root@test mhash-0.9.9.9]# ln -s /usr/local/lib/libmhash.so.2 /usr/lib/libmhash.so.2

[root@test mhash-0.9.9.9]# ln -s /usr/local/lib/libmhash.so.2.0.1 /usr/lib/libmhash.so.2.0.1

[root@test mhash-0.9.9.9]# ldconfig  #不重新加模塊,下面編譯 mcrypt 時,檢查編譯環境會出錯。

-----------------------------------------------------------------------------------------------------------------------------------------

在#./configure 檢查 php 編譯環境時可能會出現以下錯誤。

checking whether mhash >= 0.8.15... no

configure: error: "You need at least libmhash 0.8.15 to compile this program. http://mhash.sf.net/"

原因:

mhash編譯默認安裝路徑是 /usr/local/,相關庫在 /usr/local/lib 下。而 php 只搜索 /usr/lib/ 這個位置。所以會出現找不到 mhash 相關庫的情況。

解決方法:

通過軟鏈接的方法把 /usr/local/lib 目錄下的 mhash 相關的庫文件鏈接到 /usr/lib/ 目錄下。

-----------------------------------------------------------------------------------------------------------------------------------------

4、mcrypt

[root@test lnmp]# tar -xzf mcrypt-2.6.8.tar.gz

[root@test lnmp]# cd mcrypt-2.6.8

[root@test mcrypt-2.6.8]# ./configure

[root@test mcrypt-2.6.8]# make && make install

二、源碼安裝 php(FastCGI 模式)

PHP-FPM 是 一個 PHP FastCGI 進程管理器,即 PHP FastCGI Progress Manager。

FastCGI 是一個可伸縮的,高速地在 web server 和腳本語言間交互的接口。FastCGI 的主要優點是把動態語言和 web server 分離開來。這種技術允許把 web server 和動態語言運行在不同的主機上,以大規模擴展和改進安全性而不損失生產效率。

php-fpm 可以和任何支持遠端 FastCGI 的 web server 工作。

在 php-5.3.3 版本之后,php-fpm 已經被包含在 core 里邊了,不再是第三方的包了。不需要再打補丁了。

PHP-FPM 提供了更好的 PHP 進程管理方式,可以有效控制內存和進程、可以平滑重載 PHP 配置,比 spawn-fcgi 具有更多有點,所以被 PHP 官方收錄了。在 ./configure 的時候帶 -–enable-fpm 參數即可開啟 PHP-FPM。

1、安裝 php

[root@test lnmp]# mkdir /usr/local/php

[root@test lnmp]# tar -xzf php-5.4.4.tar.gz

[root@test lnmp]# cd php-5.4.4

[root@test php-5.4.4]# ./configure --prefix=/usr/local/php \

--with-config-file-path=/usr/local/php/etc \

--with-mysql=/usr/local/mysql/ \

--with-mysqli=/usr/local/mysql/bin/mysql_config \

--with-iconv-dir=/usr/local \

--with-freetype-dir \

--with-jpeg-dir \

--with-png-dir \

--with-zlib \

--with-gd \

--with-libxml-dir=/usr \

--enable-xml \

--disable-rpath \

--enable-bcmath \

--enable-shmop \

--enable-sysvsem \

--enable-inline-optimization \

--with-curl \

--with-curlwrappers \

--enable-mbregex \

--enable-fpm \

--with-pdo-mysql=/usr/local/mysql \ #可選參數,如果這里指定了,在安裝pdo_mysql時就不用指定了。

--enable-mbstring \

--with-mcrypt \

--enable-gd-native-ttf \

--with-openssl \

--with-mhash \

--enable-pcntl \

--enable-sockets \

--with-xmlrpc \

--enable-zip \

--enable-soap \

--without-pear

[root@test php-5.4.4]# make ZEND_EXTRA_LIBS='-liconv'

[root@test php-5.4.4]# make install

configure 代碼如下:

-----------------------------------------------------------------------------------------------------------------------------------------

./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --with-mysql=/usr/local/mysql/ --with-mysqli=/usr/local/mysql/bin/mysql_config --with-iconv-dir=/usr/local --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-gd --with-libxml-dir=/usr --enable-xml --disable-rpath --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --with-curlwrappers --enable-mbregex --enable-fpm --with-pdo-mysql=/usr/local/mysql --enable-mbstring --with-mcrypt --enable-gd-native-ttf --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-zip --enable-soap --without-pear

-----------------------------------------------------------------------------------------------------------------------------------------

可能出現的錯誤:

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

解決方法:

http://www.xmlsoft.org/

源碼安裝 libxml2 或通過 yum 安裝 libxml2-devel。

(1)[root@test lnmp]# tar -xzf libxml2-tests-2.8.0.tar.gz

(2)[root@test lnmp]#yum install  libxml2-devel

2、 configure: error: Please reinstall the libcurl distribution -

    easy.h should be in <curl-dir>/include/curl/

解決方法:

http://curl.haxx.se/

源碼安裝 curl 或通過 yum 安裝 libcurl-devel。

(1)[root@test lnmp]# tar -xzf curl-7.26.0.tar.gz

(2)[root@test lnmp]#yum install libcurl-devel

3、configure: error: jpeglib.h not found.

解決方法:

http://www.ijg.org/

源碼安裝 jpegsrc 或通過 yum 安裝 libjpeg-devel。

(1)[root@test lnmp]# tar -xzf jpegsrc.v8d.tar.gz

(2)[root@test lnmp]#yum install libjpeg-devel

4、configure: error: png.h not found.

解決方法:

http://www.libpng.org/pub/png/libpng.html

源碼安裝 libpng 或通過 yum 安裝 libpng-devel。

(1)[root@test lnmp]# tar -xzf libpng-1.5.12.tar.gz

(2)[root@test lnmp]#yum install libpng-devel

4、configure: error: freetype.h not found.

解決方法:

http://www.freetype.org/

源碼安裝 freetype 或通過 yum 安裝 libfreetype-devel。

(1)[root@test lnmp]# tar -xzf freetype-2.4.10.tar.gz

(2)[root@test lnmp]#yum install libfreetype-devel

編譯的時候可能出現的錯誤:

5、Generating phar.php

/data1/lnmp/php-5.4.4/sapi/cli/php: error while loading shared libraries: libmysqlclient.so.18: cannot open shared object file: No such file or directory

make: *** [ext/phar/phar.php] Error 127

解決方法:

#echo "/usr/local/mysql/lib/" &gt;&gt; /etc/ld.so.conf.d/mysql-x86_64.conf

6、PEAR package PHP_Archive not installed: generated phar will require PHP's phar extension be enabled.

兩種解決方法:

(1)#./configure --without-pear

(2)#wget http://pear.php.net/go-pear.phar

    #php go-pear.phar

7、configure: WARNING: unrecognized options: --enable-discard-path, --enable-safe-mode

警告原因:

之前 php-5.3.x 編譯時加了 --enable-safe-mode --enable-discard-path --enable-fastcgi --enable-force-cgi-redirect選項,但是這個選項沒必要,且會帶來許多的麻煩,詳解可以 google 一下,php-5.4.x 已經去掉了該選項,編譯時可以 #./configure --help | grep “safe-mode” 查看一下,沒有信息輸出,表示已經不支持!

-----------------------------------------------------------------------------------------------------------------------------------------

2、建立相關配置文件

[root@test php-5.4.4]# cp php.ini-production /usr/local/php/etc/php.ini

[root@test php-5.4.4]# vim /etc/profile

找到 export PATH=$PATH:/usr/local/mysql/bin 這一行,

修改為:export PATH=$PATH:/usr/local/mysql/bin:/usr/local/php/bin:/usr/local/php/sbin:

[root@test php-5.4.4]# source /etc/profile

 

 

 

最終 能實現的 參數,  比如msyql-config  ,還有 加密 encpty 等  不是很好找, 先減少這兩個參數  安裝完畢后,用到時再想辦法!

./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --with-mysql=/usr/local/mysql --with-mysqli --with-iconv-dir=/usr/local --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml --disable-rpath  --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl  --enable-mbregex  --enable-fpm  --enable-mbstring  --with-gd --enable-gd-native-ttf --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-ldap --with-ldap-sasl --with-xmlrpc --enable-zip --enable-soap --without-pear --with-zlib --enable-pdo --with-pdo-mysql --with-mysql --with-apxs2=/usr/local/apache/bin/apxs


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM