Back to the blog

RSS
65 subscribers

Recent Posts

Most Popular Posts

  1. Why you should be using a framework
  2. Perhaps the world doesn't need another framework
  3. Rewriting URLs with Apache's mod_rewrite and PHP
  4. Five easy things that make you a better web developer

About the Blog

Self portrait

I'm a web designer and web application developer in Melbourne, Australia. If you find anything useful, leave me a comment, and if you need web design, development, or accessibility and usability consulting, contact me! Cheers.

Twitter: joshsharp

a bird

How to add extensions to PHP 5 running as an Apache 2 module

Sunday 04 Nov, 2007 08:22 PM

Just a quick tip — hopefully this will help anyone having the same issue as I was. Our development server at work runs Ubuntu 6.10 (using the default Ubuntu LAMP setup), and this setup happens to use Apache 2, with PHP as an Apache module (rather than a CGI extension, or whatever).

Now this default setup doesn't include some fairly standard PHP extensions like cURL and the GD libraries — but working out how to get these included caused me no end of trouble. I didn't want to recompile PHP, but didn't understand why adding a reference to libgd.so was giving me the error that it wasn't a valid PHP library. And surprise surprise, it's not; you need the PHP bindings. So for those who are in the same situation and don't want to recompile PHP, but need those extensions, there's actually a very simple solution that was incredibly hard to find on the web.

You can just install the packages from the repository.

So if you're a GUI person, you can use Synaptic and search for "php5" to retrieve the list of available modules. Or if you prefer the terminal, it's as easy as typing sudo apt-get install php5-gd or sudo apt-get install php5-curl.

I wish somebody had told me that.

Tags: apache

Comments

Orre said on 17 Jan 2008:
Thanks! I've been trying to figure this out all morning. :)
noname said on 16 Apr 2008:
i just don't understand why installing php5-gd install _all_ this: defoma fontconfig-config libfontconfig1 libfreetype6 libgd2-xpm libjpeg62 libpng12-0 libt1-5 libx11-6 libx11-data libxau6 libxcb-xlib0 libxcb1 libxdmcp6
libxpm4 php5-gd ttf-dejavu ttf-dejavu-core ttf-dejavu-extra x11-common

why in the havens i need so many X11 things on my server since is just a server and not a desktop system?!?!
Josh said on 16 Apr 2008:
Noname, it's because GD is a graphics library, and as such it has to be able to render things like text, jpegs, and pngs. I imagine one of the font or image type libraries has X11 dependencies as well, and that's how the list gets so big.
Sergio Morales said on 18 Jun 2008:
Does anyone know why I can't render ttf fonts using the package php5-gd? I am using ubuntu 8.04 server (the one that canonical delivers for free) and I need to add text to the barcodes I create using phpbarcode.
Andre said on 25 Jun 2008:
Same here, no text is rendered on ubuntu 8.04, but php5-gd is installed and recognized....
templespt said on 05 Sep 2008:
thanks, dude.

Add a comment! Only your message is required (and proving you're human, sorry). No HTML.

 Captcha image - sorry!