I decided I finally wanted to track down why I couldn’t get the thumbnails working on WordPress. I always get the message “File type not supported. Thumbnail not created.” even when the filetype is supported. I run a standard Debian stable system, with a backport of MySQL, so my first assumption was that it should work. A long weekend is a good chance to try to track down these things, especially when it’s raining as much as it is this weekend in Vancouver. Of course, I start at the WordPress support forums. This leads me to try apt-get install libgd2
; the thumbnails don’t work. As a next approximation, try apt-get install php4-gd2
; this also doesn’t work.
I dig a bit deeper in the forums and find that a newer version of PHP might solve the problem; the Debian stable version is 4.1.2 and a version > 4.3 is recommended as the GD library is included by default. The other advantage to upgrading PHP4 is that there are quite a few security holes fixed in version 4.3.9 and up; these may have been backported to 4.1.2, of course. So I look in backports.org because I already know how to use those; no newer version of php4 there. Next I try dotdeb.org; this backport site has a newer version of PHP4 and a newer version of MySQL. I add the magic line deb http://packages.dotdeb.org ./
to the /etc/apt/sources.list
file. I also change the pin priority in the preferences file to use dotdeb.org rather than backports.org. This upgrades my MySQL to dotdeb’s 4.0 version nicely, but doesn’t touch the PHP4 installation. Seems odd to me since they should both be upgraded in the same way, I would have thought. Edd Dumbill (Debian guru) gives me a couple of other things to try in the preferences file; nothing seems capable of raising the priority of the dotdeb php4 install over the current stable installed version. Edd suggests installing each .deb
by brute force; that breaks on unmet dependencies.
So I think about installing the unstable version of PHP4; maybe that will work better. I set up the pin priorities in the preferences
file, and use apt-get -t unstable install php4
. It threatens to install lots of things, so I decide to install a little at a time and make sure nothing breaks, or at least ensure I know what has broken if it does. First off, I make backups of httpd.conf
, access.conf
, the firewall script, and the PPPOE settings. Just in case. Not that I’m paranoid or anything.
- I install the unstable version of
libexpat1
; this installslibc6
and talks about having to restart the X11 server. Since I’m not running X, this isn’t a problem. Then it decides it also needs to restart apache but the restart fails so I have to start apache by hand. For a while it looks like that failed too and I’m mentally cursing but it does eventually restart. - Then I decide, rather than the piecemeal approach, to do the full install with
apt-get -t unstable install php4
. As a side-effect it looks like I also get perl updated to 5.8.4, and it upgrades apache (just as well I saved those conf files!). The install script tells me about changes to apache config files, which has me a little worried… I decide to install the package maintainer’s version ofhttpd.conf
and add in any needed changes later. Everything seems to keep on running afterwards, though, so this upgrade was better than the lastdist-upgrade
I did, which didn’t apply my changes tohttpd.conf
.
Now phpinfo.php
shows that I have php4.3.10 installed on my system; time to try out the thumbnail functionality. It still doesn’t work. Reinstall php4-gd2
. Thumbnails still don’t work. Try apt-get -t unstable install php4-gd
, which also seems to uninstall/reinstall/install a whole bunch of packages. I console myself that I’m half-way to sarge, if and when that version of Debian ever makes it to stable. Hmm, the install script just asked me what size paper should be the default on my system. I guess it has some reason for wanting to know.
Since the thumbnail generation still doesn’t work, and I have no idea what to try next, I decide to give up and post on the WordPress support forum. I hope someone there knows what the problem might be! In the meantime I create the thumbnail I need using Imagemagick’s convert
function. This takes one command line and approximately 0.01 seconds.
Later… on the WordPress support forum someone tells me to search the forums. Since I’d started by doing that (and quoted forum searches in my post), that wasn’t particularly helpful. Then I remember I have SpamKarma installed, which has a captcha script (not that I want to use it, but it should be a good test). The error message on the captcha test page says the GD library isn’t enabled. A bit of Googling turns up the idea that maybe I need to restart apache yet again. I hadn’t thought of this before because the Debian upgrade/install process usually restarts everything that needs to be restarted, including apache. I run apachectl restart
and find I can finally click the magic button on image upload to create thumbnails!
So the lesson appears to be: if in doubt, restart apache. Three times, preferably. Any less just may not work.
So in the end, what do you think solved the problem? The upgraded apache, debian, php, the restart or everything?
That’s a good question. It’s obvious that installing everything is sufficient, but I’m not convinced that it’s all necessary. It’s quite possible that installing
libgd2
andphp4-gd2
on their own would have been sufficient had I thought to restart apache afterwards (i.e., paragraph 1). I surmise what happens is that the install scripts don’t notice that the addition of thegd
line tophp.ini
requires that apache be restarted or in some other way coerced into rereading thephp.ini
file. Mind you, I have no intention of spending hours uninstalling everything just to try this out.I just wanted to drop a quick comment and thank you for your post as it helped me get thumbnails working. I had tried almost all the steps you listed above (update php, libgd, etc.) to no avail, but when I restarted Apache per your suggestion, POOF, it works. Thanks again.
yes rite, just restart the apache ^_^ after upgrade my php4-gd. and it’s work !!!
many thanks
try php 4.3.11 or v.5
I’m having the same problem. It’s frustrating as heck, since I am completely unwilling to move to an “unstable” package on my production server. There libgd2 packages in stable, as of now, with php 4.3.10 really ought to work. I’m thinking it might be a path issue? Anyone? Please contact me at seanSPLATseannyob.org if you figure it out.
Same Problem here.
I have a actual debian/testing installation (apt-get upgrade) and php 4.3.10–16
But the thing with the thumbnails doesn’t work.
I just came by this post today after experiencing the exact problem described. I was about to go down the very same path of upgrading libgd2, php4 etc etc on my debian stable system, but thanks to the replys here a simple install of libgd2 and php4-gd2 followed by a restart of apache did the trick nicely. Thanks!
Add the following to /etc/php4/apache2/php.ini
extension=gd.so
And restart apache2
This may fix the problem with WordPress, without having to upgrade any packages (unless it just my system where is was installed but not enabled)
Thanks for the comment, Pobice — this may work for some people but it didn’t work for me, hence the need to upgrade everything first. Certainly worth trying first!
I find it unsettling that gd.so is commented out in php.ini by default. It took me a long time to find that the first time. Now, on my amd64 box, enabling that doesn’t work. It looks like that troublesome lib32 vs. lib64 thing.
I had another problem using gd2 library in case i was using fonts they were not chmod 777 and wouldnt work.
I looked the output from the generated image file, and it said something like enable to open.
Just installing libgd2 and php4-gd on PHP 4.3.10–19 did it for me. Of course with an apache restart afterwards.
Hope that helps you guys.
Cheers!
Chris