使用 GD 和 libjpeg 支持编译 PHP
我编译自己的 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删除
并重新安装它及其所有依赖包吗?这可以解决问题吗?
这是一个粘贴箱,其中包含希望有用的系统信息的集合:
http://pastebin.com/ied0kPR6
因服务器故障交叉发布而致歉(https://serverfault.com/q/304310/92291 )虽然我试图发现 Stack Exchange 的关于交叉发布的立场尚不清楚: https://meta.stackexchange.com/q/75326/167958
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.
My problem is that I can't get JPEG support in PHP. Using CentOS 5.6. Here are my configuration options when compiling 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:
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:
# 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. 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.
rpm
says libjpeg is installed. Should I yum remove
and reinstall it, and all it's dependent packages? Might that fix the problem?
Here's a paste bin with a collection of hopefully useful system information:
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
根据要求:
有时配置脚本很愚蠢,您必须执行 --with-somelib=/usr 而不是 ...=/usr/lib,因为配置测试被编写为providedpath + '/lib/' 而不是只是在内部提供了路径。您可能需要深入研究配置测试套件以找出真正需要什么
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. You may have to dig around inside the configure test suite to find out what's really required
不要忘记执行
make clean
配置后
。我之前已经进行了一些其他配置和 make,旧的安装阻止我在 GD 上启用 jpeg 支持。
它节省了我在 ubuntu 12.04 64 位上的时间
我还使用了这些软件包:
使用此配置选项:
然后:
与 Apache 2.4.3 和 PHP 5.4.11 一起运行良好
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.
It saves me on ubuntu 12.04 64bits
I've also use these packages :
with this configure options:
and then :
Run good with Apache 2.4.3 and PHP 5.4.11
您很可能需要安装 libjpeg 的开发版本,而不是运行时版本(当然,编译后将需要运行时版本)。
我自己不使用 CentOS,但是这样的东西应该会有所帮助:
我可能有错误的包名称,但是寻找带有
-dev
或-devel
后缀的东西。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).
I don't use CentOS myself, but something like this should help:
I might have the package name wrong, but look for something with a
-dev
or-devel
postfix.