Php

使用 GD 和 libjpeg 支持編譯 PHP

  • February 25, 2013

我編譯自己的 PHP,部分是為了了解更多關於 PHP 是如何組合在一起的,部分是因為我總是發現我需要預設情況下不可用的模組,而通過這種方式我可以控制它。

我的問題是我無法在 PHP 中獲得 JPEG 支持。使用 CentOS 5.6。以下是我在編譯PHP 5.3.8時的配置選項:

'./configure'  '--enable-fpm' '--enable-mbstring' '--with-mysql' '--with-mysqli' '--with-gd' '--with-curl' '--with-mcrypt' '--with-zlib' '--with-pear' '--with-gmp' '--with-xsl' '--enable-zip' '--disable-fileinfo' '--with-jpeg-dir=/usr/lib/'

./configure輸出說:

checking for GD support... yes
checking for the location of libjpeg... no
checking for the location of libpng... no
checking for the location of libXpm... no

然後我們可以看到 GD 已安裝,但不存在 JPEG 支持:

# php -r 'print_r(gd_info());'
Array
(
   [GD Version] => bundled (2.0.34 compatible)
   [FreeType Support] =>
   [T1Lib Support] =>
   [GIF Read Support] => 1
   [GIF Create Support] => 1
   [JPEG Support] =>
   [PNG Support] => 1
   [WBMP Support] => 1
   [XPM Support] =>
   [XBM Support] => 1
   [JIS-mapped Japanese Font Support] =>
)

我知道 PHP 需要能夠找到 libjpeg,而且它顯然找不到它滿意的版本。我會想到/usr/lib/libjpeg.so或者/usr/lib/libjpeg.so.62會是它需要的東西,但是我為它提供了正確的 lib 目錄(--with-jpeg-dir=/usr/lib/)並且它沒有選擇它們,所以我猜它們不可能是正確的版本。

rpm說 libjpeg 已安裝。我應該yum remove重新安裝它,以及它的所有依賴包嗎?這能解決問題嗎?

這是一個帶有希望有用的系統資訊集合的粘貼箱:http:

//pastebin.com/ied0kPR6

我設置--with-jpeg-dir=/usr/local/並成功了!它似乎添加了lib自身。

如果你正在編譯自己的 php 和擴展,你也需要 libjpeg-devel

yum install libjpeg-devel

您需要所有要連結和使用的庫的 -devel 等效項(curl-devel、zlib-devel、gmp-devel 等)

引用自:https://serverfault.com/questions/304310