21

我编译自己的 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

尽管我试图了解 Stack Exchange 在交叉发布方面的立场,但并不清楚:https : //meta. stackexchange.com/q/75326/167958

4

3 回答 3

20

按照要求:

有时配置脚本很笨,你必须使用 --with-somelib=/usr 而不是 ...=/usr/lib,因为配置测试是写成 providedpath + '/lib/' 而不是内部提供的路径. 您可能不得不在配置测试套件中四处挖掘以找出真正需要的内容

于 2011-09-14T17:25:50.983 回答
15

不要忘记做一个

make clean

配置后。

我之前做了一些其他配置和制作,旧的安装阻止我在 GD 上启用 jpeg 支持。

它为我节省了 ubuntu 12.04 64bits

我也使用过这些包:

aptitude install libjpeg62-dev libpng-dev libfreetype6-dev

使用此配置选项:

./configure \
  --with-config-file-path=/usr/local/apache2/conf \
  --with-jpeg-dir \
  --with-png-dir \
  --with-vpx-dir \
  --with-freetype-dir \
  --enable-apc \
  --enable-bcmath \
  --enable-calendar \
  --enable-dba \
  --enable-exif \
  --enable-ftp \
  --enable-mbstring \
  --enable-shmop \
  --enable-sigchild \
  --enable-soap \
  --enable-sockets \
  --enable-sysvmsg \
  --enable-zip \
  --enable-gd-native-ttf  \
  --with-gd \
  --with-apxs2=/usr/local/httpd/bin/apxs \
  --with-bz2 \
  --with-curl \
  --with-gettext \
  --with-mcrypt \
  --with-mysql-sock=/var/run/mysqld/mysqld.sock \
  --with-openssl \
  --with-pdo-mysql \
  --with-xmlrpc \
  --with-zlib

进而 :

make clean
make
make install

在 Apache 2.4.3 和 PHP 5.4.11 上运行良好

于 2013-02-16T14:55:24.707 回答
1

您很可能需要安装 libjpeg 的开发版本,而不是运行时版本(当然,编译后将需要运行时版本)。

我自己不使用 CentOS,但这样的事情应该会有所帮助:

rpm install libjpeg-devel

我可能有错误的包名称,但寻找带有-dev-devel后缀的东西。

于 2011-08-23T21:39:52.710 回答