Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

problem with GD image extension on Amazon Linux 2

I've recently created LAMP servers on EC2 instances using Amazon Linux AMI.

using

sudo yum install -y php70-gd

I installed the GD extension. This all worked fine and i could upload and manipulate images using PHP.

Now I've created a LAMP server using Amazon Linux 2 using the tutorial here :https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-lamp-amazon-linux-2.html

My problem is that I can't get the GD extension to work. i tried using

sudo yum install -y gd

and this seemed to install an older version of GD. I tried

sudo yum install php-gd

and this seems to install the latest version of the extension.

But the gd extension still doesn't seem to work. when I enter yum info gd In the console it shows :

Loaded plugins: extras_suggestions, langpacks, priorities, update-motd
Installed Packages
Name        : php-gd
Arch        : x86_64
Version     : 7.2.5
Release     : 3.amzn2.0.2
Size        : 769 k
Repo        : installed
From repo   : amzn2extra-lamp-mariadb10.2-php7.2
Summary     : A module for PHP applications for using the gd graphics library
URL         : http://www.php.net/
License     : PHP and BSD
Description : The php-gd package contains a dynamic shared object that will add
            : support for using the gd graphics library to PHP.

when I try an image resize script I get an error. I've tried this test script :

$testGD = get_extension_funcs("gd"); // Grab function list 
if (!$testGD){ echo "GD not installed."; exit; }
echo"<pre>".print_r($testGD,true)."</pre>";

and this gives me the result

GD not installed.

so obviously something is not right. Can anyone help?

thanks

like image 466
Dog Avatar asked Sep 06 '18 11:09

Dog


People also ask

What is the GD extension?

What is a GD extension? A GD file contains source code written in GDScript, which is a scripting language used to create and modify content in Godot Engine. It stores code in a syntax similar to Python, which may include identifiers, keywords, operators, variables, constants, functions, and comments.15-Oct-2019.

How do I migrate Amazon AMI to Amazon Linux 2?

To migrate to Amazon Linux 2, launch an instance or create a virtual machine using the current image. Install your application on Amazon Linux 2, plus any packages required by your application. Test your application, and make any changes required for it to run on Amazon Linux 2.

What version of Linux is Amazon Linux 2 based on?

At the time of writing, the default kernel in Amazon Linux 2, which receives long-term support from Amazon, is Linux Kernel 4.14.


5 Answers

$ sudo yum install -y php-gd
$ sudo systemctl restart php-fpm

No need to reboot

like image 64
shane Avatar answered Oct 22 '22 13:10

shane


Amazon Linux 2 uses Apache with PHP-FPM instead of mod_php. So you need to restart the php-fpm process to reload PHP with the new extension.

sudo systemctl restart php-fpm

like image 34
rmarscher Avatar answered Oct 22 '22 12:10

rmarscher


I'm running php 7.2.14 on Amazon Linux 2 and this worked for me:

$ sudo yum update -y
$ sudo yum install -y php-gd
$ sudo reboot
like image 32
mtm Avatar answered Oct 22 '22 13:10

mtm


And solved... Turns out restarting apache with

sudo systemctl restart httpd

wasn't enough to load the newly installed component...

what i needed to do was

sudo reboot

and everything works...

Why did't i try that 24 hours ago!

like image 39
Dog Avatar answered Oct 22 '22 11:10

Dog


my PHP version was - PHP 7.2.18 $ php -v

I had to install -y php72-gd

$ sudo yum update -y $ sudo yum install -y php72-gd $ sudo reboot

like image 40
smakintel.com Avatar answered Oct 22 '22 12:10

smakintel.com