Ubuntu Linux install or add php gd support to Apache

by Vivek Gite on December 20, 2006 · 41 comments

Q. I am using Apache server and PHP5. How do I install install php gd support?

A. PHP is used mainly in server-side application software along with various addons.

PHP includes a large number of free and open source libraries with the core build. PHP is a fundamentally Internet-aware system with modules built in for accessing FTP servers, many database servers, embedded SQL libraries such as embedded MySQL and SQLite, LDAP servers, and others. Many functions familiar to C programmers such as those in the stdio family are available in the standard PHP build.

The GD Graphics Library for dynamically manipulating images. You will need to compile PHP with the GD library of image functions for this to work.

However Ubuntu (and Debian) comes with package called php5-gd

Just type following command to install this module:
# apt-get install php5-gd
OR
$ sudo apt-get install php5-gd

Restart Apache
# /etc/init.d/apache2 restart

Test your php application.

Featured Articles:

Share this with other sys admins!
Facebook it - Tweet it - Print it -

{ 41 comments… read them below or add one }

1 Heroin February 7, 2007

Thanks didnt really understand what GD was and which package it was. Apt-cache search gave me a load of weird packages. So i thank you!

Perhaps it would be nice if there was a line you can run to see if its running properly

Reply

2 nixcraft February 7, 2007

Heroin,

You can type php -m command to see php-gd support is loaded or not at a shell prompt:
php -m

You can also create a php code with phpinfo() function and see if GD is loaded or not :)

<?php
phpinfo();
?>

Reply

3 Eric February 14, 2007

That’s great, it solves my problem in my new server. Good stuff.

Reply

4 zaf April 4, 2007

when running in a browser it only shows the code, but doesn’t show the php information.
Can anyone please help me solving this problem.

Reply

5 zaf April 4, 2007

I have a problem running php files in a browser; I tried a test.php with but it only shows the code lines in the browser with no PHP information.
I would really appreicate you help.

Reply

6 cruz July 4, 2007

Hi, I want to install GD library, I want use it with PHP

I tried:

sudo apt-get install php5-gd

but i get following error message

E: couldn“t find package php5-gd

Apache is working, my soft versions are:
SO ubuntu 7.07
PHP Version 5.2.1
Apache/2.2.3 (Ubuntu)

what can I do?

THANKS!!!

Reply

7 vivek July 5, 2007

You need to use php5-gd only, try apt-get update first.

Reply

8 wilco July 17, 2007

When I apt-get install php5-gd the response is ‘Please insert the disc labeled ‘Ubuntu-Server 6.06.1 _Dapper Drake_ – Release i386′.
But I am working remote, what can I do to solve this issue??

Reply

9 vivek July 17, 2007

You need to force apt-get to run via network by editing /etc/apt/sources.list file. Comment out CDROM entry.

Reply

10 wilco July 17, 2007

@vivek.

Thanks that did the job!
I had to apt-get update first and after that it worked like a charme!
Thanx again

Reply

11 Tharange November 9, 2007

Thanks, My prob Solved.

Reply

12 Newbie2 November 10, 2007

I have a standard linux box from theplanet.com (formerly ev1servers.net formerly rackshack.net) and they generally use Redhat Pro as the OS..

I found the easiest way to install PHP GD on the servers from “the planet” was to use the command:

yum install php-gd

Do it from the root dir via SSH (using the program called “putty”) and it all happens very fast. Restart the server and check if your page apps run correctly.

Thats about as simple as I can explain it for any other newbies that don’t understand linux like myself.

hope this is helpful.

Reply

13 Mark December 5, 2007

Hi all,

I’m running a Joomla install on a virtual Jumpbox. I’ve tried running the above but it doesn’t seem to help.

Has anyone experience of getting this to work on the Jumpbox platform?

Cheers, MARK.

Reply

14 xer February 28, 2008

thank you =)

Reply

15 ihya April 26, 2008

thank you

Reply

16 Peter Martin August 26, 2008

When I tried to install some 3rd party extension in my Joomla 1.5 website (hosted on my local Ubuntu PC) I got the error that GD2 was missing.

With your instruction I was able to install GD2 successfully. I reinstalled the Joomla Extension and now it’s able to resize images!

Thanks!

Reply

17 fixsmall October 22, 2008

I test my gd but it doesn’t support xbm ,how could i do ?

when I wanna use phpXplorer it show me could not find “PHP GD XBM Support”
thank you !

You need either PHP GD extension or Image Magick for image manipulation.
PHP GD extension found 2.0 or higher
PHP GD FreeType Support exists
PHP GD T1Lib Support exists
PHP GD GIF Read Support exists
PHP GD GIF Create Support exists
PHP GD JPG Support exists
PHP GD PNG Support exists
PHP GD WBMP Support exists
PHP GD XBM Support not found

Reply

18 Webdesign Amsterdam April 9, 2009

Thanks! Never thought i could solve this problem this fast.

Reply

19 Matteo Terruzzi July 1, 2009

Thank you very much, you have resolved all my problems!

Reply

20 Webdesign Rotterdam July 13, 2009

Thank you very much, you have resolved all my problems! Never thought i could solve this problem this fast.

Reply

21 berkmense October 30, 2009

i am using Apache/2.2.8 (Ubuntu) PHP/5.2.4-2ubuntu5.6 with Suhosin-Patch .i am not able to download GD ..Please help me..

Reply

22 tanks December 23, 2009

thank you very very much!

Reply

23 manuel February 8, 2010

you are #1 in google for this search, so I’m goingo to thankyou to keep it this way.

Reply

24 Roy July 11, 2010

Thanks for such simple instructions!

Reply

25 Pablito Zamudio July 18, 2010

PHP5-Gd INSTALL HELP
In the installation of php5-gd, do not include T1Lib in the GUI option–include only TrueType.

Reply

26 Hemma August 2, 2010

how to install php GD in ubuntu linux? This is for resize the thumbnail images. Thank You

Reply

27 g August 19, 2010

Nice information ooooOO…

so if we already HAVE the apache and php installed
but not included with
These extensions;

GD
IMAP
Zlib
OpenSSL
Curl

on Linux,,,

should we installed it by typing one by one apt-get install <> ?

Reply

28 g August 19, 2010

so how if we want more extension installed
at the time we already have the apache and php installed on our linux….?

Reply

29 Rafael September 7, 2010

Perfect! Thanks from Brazil \o/

Reply

30 tangtang December 6, 2010

but , my server is off line
what can i do?

Reply

31 lixin December 29, 2010
32 Vladimir February 24, 2011

It still actual and helped me resolve my problem with images processing in a minute. Thanks.

Reply

33 vivek April 26, 2011

how can i enable Gd, Curl, Memcache, Mysql, Mysqli, Exif, ftp, iconv, json, Session, apc modules in centos .

tanks & regards
vivek.p

Reply

34 Achyut Neupane June 14, 2011

I dont have website.
But I want to learn how to add captcha in website.

Reply

35 musasa June 20, 2011

Thanks it helped. may God be with you.

Reply

36 RedScourge July 12, 2011

If you are like me, and running PHP 5.2.X on an Ubuntu system that normally ships with PHP 5.3.X, it is difficult to compile your own PHP from altered source so that it uses bundled GD instead of system GD, since libaprutil1-dev and apache2-prefork-dev depend on some non-dev packages that essentially break your ability to compile this unless you first were to uninstall PHP and Apache entirely. You can get around this by installing all the dependencies you need for building minus these two libraries, then downloading the .deb packages for these two libraries, forcing them in with dpkg –force-depends -i [packagename], THEN alter and compile, and then remove all the build dependencies after. This is how I built myself a bundled GD version of php5-gd_5.2.10.dfsg.1-2ubuntu6.10_amd64.deb.

Reply

37 hennie September 18, 2011

i am running a couple of sites and forums on the server
my fear is when i install the php5-gd it will damidge the current running php5

so my question is can i install it without damidging the current setup
or will i have to repair them afterwards

Reply

38 Guru Wannabe October 28, 2011

Hi,
Thank you very much. It’s 2011oct28 and your post just help me =).
Was figuring what went wrong with my WebApp running Turkey Linux LAMP appliance in Virtualbox. Got an error message about GD library.
Googled and read a ‘thread’ of scary ‘recompile’ … late night tales… and thanks for your post that saved me all from those.
I ssh as root into the VirtualBox appliance and did exactly as you said and viola … it just works.
Cheers!

Reply

39 Guru Wannabe October 28, 2011

Ooops! wireless keyboard … I meant TurnKey Linux LAMP and no didn’t eat turkey earlier.

Reply

40 Rama January 9, 2012

Thanks, that worked for me also.

Reply

41 Insan January 30, 2012

Thanks, it took me a while to actually realize that the library was not installed.. that’s why it kept crashing! But now, problem is fixed! :)

Reply

Leave a Comment

You can use these HTML tags and attributes for your code and commands: <strong> <em> <ol> <li> <u> <ul> <blockquote> <pre> <a href="" title="">



Previous post:

Next post: