Install php gd extension centos 7

How do I go about enabling GD Support in a CentOS Installation?

asked Jan 26, 2012 at 20:35

1

The thing that did the trick for me eventually was:

yum install gd gd-devel php-gd

and then restart apache:

service httpd restart

answered Aug 19, 2012 at 6:59

Nir AlfasiNir Alfasi

52.2k11 gold badges81 silver badges122 bronze badges

8

  1. You need to find a repo that offers a GD lib matching your current php version. I've had great success using Remi Collet's repo for this purpose. In fact, I used it yesterday to update my php install to the latest 5.4.0RC6 version on my CentOS6 box.
  2. Once you've setup the repo it's a simple matter of running sudo yum install php-gd
  3. Of course, the usual things apply: make sure you restart apache after installing, etc.

answered Jan 26, 2012 at 20:39

rdlowreyrdlowrey

39.3k9 gold badges76 silver badges98 bronze badges

1

CentOs 6.5+ & PHP 5.6:

sudo yum install php56-gd

service httpd restart

answered Jun 30, 2016 at 7:44

Put the command

yum install php-gd

and restart the server [httpd, nginx, etc]

service httpd restart

answered Dec 26, 2017 at 19:26

Ivan FretesIvan Fretes

6287 silver badges11 bronze badges

For PHP7 on CentOS or EC2 Linux AMI:

sudo yum install php70-gd

answered Jan 2, 2020 at 4:48

Adam WinterAdam Winter

1,3941 gold badge10 silver badges24 bronze badges

Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

I should have paid more attention to the naming convention - even though I couldn’t find GD Library in IUS’s package list, it is there. I just ran:

sudo yum install php70u-gd

It wasn’t until I tried grabbing a list of all installed PHP packages that I noticed the naming convention was probably key. If anyone is curious about their own installation, you can run:

yum list installed *php*

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

After some struggle trying to get the package right for centos it wound up being: yum install php-gd

The other packages are not available any more.

Note: this article only applies if your current PHP version has been installed by yum. If you custom compiled it from source, this will not work.

Verify PHP as installed by yum

An easy task, using yum. First step, see if it’s already installed.

[root@srv]# rpm -qa | grep php
php-common-5.1.6-15.el5
php-cli-5.1.6-15.el5
php-5.1.6-15.el5
php-pdo-5.1.6-15.el5
php-mysql-5.1.6-15.el5

Install the GD library using yum

If the GD Library isn’t present in that list, it wasn’t installed on the server yet. Install it using yum.

[root@srv]# yum install php-gd
Loading "installonlyn" plugin
Setting up Install Process
Setting up repositories
extras                    100% |====================| 1.1 kB    00:00
updates                 100% |====================|  951 B    00:00
base                      100% |====================| 1.1 kB    00:00
addons                  100% |====================|  951 B    00:00
Reading repository metadata in from local files
primary.xml.gz            100% |====================|  81 kB    00:00
########################################## 282/282
primary.xml.gz            100% |====================| 164 kB    00:00
########################################## 374/374
primary.xml.gz            100% |====================| 853 kB    00:00
########################################## 2458/2458
Parsing package install arguments
Resolving Dependencies
--> Populating transaction set with selected packages. Please wait.
---> Downloading header for php-gd to pack into transaction set.
php-gd-5.1.6-20.el5_2.1.i 100% |====================|  17 kB    00:00
---> Package php-gd.i386 0:5.1.6-20.el5_2.1 set to be updated
--> Running transaction check
--> Processing Dependency: php-common = 5.1.6-20.el5_2.1 for package: php-gd
--> Restarting Dependency Resolution with new changes.
--> Populating transaction set with selected packages. Please wait.
---> Downloading header for php-common to pack into transaction set.
php-common-5.1.6-20.el5_2 100% |====================|  21 kB    00:00
---> Package php-common.i386 0:5.1.6-20.el5_2.1 set to be updated
--> Running transaction check
--> Processing Dependency: php-common = 5.1.6-15.el5 for package: php
--> Processing Dependency: php-common = 5.1.6-15.el5 for package: php-pdo
--> Processing Dependency: php-common = 5.1.6-15.el5 for package: php-mysql
--> Processing Dependency: php-common = 5.1.6-15.el5 for package: php-cli
--> Restarting Dependency Resolution with new changes.
--> Populating transaction set with selected packages. Please wait.
---> Downloading header for php-pdo to pack into transaction set.
php-pdo-5.1.6-20.el5_2.1. 100% |====================|  18 kB    00:00
---> Package php-pdo.i386 0:5.1.6-20.el5_2.1 set to be updated
---> Downloading header for php-mysql to pack into transaction set.
php-mysql-5.1.6-20.el5_2. 100% |====================|  18 kB    00:00
---> Package php-mysql.i386 0:5.1.6-20.el5_2.1 set to be updated
---> Downloading header for php-cli to pack into transaction set.
php-cli-5.1.6-20.el5_2.1. 100% |====================|  18 kB    00:00
---> Package php-cli.i386 0:5.1.6-20.el5_2.1 set to be updated
---> Downloading header for php to pack into transaction set.
php-5.1.6-20.el5_2.1.i386 100% |====================|  19 kB    00:00
---> Package php.i386 0:5.1.6-20.el5_2.1 set to be updated
--> Running transaction check

Dependencies Resolved

=================================
Package                 Arch       Version          Repository        Size
=================================
Installing:
php-gd                  i386       5.1.6-20.el5_2.1  updates           113 k
Updating for dependencies:
php                     i386       5.1.6-20.el5_2.1  updates           1.1 M
php-cli                 i386       5.1.6-20.el5_2.1  updates           2.1 M
php-common              i386       5.1.6-20.el5_2.1  updates           154 k
php-mysql               i386       5.1.6-20.el5_2.1  updates            84 k
php-pdo                 i386       5.1.6-20.el5_2.1  updates            62 k

Transaction Summary
=================================
Install      1 Package[s]
Update       5 Package[s]
Remove       0 Package[s]

Total download size: 3.7 M
Is this ok [y/N]: y
Downloading Packages:
[1/6]: php-pdo-5.1.6-20.e 100% |=========================|  62 kB    00:00
[2/6]: php-common-5.1.6-2 100% |=========================| 154 kB    00:00
[3/6]: php-gd-5.1.6-20.el 100% |=========================| 113 kB    00:00
[4/6]: php-mysql-5.1.6-20 100% |=========================|  84 kB    00:00
[5/6]: php-cli-5.1.6-20.e 100% |=========================| 2.1 MB    00:01
[6/6]: php-5.1.6-20.el5_2 100% |=========================| 1.1 MB    00:00
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
Updating  : php-common                   ####################### [ 1/11]
Updating  : php-pdo                      ####################### [ 2/11]
Updating  : php-cli                      ####################### [ 3/11]
Installing: php-gd                       ####################### [ 4/11]
Updating  : php-mysql                    ####################### [ 5/11]
Updating  : php                          ####################### [ 6/11]
Cleanup   : php-pdo                      ####################### [ 7/11]
Cleanup   : php-common                   ####################### [ 8/11]
Cleanup   : php-mysql                    ####################### [ 9/11]
Cleanup   : php-cli                      ####################### [10/11]
Cleanup   : php                          ####################### [11/11]

Installed: php-gd.i386 0:5.1.6-20.el5_2.1
Dependency Updated: php.i386 0:5.1.6-20.el5_2.1 php-cli.i386 0:5.1.6-20.el5_2.1 php-common.i386 0:5.1.6-20.el5_2.1 php-mysql.i386 0:5.1.6-20.el5_2.1 php-pdo.i386 0:5.1.6-20.el5_2.1
Complete!

Easy going, isn’t it?

Restart Apache

Restart your apache, and you’re ready to rock.

[root@srv]# service httpd restart
Stopping httpd:                                            [  OK ]
Starting httpd:                                            [  OK ]

Simple as that!

Chủ Đề