Fixing gd Problem in PHP on Ubuntu 11.04

I was trying to enable gd for php in Ubuntu 11.04. As usual it should be typing in terminal:

$ sudo apt-get install php5-gd

Unfortunately it does not worked and gd was not enabled

Typing the command php -a I was getting:

PHP Startup: Unable to load dynamic library ‘/usr/lib/php5/20090626+lfs/’ - /usr/lib/php5/20090626+lfs/ undefined symbol: gdImageCreateFromJpeg in Unknown on line 0

By googling I got this bug report and a solution along. The reason was /usr/local/lib/ contained other versions gd. So it have to be moved out. So just run these commands once the terminal is inside ‘/usr/local/lib/’

$ sudo mkdir libgd.backup
$ sudo mv* libgd.backup

Then restart apache:

$ sudo /etc/init.d/apache2 restart