Closed (outdated)
Project:
Documentation
Component:
Correction/Clarification
Priority:
Normal
Category:
Task
Assigned:
Issue tags:
Reporter:
Created:
10 Aug 2010 at 12:00 UTC
Updated:
4 Apr 2017 at 11:13 UTC
Jump to comment: Most recent
Getting the right GD library on any distribution is not that easy. Let's try to explain the basics of how to do it for Drupal 7.
Ubuntu and Windows: http://drupal.org/node/256876 (see subpages)
CentOS: http://drupal.org/node/327731
Since this is such a common problem it would be nice to get a standard solution for people.
Note that Ubuntu 10.04 works "out of the box" and it's PHP 5.3.
Comments
Comment #1
rfayOne approach to Debian (not tested in this context)
New /etc/apt/sources.list:
apt-get update
apt-get install php5-gd
(or perhaps apt-get install apache2 mysql-server php5 libapache2-mod-php5 php5-xsl php5-gd php-pear libapache2-mod-auth-mysql php5-mysql mysql-query-browser php5-curl php5-memcache)
This is the approach we use the the testbots on Debian 5/php 5.3.
Comment #2
mgiffordSubscribe. Will have to find time to test this.
Comment #3
steve.m commentedNote that php5-gd is available in the 'main' repos, so it's not necessary to include contrib and non-free.
Also, the version of GD that is installed with php5-gd on Debian still causes Drupal to throw errors because it's not the same GD library as included with mainstream PHP and is missing some features. (The Debian package maintainers take issue with how the PHP team is treating the GD library: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=321237)
Looks like the only way to get rid of those errors is to actually recompile PHP:
http://cumu.li/2008/5/13/recompiling-php5-with-bundled-support-for-gd-on...
Comment #4
rfay@steve.m, this issue is about the problem you describe, and documenting how to resolve it. The links in the above explain workarounds.
Changing title to make it clearer.
Comment #5
mgiffordDrupal should never be asking an administrator to recompile PHP. Yikes.
Comment #6
steve.m commentedAha, cool. I just wanted to point out that the apt-get install of php5-gd does not in fact solve the problem.
Comment #7
thomasde commentedAny solution without recompile PHP?
Comment #8
rfayYes, the pages in #0 and #1 suggest how to do this on Ubuntu at least.
Comment #9
thomasde commentedohh, sorry, I mean Debian. Does Squeeze work without?
Comment #10
rfay#1 is a suggestion for Debian. If you haven't already, could you try it and report back?
Comment #11
arianek commentedadding tags
Comment #12
damien_vancouver commentedI perform the build from source step, the debian way, for each new PHP5 version. I'll take on writing a new page to document it properly for Debian, and expanding the existing the instructions for Ubuntu.
The following is a raw dump of my wiki documentation, in case people are curious how to do it before I get this converted to a proper docs page. These docs are for Debian 5.0 Lenny and I copied the steps from a blog post at: http://blog.pirsig.net/apiBlog/entry/compile_php5_gd. I tried to clarify the steps a bit more in my version (which I'll udpate shortly for the Drupal docs):
Debian Lenny: rebuild php with bundled gd
You have to redo this every PHP version upgrade (after each security update)
first make sure the dependancies are there:
sudo apt-get install apache2-prefork-dev build-essential debhelper fakerootNow change to the /usr/src dir, remove any old php5 stuff there:
become root ("sudo su", type your password if required), then:
Get the PHP5 source and dependencies:
Now cd to the php5 dir, it will be named slightly differently to match the version you downloaded, and edit debian/rules:
search for: --with-gd=shared,/usr and replace with just: --with-gd=shared. The edited line in debian/rules will then read:
Save debian/rules, and build the packages with:
(this takes a long time, at least half an hour on a fast machine)
Once done, you will find newly compiled PHP5 packages in /usr/src. One of these will be a php5-gd package that is built using the bundled library.
Install it and hold it so aptitude will not immediately "security update" it with the stock version. Again, change the exact version number here to match the version you just built, the 5.2.6.dfsg.1-1+lenny8_amd64 pat will be different!
It should output something like this:
Now mark it not to upgrade, both to dpkg and aptitude:
(this should prevent it from being overwritten the first time you run security updates, which you should check. Make sure it's not going to reinstall php5-gd as a security update, as the old one will show up as newer. It must be marked as "hold").
NOTE - you have to be careful accepting security updates, or you will clobber this version with a new one.
NOTE2 - if there is a security update for the rest of the php5 packages, you are probably going to have to repeat this entire process to generate a new, up to date php5-gd. We hold the php5 package as well as php5-gd so you don't get version mismatches between your main php5 and our custom php5-gd. The versions have to match exactly. So in short Don't update PHP5 ever without doing this whole procedure (on a test machine first, so you have the package built when you upgrade PHP5 on the other machines). Ctweb04 needs an i386 package so you have to just build on there.
Finally, restart apache:
look at a phpinfo page, under "gd" it should now say:
Enjoy your bundled php5-gd!
Comment #13
arianek commentedComment #14
damien_vancouver commentedNow that Debian Squeeze has been released, I must re-visit this again... Perhaps the procedure is different, or no longer necessary!
Comment #15
rfayI just took Debian Squeeze for a test run. If you're willing to run PHP 5.3, it seems to have no trouble on D6 out of the box.
D7 also seems to be fine and very happy with GD on all counts.
I recommend that we document for Squeeze and PHP 5.3. The majority (I think) of D6 contrib has adapted to 5.3 by this point, and core has been ready for some time.
If we have to document PHP 5.2 for Squeeze, an approach similar to http://www.randyfay.com/node/63 may work, but then we'll have the GD problems again unless we use dotdeb or something like it. As I remember, the dotdeb repos always solved this problem, but they moved on to PHP5.3 very fast.
Comment #16
skomorokh commentedBeyond recompiling the package is there any known and reliable PPA for an appropriate php5-gd on Lenny?
Forcing early migration to Squeeze is not an option nor is making PHP packages a manual affair.
Backports would be a good choice, except apparently there isn't one?
http://packages.debian.org/search?keywords=php5-gd&searchon=names&suite=...
Also, is there any way to disable status messages you don't care about? It is fully unimportant to this particular install (and many others, I imagine) if images can be desaturated or rotated. Some functions of GD are working fine and that suffices. But beyond editing core (and needing to reapply the edit every upgrade) I do not see how to prevent the status message. This makes the status system useless as I do not know if the continuously reported "one or more problems" are the one that I know is there or something new and important!
Comment #17
skomorokh commented(urk, dupe)
Comment #18
thsutton commentedI've encountered a number of issues with the stock Debian 6.0 ("squeeze") php5-gd package running D6 with imagecache and imagecache_actions. While ImageAPI doesn't complain any more, ImageCache presets including canvas and file type operations seem not to work very well or at all.
I'm rebuilding php5-gd as described above now and I'll see if that fixes the issues I've seen.
Comment #19
johnpitcairn commentedSub. Considering taking the plunge and upgrading to squeeze.
Comment #20
damien_vancouver commentedHey all,
On the one D7 site I'm building, the stock squeeze packages don't show an error under the status report. instead it says:
But... I assume Drupal 6 is still going to complain. I've also encountered other random problems in the wild hosting Drupal 6 sites on PHP 5.3... so aside from the gd problem, you may also have that larger problem to worry about with the upgrade.
(With Ubuntu you can use methods like http://www.randyfay.com/node/63 to install old LTS packages that are still supported and still PHP 5.2. AFAIK this isn't an option in Debian, and I'm not sure what all of us who depend on PHP 5.2 are going to do come Debian 5 EOL early next year... hopefully not resort to building PHP 5.2 from source.)
Anyway, I will attempt my #12 on my local squeeze server and post the updated procedure here!
Comment #21
damien_vancouver commentedHi guys, so my Debian Squeeze test went OK. Here are the updated instructions. There's an extra step now (editing the debian/setup-mysql.sh script as well as debian/rules) and also the end is slightly different. I've also added the steps I use each new PHP5 security update to upgrade my servers.
I hope this helps! Remember to test out other PHP 5.3 compatibility, or if possible back up/snapshot your server entirely before doing the squeeze upgrade. My first one ended in a very hurried rollback due to OpenAtrium and PHP 5.3 scrapping. I definitely do not recommend you upgrade a physical server to squeeze without first testing your sites somewhere to make sure they will work, because you will be in a world of pain and unable to easily roll back. And with that last word of caution: Good luck upgrading!!!
Debian Squeeze: rebuild php5 packages with bundled gd library, the "Debian Way"
Important Note: You have to redo this EVERY PHP version upgrade (after each security update). Yes I'm serious.
Important Warning: Please read this ENTIRE procedure before starting it. Please don't try it on your production server until you are sure you have it down and everything is going to work.
Prerequisites
First make sure the dependencies are there. You only need to do this once per machine:
Second, you need a phpinfo() page that shows you what version you have so you can see the change. If you don't have one of these, create a simple text file in your web root containing just:
and save it as "phpinfo.php" or something. Then verify you can load the page and see the PHP version page. It will list your "gd" version as just "2.0". It should not say "bundled" under the gd version.
Step 1 - remove old build files
Now remove any old php5 stuff from /usr/src (ie. files from last time you did this procedure):
become root ("sudo su", type your password if required), then:
Step 2 - download PHP5 source and build dependencies
Perform this with:
Step 3 - edit debian specific build files
Now cd to the php5 dir that has been created under /usr/src. It will be named slightly differently from my example to match the version you downloaded. Once inside that directory, edit debian/rules with pico, vi, emacs, or whatever your favourite editor is:
Inside debian/rules, search for: --with-gd=shared,/usr and replace with just: --with-gd=shared The edited line in debian/rules will then read:
Now Save debian/rules. You will still be in /usr/src/php-5.3.3
(New for Debian 6) - Edit debian/setup-mysql.sh to avoid an error during the test. Solution from http://subject9.wordpress.com/2011/04/23/tutorial-how-to-enable-php5s-im...
Search for: # Start the daemon and add --user=root right after $mysqld, so it looks like this:
Save the file and exit. You're now ready to build!
Step 4: Build the packages
Now Build the packages "the Debian Way" with:
It's going to build all 25 or so PHP packages (this takes a LONG time, at least half an hour on a fast machine), and should end with an error about not being able to sign the package (as we are not really the package maintainer so don't have his secret key):
Now you should find newly compiled PHP5 .deb packages in /usr/src. One of these will be a php5-gd package that is built using the bundled library.
Step 5: Install the package, then mark it as held for upgrades
You need to install it and THEN hold it so apt/aptitude will not immediately "security update" it with the stock version. Again, change the exact version number here to match the version you just built, the 5.3.3-7+squeeze3_amd64 part will be different!
It should output something like this:
Now mark it not to upgrade, both to dpkg and aptitude:
(this should prevent it from being overwritten the first time you run security updates, which you should check. Make sure it's not going to reinstall php5-gd as a security update, as the old one will show up as newer. It must be marked as "hold").
NOTE1 - you have to be careful accepting security updates, or you will clobber this version with a new one.
NOTE2 - if there is a security update for the rest of the php5 packages, you are going to have to repeat this entire process to generate a new, up to date php5-gd. You have to rebuild it every time.
NOTE3 - You can build the .deb file on one machine and then install it on several others. But you have to match up the architecture (amd64 vs. i386) and you also have to make sure you pay attention and don't install a php5-gd that is the wrong version compared to the rest of the php5 packages on the machine.
Restart Apache
Finally, restart apache:
look at your phpinfo page, under "gd" it should now say:
Enjoy your bundled php5-gd!
And remember not to security update it unless you are applying OTHER php5 security updates.
updating PHP5 with security upates
Here is the procedure I follow for each new PHP security update:
Comment #22
hansfn commented