简体   繁体   English

使用GD和libjpeg支持编译PHP

[英]Compiling PHP with GD and libjpeg support

I compile my own PHP, partly to learn more about how PHP is put together, and partly because I'm always finding I need modules that aren't available by default, and this way I have control over that. 我编译自己的PHP,部分是为了更多地了解PHP如何组合在一起,部分是因为我总是发现我需要默认情况下不可用的模块,这样我就可以控制它。

My problem is that I can't get JPEG support in PHP. 我的问题是我无法在PHP中获得JPEG支持。 Using CentOS 5.6. 使用CentOS 5.6。 Here are my configuration options when compiling PHP 5.3.8 : 以下是编译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/'

The ./configure output says: ./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

And then we can see that GD is installed, but that JPEG support isn't there: 然后我们可以看到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] =>
)

I know that PHP needs to be able to find libjpeg, and it obviously can't find a version it's happy with. 我知道PHP需要能够找到libjpeg,它显然找不到它满意的版本。 I would have thought /usr/lib/libjpeg.so or /usr/lib/libjpeg.so.62 would be what it needs, but I supplied it with the correct lib directory ( --with-jpeg-dir=/usr/lib/ ) and it doesn't pick them up so I guess they can't be the right versions. 我原以为/usr/lib/libjpeg.so/usr/lib/libjpeg.so.62会是它需要的东西,但我提供了正确的lib目录( --with-jpeg-dir=/usr/lib/ )它并没有接收它们,所以我猜它们不是正确的版本。

rpm says libjpeg is installed. rpm表示安装了libjpeg。 Should I yum remove and reinstall it, and all it's dependent packages? 我应该yum remove并重新安装它,以及它所有依赖的软件包吗? Might that fix the problem? 可能解决问题吗?

Here's a paste bin with a collection of hopefully useful system information: 这是一个粘贴框,其中包含一组希望有用的系统信息:
http://pastebin.com/ied0kPR6 http://pastebin.com/ied0kPR6

Apologies for cross-posting with Server Fault ( https://serverfault.com/q/304310/92291 ) although I tried to discover what Stack Exchange's position on cross-posting was and it wasn't clear: https://meta.stackexchange.com/q/75326/167958 虽然我试图发现Stack Exchange在交叉发布上的立场是什么并且不清楚,但是为了与服务器故障( https://serverfault.com/q/304310/92291 )进行交叉发布而道歉: https:// meta。 stackexchange.com/q/75326/167958

as requested: 按照要求:

Sometimes the configure script is dumb, and you have to do --with-somelib=/usr instead of ...=/usr/lib, because the config test is written as providedpath + '/lib/' rather than just providedpath internally. 有时配置脚本是愚蠢的,你必须做--with-somelib = / usr而不是... = / usr / lib,因为配置测试被写为providepath +'/ lib /'而不是内部提供的路径。 You may have to dig around inside the configure test suite to find out what's really required 您可能需要在配置测试套件内部进行挖掘,以找出真正需要的内容

Don't forget to do a 别忘了做一个

make clean

after you configure. 配置完成后

I've got make some other configuration and make before and the old installation prevent me to got the jpeg support enabled on GD. 我已经做了一些其他配置并且之前做过,旧的安装阻止我在GD上启用了jpeg支持。

It saves me on ubuntu 12.04 64bits 它节省了我在ubuntu 12.04 64位上

I've also use these packages : 我也使用这些包:

aptitude install libjpeg62-dev libpng-dev libfreetype6-dev

with this configure options: 使用此配置选项:

./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

and then : 然后 :

make clean
make
make install

Run good with Apache 2.4.3 and PHP 5.4.11 适用于Apache 2.4.3和PHP 5.4.11

You most probably need to install the development version, not the run-time version, of libjpeg (of course, the run-time version will be needed once you've compiled). 您最有可能需要安装libjpeg的开发版本而不是运行时版本(当然,编译后将需要运行时版本)。

I don't use CentOS myself, but something like this should help: 我自己不使用CentOS,但这样的事情应该会有所帮助:

rpm install libjpeg-devel

I might have the package name wrong, but look for something with a -dev or -devel postfix. 我可能有错误的包名称,但寻找带-dev-devel后缀的东西。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM