Mar 262005
 

I decided I finally wanted to track down why I could­n’t get the thumb­nails work­ing on Word­Press. I always get the mes­sage “File type not sup­por­ted. Thumb­nail not cre­ated.” even when the file­type is sup­por­ted. I run a stand­ard Debi­an stable sys­tem, with a back­port of MySQL, so my first assump­tion was that it should work. A long week­end is a good chance to try to track down these things, espe­cially when it’s rain­ing as much as it is this week­end in Van­couver. Of course, I start at the Word­Press sup­port for­ums. This leads me to try apt-get install libgd2; the thumb­nails don’t work. As a next approx­im­a­tion, try apt-get install php4-gd2; this also does­n’t work.

I dig a bit deep­er in the for­ums and find that a new­er ver­sion of PHP might solve the prob­lem; the Debi­an stable ver­sion is 4.1.2 and a ver­sion > 4.3 is recom­men­ded as the GD lib­rary is included by default. The oth­er advant­age to upgrad­ing PHP4 is that there are quite a few secur­ity holes fixed in ver­sion 4.3.9 and up; these may have been back­por­ted to 4.1.2, of course. So I look in backports.org because I already know how to use those; no new­er ver­sion of php4 there. Next I try dotdeb.org; this back­port site has a new­er ver­sion of PHP4 and a new­er ver­sion of MySQL. I add the magic line deb http://packages.dotdeb.org ./ to the /etc/apt/sources.list file. I also change the pin pri­or­ity in the pref­er­ences file to use dotdeb.org rather than backports.org. This upgrades my MySQL to dot­de­b’s 4.0 ver­sion nicely, but does­n’t touch the PHP4 install­a­tion. Seems odd to me since they should both be upgraded in the same way, I would have thought. Edd Dum­bill (Debi­an guru) gives me a couple of oth­er things to try in the pref­er­ences file; noth­ing seems cap­able of rais­ing the pri­or­ity of the dot­deb php4 install over the cur­rent stable installed ver­sion. Edd sug­gests installing each .deb by brute force; that breaks on unmet dependencies.

So I think about installing the unstable ver­sion of PHP4; maybe that will work bet­ter. I set up the pin pri­or­it­ies 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 noth­ing breaks, or at least ensure I know what has broken if it does. First off, I make backups of httpd.conf, access.conf, the fire­wall script, and the PPPOE set­tings. Just in case. Not that I’m para­noid or anything.

  1. I install the unstable ver­sion of libexpat1; this installs libc6 and talks about hav­ing to restart the X11 serv­er. Since I’m not run­ning X, this isn’t a prob­lem. 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 men­tally curs­ing but it does even­tu­ally restart.
  2. Then I decide, rather than the piece­meal 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 con­fig files, which has me a little wor­ried… I decide to install the pack­age main­tain­er­’s ver­sion of httpd.conf and add in any needed changes later. Everything seems to keep on run­ning after­wards, though, so this upgrade was bet­ter than the last dist-upgrade I did, which did­n’t apply my changes to httpd.conf.

Now phpinfo.php shows that I have php4.3.10 installed on my sys­tem; time to try out the thumb­nail func­tion­al­ity. It still does­n’t work. Rein­stall php4-gd2. Thumb­nails still don’t work. Try apt-get -t unstable install php4-gd, which also seems to uninstall/reinstall/install a whole bunch of pack­ages. I con­sole myself that I’m half-way to sarge, if and when that ver­sion of Debi­an ever makes it to stable. Hmm, the install script just asked me what size paper should be the default on my sys­tem. I guess it has some reas­on for want­ing to know.

Since the thumb­nail gen­er­a­tion still does­n’t work, and I have no idea what to try next, I decide to give up and post on the Word­Press sup­port for­um. I hope someone there knows what the prob­lem might be! In the mean­time I cre­ate the thumb­nail I need using Imagema­gick­’s convert func­tion. This takes one com­mand line and approx­im­ately 0.01 seconds.

Later… on the Word­Press sup­port for­um someone tells me to search the for­ums. Since I’d star­ted by doing that (and quoted for­um searches in my post), that was­n’t par­tic­u­larly help­ful. Then I remem­ber 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 mes­sage on the captcha test page says the GD lib­rary isn’t enabled. A bit of Googling turns up the idea that maybe I need to restart apache yet again. I had­n’t thought of this before because the Debi­an upgrade/install pro­cess usu­ally restarts everything that needs to be restar­ted, includ­ing apache. I run apachectl restart and find I can finally click the magic but­ton on image upload to cre­ate thumbnails!

So the les­son appears to be: if in doubt, restart apache. Three times, prefer­ably. Any less just may not work.

  13 Responses to “Enabling Thumbnails”

  1. So in the end, what do you think solved the prob­lem? The upgraded apache, debi­an, php, the restart or everything?

  2. That’s a good ques­tion. It’s obvi­ous that installing everything is suf­fi­cient, but I’m not con­vinced that it’s all neces­sary. It’s quite pos­sible that installing libgd2 and php4-gd2 on their own would have been suf­fi­cient had I thought to restart apache after­wards (i.e., para­graph 1). I sur­mise what hap­pens is that the install scripts don’t notice that the addi­tion of the gd line to php.ini requires that apache be restar­ted or in some oth­er way coerced into reread­ing the php.ini file. Mind you, I have no inten­tion of spend­ing hours unin­stalling everything just to try this out. 

  3. I just wanted to drop a quick com­ment and thank you for your post as it helped me get thumb­nails work­ing. I had tried almost all the steps you lis­ted above (update php, libgd, etc.) to no avail, but when I restar­ted Apache per your sug­ges­tion, POOF, it works. Thanks again.

  4. yes rite, just restart the apache ^_^ after upgrade my php4-gd. and it’s work !!!
    many thanks

  5. try php 4.3.11 or v.5

  6. I’m hav­ing the same prob­lem. It’s frus­trat­ing as heck, since I am com­pletely unwill­ing to move to an “unstable” pack­age on my pro­duc­tion serv­er. There libgd2 pack­ages in stable, as of now, with php 4.3.10 really ought to work. I’m think­ing it might be a path issue? Any­one? Please con­tact me at seanSPLATseannyob.org if you fig­ure it out.

  7. Same Prob­lem here.
    I have a actu­al debian/testing install­a­tion (apt-get upgrade) and php 4.3.10–16
    But the thing with the thumb­nails does­n’t work.

  8. I just came by this post today after exper­i­en­cing the exact prob­lem described. I was about to go down the very same path of upgrad­ing libgd2, php4 etc etc on my debi­an stable sys­tem, but thanks to the replys here a simple install of libgd2 and php4-gd2 fol­lowed by a restart of apache did the trick nicely. Thanks!

  9. Add the fol­low­ing to /etc/php4/apache2/php.ini

    extension=gd.so

    And restart apache2

    This may fix the prob­lem with Word­Press, without hav­ing to upgrade any pack­ages (unless it just my sys­tem where is was installed but not enabled)

  10. Thanks for the com­ment, Pobice — this may work for some people but it did­n’t work for me, hence the need to upgrade everything first. Cer­tainly worth try­ing first!

  11. I find it unset­tling that gd.so is com­men­ted 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 does­n’t work. It looks like that trouble­some lib32 vs. lib64 thing.

  12. I had anoth­er prob­lem using gd2 lib­rary in case i was using fonts they were not chmod 777 and would­nt work.
    I looked the out­put from the gen­er­ated image file, and it said some­thing like enable to open.

  13. 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

Leave a Reply to Michael Cancel reply

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

(required)

(required)

/* ]]> */