78

How does one enable (or perhaps I need to install) GD when my phpinfo() output in "Configure Command" says; --without-gd ?

I also have nothing in my phpinfo() output "Core" that lists "gd"

PHP Version 5.2.4 on AWS.

Jonas
  • 121,568
  • 97
  • 310
  • 388
Shu
  • 781
  • 1
  • 5
  • 3
  • I have same problem but I would like to remind question is not how to setup gd on terminal or how to restart your server question is after all if you can not see on phpinfo file gd support what should you do? one of answer on php.net [enter link description here](http://php.net/manual/en/image.installation.php) it says you should configure your php --with-gd="your diroctory path to gd" – Victor Sep 12 '17 at 08:58

12 Answers12

101

if you are on a Debian based server (such as Ubuntu) you can run the following command:

apt-get install php-gd

Then once it is complete run:

/etc/init.d/apache2 restart

This will restart your server and enable GD in PHP.

If you are on another type of system you will need to use something else (like yum install) or compile directly into PHP.

user1133275
  • 2,642
  • 27
  • 31
Shane
  • 16,779
  • 5
  • 27
  • 46
72

For PHP8 use (php8.1-gd are also available):

sudo apt-get install php8.0-gd

For PHP7.0 use (php7.1-gd, php7.2-gd, php7.3-gd andphp7.4-gd are also available):

sudo apt-get install php7.0-gd

and than restart your webserver.

sudo service nginx restart

or

sudo service httpd restart
Sebastian Viereck
  • 5,455
  • 53
  • 53
  • From a while now, every extension is now on Ubuntu aliased. IE `sudo apt-get install php-gd` refers to the running version. – Augusto Dec 02 '22 at 10:51
22

Check if in your php.ini file has the following line:

;extension=php_gd2.dll

if exists, change it to

extension=php_gd2.dll

and restart apache

(it works on MAC)

Mogsdad
  • 44,709
  • 21
  • 151
  • 275
  • You don't even need to restart your webserver if you are on terminal – briankip Apr 26 '17 at 12:51
  • I don't have `php_gd2.dll` extention – Moeez Jan 25 '21 at 06:00
  • 3
    In my case there's `extension=gd` and then `;gd.jpeg_ignore_warning = 1`, but no `;extension=php_gd2.dll`. As I [read](https://php.watch/versions/8.0/gd2-gd-windows), this is the case with PHP8. Still I get an error, despite `php -m` clearly showing `gd` extension is available. Odd. – s3c Mar 11 '21 at 14:25
17

In my case (php 5.6, Ubuntu 14.04) the following command worked for me:

sudo apt-get install php5.6-gd

According to php version we need to change the php5.x-gd

jmarkmurphy
  • 11,030
  • 31
  • 59
14

PHP7 Or PHP8 For Windows:

Check if in your php.ini file has the following line:

;extension=gd

if exists, change it to

extension=gd

if not found, Add this

extension=gd

and restart apache

(it works on WINDOWS)

Mohamed Hany
  • 451
  • 4
  • 10
12

All previous answers are correct but were not sufficient for me on ArchLinux. I also needed to edit /etc/php/php.ini and to uncomment :

;extension=gd.so 

The initial ; on the line needs to be removed. After restarting Nginx via systemctl restart nginx, I was good to go.

galoget
  • 722
  • 9
  • 15
Alexandre Bourlier
  • 3,972
  • 4
  • 44
  • 76
  • Nice, 2019 here on arch, I had installed GD extension with `yay -S php-gd` but that didn't setup the php.ini/conf.d/gd.ini like it should have. Your tip worked. The AUR probably needs its build file updated to do that.3 minutes later... oh that package has been flagged as out of date, looks like `php70-gd` is the _one_. – Elijah Lynn Jul 31 '19 at 07:06
  • For php 7.3 open php.ini and ucomment `extension=gd2` – MattJamison Jun 30 '21 at 21:08
3

For php7.1 do:

sudo apt-get install php7.1-gd

and restart webserver. For apache do

sudo service apache2 restart
Mubashar Abbas
  • 5,536
  • 4
  • 38
  • 49
2

If You're using php5.6 and Ubuntu 18.04 Then run these two commands in your terminal your errors will be solved definitely.

sudo apt-get install php5.6-gd

then restart your apache server by this command.

 sudo service apache2 restart
2

I've PHP 7.3 and Nginx 1.14 on Ubuntu 18.

# it installs php7.3-gd for the moment
# and restarts PHP 7.3 FastCGI Process Manager: php-fpm7.3.
sudo apt-get install php-gd

# after I've restarted Nginx
sudo /etc/init.d/nginx restart

Works!

Pax Beach
  • 2,059
  • 1
  • 20
  • 27
2

Enable gd via XAMPP in windows

First stop the server and go to config

enter image description here

Find the ;extension=gd

enter image description here

Remove the ; and save

enter image description here

and start the server then you will fixed the issue.

Thilina Dharmasena
  • 2,243
  • 2
  • 19
  • 27
0

In CentOS (but the same may apply to other distros too) if you install the php7x-gd module followed by Apache restart and still the php -i does not show the GD Support => enabled it might mean that the php.ini was not automatically configured to support this extension.

All you have to to is either to edit the /etc/php/php.ini or to create a /etc/php.d/gd.ini file with the following content:

[gd]
extension=/path/to/gd.so # use the gd.so absolute path here
Eugen Mihailescu
  • 3,553
  • 2
  • 32
  • 29
0

in my case:

I am using PHP 8 I had to search for ;extension=gd in my php.ini file. Then removed the ; and error has gone.

Mohamed Mahfouz
  • 201
  • 1
  • 5
  • 14