使用GD和libjpeg支持编译PHP

Rob*_*low 19 php gd compilation centos libjpeg

我编译自己的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/'
Run Code Online (Sandbox Code Playgroud)

./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
Run Code Online (Sandbox Code Playgroud)

然后我们可以看到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] =>
)
Run Code Online (Sandbox Code Playgroud)

我知道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://serverfault.com/q/304310/92291)进行交叉发布表示歉意:https:// meta. stackexchange.com/q/75326/167958

Mar*_*c B 18

按照要求:

有时配置脚本是愚蠢的,你必须做--with-somelib =/usr而不是... =/usr/lib,因为配置测试被写为providepath +'/ lib /'而不是仅仅是在内部提供路径.您可能需要在配置测试套件内部进行挖掘,以找出真正需要的内容

  • 对于CentOS 7上的PHP 7,神奇的咒语是:` - with-gd --with-jpeg-dir =/usr/lib64` (3认同)

小智 15

别忘了做一个

make clean

配置完成后

我已经做了一些其他配置并且之前做过,旧安装阻止我在GD上启用了jpeg支持.

它节省了我在ubuntu 12.04 64位上

我也使用这些包:

aptitude install libjpeg62-dev libpng-dev libfreetype6-dev
Run Code Online (Sandbox Code Playgroud)

使用此配置选项:

./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
Run Code Online (Sandbox Code Playgroud)

然后 :

make clean
make
make install
Run Code Online (Sandbox Code Playgroud)

适用于Apache 2.4.3和PHP 5.4.11