Ubuntu Linux install or add php gd support to Apache

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.

Want to read Linux tips and tricks, but don't have time to check our blog everyday? Subscribe to our daily email newsletter to make sure you don't miss a single tip/tricks. Subscribe to our weekly newsletter here!

{ 19 comments… read them below or add one }

1 Heroin 02.07.07 at 11:46 am

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

2 nixcraft 02.07.07 at 3:15 pm

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();
?>

3 Eric 02.14.07 at 8:22 am

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

4 zaf 04.04.07 at 7:26 am

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.

5 zaf 04.04.07 at 10:36 am

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.

6 cruz 07.04.07 at 3:29 pm

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!!!

7 vivek 07.05.07 at 12:26 pm

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

8 wilco 07.17.07 at 9:25 pm

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??

9 vivek 07.17.07 at 9:47 pm

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

10 wilco 07.17.07 at 10:08 pm

@vivek.

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

11 Tharange 11.09.07 at 8:08 am

Thanks, My prob Solved.

12 Newbie2 11.10.07 at 9:46 pm

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.

13 Mark 12.05.07 at 3:49 pm

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.

14 xer 02.28.08 at 10:02 am

thank you =)

15 ihya 04.26.08 at 6:58 am

thank you

16 Peter Martin 08.26.08 at 9:20 am

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!

17 fixsmall 10.22.08 at 7:48 pm

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

18 Webdesign Amsterdam 04.09.09 at 1:52 pm

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

19 Matteo Terruzzi 07.01.09 at 5:30 pm

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

Leave a Comment

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

Previous post: Connect to SQL Server from command prompt – list tables and database

Next post: Linux format external USB hard disk Partition