39 Responses to “Recompiling PHP5 With Bundled Support for GD on Ubuntu”

  1. Donald Organ Says:

    couldnt your just do [code] sudo apt-get install php5-gd [/code]

  2. Markku Says:

    Donald,

    The apt-get method will NOT work if you want to have a BUNDLED version of GD. The bundled version comes with thingies like “imagerotate” which is missing from the apt-got library. I am currently compiling the library, fingers crossed

    Oh, and thanks, ant!

  3. Brandon Says:

    Awesome! I’ve been developing an application that relies heavily on imageconvolution and couldn’t get the thing to run on ubuntu in development. Your instructions worked great. One tip though, I had to enable the source code option in the synaptic package manager repository settings before I could download the php source code to compile it. Not a big hurdle, but it’s unchecked by default.

  4. silentdark Says:

    Thank you very, very much. I’ll see if it works as soon as my compiler runs trough.

  5. fdm391 Says:

    Thanks for the howto! but after compiling and installing the new version it’s not working anymore (php5-gd), which is a pity really.

    Solved the problem using the binary packages from dotdeb.org, works flawlessly.

  6. Nico Says:

    Thank you very much fpr sharing this! As soon as the compiler is ready I can test the result :) and can hopefully use the rotate function of my phoca gallery for joomla again…

  7. Mark Says:

    Great thanks for this tips.

    But, I have only one question. When I use apt-get update again, ubuntu will tell me the php-gd need update.

    How can I update others pakage but without this one?

    Regards, Mark

  8. zail Says:

    Thanks for the tips!

    2Mark: Just try ‘aptitude’ instead of ‘apt-get’. It’s much more smarter than traditional tools:

    ws1:/usr/src# aptitude hold php5-gd Reading package lists… Done Building dependency tree… Done Reading extended state information Initializing package states… Done Reading task descriptions… Done Building tag database… Done The following packages have been kept back: linux-image-2.6.18-6-686 php5-gd 0 packages upgraded, 0 newly installed, 0 to remove and 2 not upgraded. Need to get 0B of archives. After unpacking 0B will be used. Writing extended state information… Done

    As you can see, server is running custom built kernel image and libGD for PHP. They will not be upgraded with newer versions until you unhold them.

  9. Ace Frye Says:

    Dude, thank you so much for this!!

    Just a few things I have learned that other people might like to know…

    1. In a production environment with php already enabled… if you can manage taking the server offline for about 40 minutes then you can make this happen. Simply run “apt-get purge php5” first, then run what he has listed here. I know because I just did this.

    2. You must run “dpkg-buildpackage rfakeroot” IN THE php5-5.2.* DIRECTORY - otherwise it will error on you.

    3. In the end, if you want to install more than just the gd you CAN dpkg -i the “php5-gd_5.2.-etc…” file first AND THEN if you want to later you can dpkg -i the “php5_5.2._all…” file.

    Hope that helps & I also hope that last one makes sense.

    Take care & happy bashing! —Ace

  10. Ace Frye Says:

    Wow, so that parsed the code very weird. Please, disregard the fact that things are striked out or bolded. —Ace

    PS: Anthony, feel free to change my former comment so it does not parse so oddly & you can delete this comment too if you fix the other one. :-)

  11. Jaywalker Says:

    This is the best guide I have seen to solve this problem, and the only one I could make it work. So, thank you! :-)

  12. nigelbb Says:

    Thank you for this excellent guide. I just followed your instructions to the letter & it worked perfectly. I need the imageantialias function for a specific Joomla! component & this function is apparently not part of the GD library that works with PHP & Apache in any Ubuntu or Debian distribution.

  13. maxxx Says:

    thank you for this tutorial, it works perfect

  14. marc Says:

    Hello, and thank you, i have the same question as Mark (#7). “When I use apt-get update again, ubuntu will tell me the php5-gd need update. How can I update others pakage but without this one?”

    Can you help ? Thank you

  15. muruli Says:

    when i typed this dpkg -i php5-gd_5.2.3-1ubuntu6.3_i386.deb it showed php5-gd_5.2.3-1ubuntu6.3_i386.deb no file or dir where will it stored

  16. Marc-o Says:

    Another simple way to do it using compilation but maybe a bit dirty…

    http://info.momeunier.fr/node/20

    But I must say I like your way to do it :)

  17. Eldon Says:

    Another satisified customer! Worked perefctly.

    Thanks.

  18. Joe Says:

    still receiving the following error message:

    Fatal error: Call to undefined function imageantialias() in /var/www/admin/library/functions.php on line 231

    Any help would be greatly appreciated

  19. Joe Says:

    still receiving the following error message:

    Fatal error: Call to undefined function imageantialias() in /var/www/admin/library/functions.php on line 231

    Any help would be greatly appreciated

  20. Tiffoun Says:

    Hi, i am a happy guy. I am french, i have spent about 6 * 8 hours = 48 hours to search before to find ur “how to”. You can’t imagine how much pleasure u r giving me. So many ppl could use their GD in captchas, without problem, nobody understanding why i couldn’t… It is long story i have related at http://www.siteduzero.com/forum-83-356477-p1-ubuntu-probleme-avec-les-fichiers-png.html (in french sorry !) and… well, ur how to the only one i found explaining what u explain. Thanks again …LOL

  21. David Says:

    Nice Solution, especially when you like to do it the Debian/Ubuntu way!

    This Trick also works with Debian 4.0 (Etch)

  22. sam Says:

    after “apt-get build-dep php5”, it auto generated below files in /usr/src

    php5-5.2.6.dfsg.1 php5_5.2.6.dfsg.1-3ubuntu4.2.diff.gz php5_5.2.6.dfsg.1-3ubuntu4.2.dsc php5_5.2.6.dfsg.1.orig.tar.gz

    then

    cd php5-5.2.6.dfsg.1 dpkg-buildpackage -rfakeroot cd .. dpkg -i php5-gd_5.2.3-1ubuntu6.3_i386.deb

    No found any .deb files.

    any thoughts on this?

    thanks.

  23. br0n2 Says:

    You can solve problem without debian version of php and gdlib. Simply download and compile gd2 using a—prefix=/usr/local/gd2/ , and later download and compile compile php using—with-gd=/usr/local/gd2. Be carefull: do not use standard prefix otherwise php configure cannot find gd.h or gdlib.so ..

    I’ve just installed php5.2.3 + gdlib 2.0.35 and work perfectly.

  24. Noob Says:

    Hello there, nice Tut so far but a Noob like me still got some question: - I already installed PHP. Do I need to remove (purge) PHP before compiling on my own. (Think it’s a YES) - If so is there any list or something similar containig usefull informations/packages I should backup fist in order to reinstall them?

  25. daoudi Says:

    merci infini pour votre solution.

  26. Rauls Says:

    Thanks for great guide! Followed it and everything worked like a charm! :) The only question is – can I remove the original php5-gd package via aptitude (apt-get)? Does it change anything or can be freely removed? Thanks once more!

  27. Davide Says:

    Thanks, it helped me a lot!

  28. Matt Says:

    I ran through this with no luck.

    gd installs just fine—but it is the same gd with no filtering or rotation.

    I’m running Karmic— I have a feeling that the package that was downloaded when I ran through the instructions wasn’t different than what I got out of synaptic…

    In my sources.list “backports” and “partner” were commented out—

    But I’m not sure which needs uncommented or what…

  29. Matt (Again) Says:

    The package that gets built is named php5-gd_5.2.10.dfsg.1-2ubuntu6.1_i386.deb which is slightly different from the instructions… I’m not sure where I went wrong.

  30. geertv Says:

    Much kudos, Ant. Works like a charm !

    @Matt: No worries, when Ant wrote this posting, php was at version 5.2.3. But it still works for the current version (5.2.10)

    My package is even called differently than yours: php5_5.2.10.dfsg.1-2ubuntu6.1_all.deb

    I just did a

    dpkg -i *.deb

    and then a

    /etc/init.d/apache2 start

    and it works like a charm ! (at least imageantialias() I was depending on is working fine).

  31. cemkaan Says:

    after dpkg-buildpackage -rfakeroot nothing comes, it says: Build complete. Don’t forget to run ‘make test’. but it does not end and fall back to command line. last line says: mkdir -p temp_session_store env NO_INTERACTION=1 TEST_PHP_CGI_EXECUTABLE=./cgi-build/sapi/cgi/cgi-bin.php5 TEST_PHP_EXECUTABLE=./apache2-build/sapi/cli/php ./apache2-build/sapi/cli/php run-tests.php > test-results.txt

  32. cem kaan Says:

    thanks it worked fine until I did aptitude safe-upgrade . Now it turned back to orginal GD.

  33. GouMs Says:

    Thank you very much for this tutorial ! It works really nice !!

  34. Andy Says:

    @cemkaan: Same problem here.

  35. Andy Says:

    @cemkann:

    Just open another window and “tail” the test-results.txt file.

    tail -f test-results.txt

    It will show you what kind of test are running.

  36. гей знакомства сейчас Says:

    я считаю: превосходно…

  37. ganesh Says:

    I am getting the following warning message and the build is not completing,

    “Warning: PHP Startup: Unable to load dynamic library ’/usr/lib/php5/20060613+lfs/php_gd2.dll’ – /usr/lib/php5/20060613+lfs/php_gd2.dll: cannot open shared object file: No such file or directory in Unknown on line 0”

    Can u please help me ..

  38. Георгий Says:

    Пожалуй так оно и есть, на самом деле все очень просто :)

  39. John Says:

    Thank you for this! I have a site that really needs crisp fonts and since I switched to Ubuntu and stopped compiling LAMP from scratch my fonts have looked bad but the customer insisted on using packages. After installing the newly created GD package the fonts look good again, and I’ve learned a lot about Ubuntu.

    Thanks Again!

Leave a Reply ☆

Blog uses Mephisto
Design from OSWD
by dreamLogic