GD Library extension not available with this PHP installation Ubuntu Nginx

108,871

Solution 1

The GD Graphics Library is for dynamically manipulating images. For Ubuntu you should install it manually:

  • PHP5: sudo apt-get install php5-gd
  • PHP7.0: sudo apt-get install php7.0-gd
  • PHP7.1: sudo apt-get install php7.1-gd
  • PHP7.2: sudo apt-get install php7.2-gd
  • PHP7.3: sudo apt-get install php7.3-gd
  • PHP7.4: sudo apt-get install php7.4-gd
  • PHP8.0: sudo apt-get install php8.0-gd
  • PHP8.1: sudo apt-get install php8.1-gd

That's all, you can verify that GD support loaded:

php -i | grep -i gd

Output should be like this:

GD Support => enabled
GD headers Version => 2.1.1-dev
gd.jpeg_ignore_warning => 0 => 0

and finally restart your apache:

sudo service apache2 restart

Solution 2

window users using xampp apache server.

Go to php folder in xampp and open the php.ini and php configurations settings file, and change the line ;extension=gd2 or the line ;extension=gd to just extension=gd2

NB that php version 8 is stored as ;extension=gd

Solution 3

For my fellow Windows users, find the line ;extension=gd2 in your php.ini file and change it to extension=gd2.

Regards

Solution 4

@limonte's answer is correct, but if you're using PHP7+, you should use following command:

sudo apt-get install php7.0-gd

If you don't know what version of PHP you're using, just type

php -v

Output should start with something similar to PHP 7.0.8-0ubuntu0.16.04.2 (cli) ( NTS ).

Solution 5

Php 5.6 worked with below command

PHP5.6: sudo apt-get install php5.6-gd

after installing restart server

sudo service apache2 restart
Share:
108,871
Saeed Vaziry
Author by

Saeed Vaziry

I am a software engineer since 2010. I've done many projects and managed to ship them to the production in these years. I have experience developing multi-platform applications such as web applications in both Back-End and Front-End as a senior developer or a lead developer. I've worked with many teams and learned much from them cause I love to learn new things in my career. Some of my skills: PHP Laravel JavaScript Nodejs Nestjs Vuejs HTML, CSS, JQuery Real time applications Mysql, Mongodb, MSSQL DevOps

Updated on November 26, 2021

Comments

  • Saeed Vaziry
    Saeed Vaziry over 2 years

    I am using Laravel web framework on my ubuntu 14.04 server and Nginx web server, I have this error when I try to upload a file using Laravel to the server. my upload directory is on the public/uploads folder that has 777 permission.

  • FosAvance
    FosAvance over 7 years
    sudo apt-get install php5.6-gd for PHP 5.6 version
  • Chintan7027
    Chintan7027 over 7 years
    sudo apt-get install php7.0-gd
  • ThatMSG
    ThatMSG about 7 years
    ...and don't forget to reload apache2 afterwards e.g. service apache2 reload
  • mutiemule
    mutiemule about 5 years
    If you're using apache server, after installing, reload sudo systemctl restart apache2 Then go back and reload your page and upload a new doc. It should work
  • andromeda
    andromeda almost 5 years
    If you're using php's internal server (php artisan serve for the artisans), make sure you stop the server and restart it. Restarting/reloading apache won't help.
  • Deepak3301086
    Deepak3301086 over 3 years
    if above command not works. Use "yum search gd" you will see output as php72-gd.x86_64, php71-gd.x86_64, php73-gd.x86_64 etc. Then Use command "sudo yum install php72-gd.x86_64" it works for me.
  • javaxiss
    javaxiss about 3 years
    for PHP 8, the line would be extension=gd and not extension=gd2
  • shaedrich
    shaedrich about 3 years
    Thanks for your answer but it's mostly a duplicate of @Arinzehills's answer
  • akinuri
    akinuri almost 3 years
    @EyadMohammedOsama I bet you hate multi-purpose things.
  • Chauhan Ajay
    Chauhan Ajay almost 3 years
    may be extension=gd2 OR extension=gd ony one of them (100% Workes fo me)
  • runtimeTerror
    runtimeTerror over 2 years
    @akinuri sure he does, this answer actually helped me!