How do I go about enabling GD Support in a CentOS Installation?
Asked
Active
Viewed 1.5e+01k times
6 Answers
121
The thing that did the trick for me eventually was:
yum install gd gd-devel php-gd
and then restart apache:
service httpd restart

Nir Alfasi
- 53,191
- 11
- 86
- 129
-
Yes, this works perfectly on CentOS release 6.5. The "phpinfo" page says that PHP has originally compiled without gd ('--without-gd') but also dumps a section about the now-present "gd". – David Tonhofer Mar 27 '14 at 13:05
-
2Make sure that you are using the right php package. For example, in my case, I was using php56w, so I needed to use php56w-gd. – Evan Donovan Dec 06 '16 at 21:51
-
@EvanDonovan it's true only if you're using versions that are not in the official CentOS repository! – Nir Alfasi Dec 06 '16 at 21:56
-
1Thanks for that clarification @alfasin - I was not the person who did the upgrade of our PHP to 5.6, so I'm not sure why they used the php56w package. I just wanted to add that as a comment though in case anyone else gets dependency resolution errors. – Evan Donovan Dec 07 '16 at 19:11
-
-
if you're running PHP-FPM, instead of Apache, you need to restart PHP-FPM. – bdereta Aug 03 '17 at 17:39
-
Thank you @EvanDonovan. My server admin uses php56w for some reason as well. – Dork Nov 26 '19 at 05:37
-
@alfasin that makes sense - we are using a different package of PHP because our CentOS was lagging behind. However, we are now on PHP 7.x - as should everyone be :) – Evan Donovan Nov 26 '19 at 17:05
34
- 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.
- Once you've setup the repo it's a simple matter of running
sudo yum install php-gd
- Of course, the usual things apply: make sure you restart apache after installing, etc.
-
If you have NginX, no need to restart! Apparently you need php-gd for WordPress "edit media" https://wordpress.org/support/topic/edit-media-not-working – PJ Brunet Mar 26 '15 at 22:16
6
With CentOS 6.5+ and PHP 5.5:
yum install php55u-gd
service httpd restart
If you get an error like: cannot map zero-fill pages: Cannot allocate memory in Unknown on line 0
, it could be because you don't have a swap file. I suggest you take a look at the tutorial mentioned in this answer: https://stackoverflow.com/a/20275282/828366
Tutorial: https://www.digitalocean.com/community/articles/how-to-add-swap-on-centos-6

Community
- 1
- 1

Francesco Casula
- 26,184
- 15
- 132
- 131
1
Put the command
yum install php-gd
and restart the server (httpd, nginx, etc)
service httpd restart

Ivan Fretes
- 668
- 7
- 11