title: Compiling PHP with GD and libjpeg support
body: <p>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.</p>
  
  <p>My problem is that I can't get JPEG support in PHP. Using CentOS 5.6. Here are my configuration options when compiling <a href="http://www.php.net/get/php-5.3.8.tar.gz/from/a/mirror" rel="noreferrer">PHP 5.3.8</a>:</p>
  
  <pre><code> './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/'
  </code></pre>
  
  <p>The <code>./configure</code> output says:</p>
  
  <pre><code>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
  </code></pre>
  
  <p>And then we can see that GD is installed, but that JPEG support isn't there:</p>
  
  <pre><code># php -r 'print_r(gd_info());'
  Array
  (
      [GD Version] =&gt; bundled (2.0.34 compatible)
      [FreeType Support] =&gt;
      [T1Lib Support] =&gt;
      [GIF Read Support] =&gt; 1
      [GIF Create Support] =&gt; 1
      [JPEG Support] =&gt;
      [PNG Support] =&gt; 1
      [WBMP Support] =&gt; 1
      [XPM Support] =&gt;
      [XBM Support] =&gt; 1
      [JIS-mapped Japanese Font Support] =&gt;
  )
  </code></pre>
  
  <p>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 <code>/usr/lib/libjpeg.so</code> or <code>/usr/lib/libjpeg.so.62</code> would be what it needs, but I supplied it with the correct lib directory (<code>--with-jpeg-dir=/usr/lib/</code>) and it doesn't pick them up so I guess they can't be the right versions.</p>
  
  <p><code>rpm</code> says libjpeg is installed. Should I <code>yum remove</code> and reinstall it, and all it's dependent packages? Might that fix the problem?</p>
  
  <p>Here's a paste bin with a collection of hopefully useful system information:<br>
  <a href="http://pastebin.com/ied0kPR6" rel="noreferrer">http://pastebin.com/ied0kPR6</a></p>
  
  <p>Apologies for cross-posting with Server Fault ( <a href="https://serverfault.com/q/304310/92291">https://serverfault.com/q/304310/92291</a> ) although I tried to discover what Stack Exchange's position on cross-posting was and it wasn't clear: <a href="https://meta.stackexchange.com/q/75326/167958">https://meta.stackexchange.com/q/75326/167958</a></p>