Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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());'
    [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/ or /usr/lib/ 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:

share|improve this question

closed as off topic by Michael Hampton, Khaled, mgorven, mdpc, EEAA Feb 27 '13 at 2:45

Questions on Server Fault are expected to relate to server, networking, or related infrastructure administration within the scope defined by the community. Consider editing the question or leaving comments for improvement if you believe the question can be reworded to fit within the scope. Read more about reopening questions here.If this question can be reworded to fit the rules in the help center, please edit the question.

If I use --with-jpeg-dir=/usr/lib/ it outputs a rather more promising checking for the location of libjpeg... /usr/local/lib/. But then it still doesn't list JPEG support in the output of php -r 'print_r(gd_info());'. – Robin Winslow Aug 23 '11 at 21:18
Try it wih --with-jpeg-dir=/usr. I think autoconf looks in lib/ within the specified directory. – SmallClanger Aug 23 '11 at 22:00
Tried that. Didn't work. Similar my above comment, it said location of libjpeg... /usr but didn't lead to JPEG support. – Robin Winslow Aug 23 '11 at 22:15
This was the solution. I set --with-jpeg-dir=/usr/local/ and now it works! Please post this solution as an answer and I'll accept it. – Robin Winslow Aug 23 '11 at 23:43
How odd. Perhaps the idea is to distract autoconf by making it look in usr/local/ whilst quietly slipping the correct lib into its pocket. :) Still, I couldn't possibly accept this answer, since mine was wrong. Feel free to post your own solution and accept it, though, so that other in the same position will find it. – SmallClanger Aug 24 '11 at 8:06

you need libjpeg-devel too if you are COMPILING your own php and extensions

yum install libjpeg-devel

you need all the -devel equivalents for libraries that you are going to link and use (curl-devel, zlib-devel, gmp-devel, etc)

share|improve this answer
up vote 1 down vote accepted

I set --with-jpeg-dir=/usr/local/ and it worked! It appears to add the lib itself.

share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.