我自己编译 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
就是所需的,但我提供了正确的库目录(--with-jpeg-dir=/usr/lib/
),但它并没有识别它们,所以我猜它们可能不是正确的版本。
rpm
显示已安装libjpeg。我应该使用yum remove
命令卸载并重新安装它及其依赖包吗?这样会解决问题吗?
这里有一个paste bin,其中包含一些有用的系统信息:http://pastebin.com/ied0kPR6
很抱歉与Server Fault的交叉发布(https://serverfault.com/q/304310/92291),尽管我试图了解Stack Exchange对交叉发布的立场,但并不清楚:https://meta.stackexchange.com/q/75326/167958。
--with-somelib=/usr
而不是...=/usr/lib
,因为配置测试是写成providedpath + '/lib/'
而不仅仅是providedpath
。你可能需要深入挖掘配置测试套件,找出真正所需的内容。 - Marc B--with-jpeg-dir=/usr
。它输出了checking for the location of libjpeg... /usr
,但仍然没有JPEG支持。我无法确定在哪里查看配置脚本的课程代码 - 你知道我可以在哪里找到吗? - Robin Winslow--with-jpeg-dir=/usr/local/
,现在它可以工作了!请将此解决方案发布为答案,我会接受它。 - Robin Winslow