Amazon EC2 – PHP GD image library

I’ve got a brand new install of WordPress setup and activated a custom-built theme along with a good amount of plugins. In the posts, I have built it so the user can create a post, upload an image as a thumbnail and it will automatically resize the image to a custom size set in my functions.php file.

All this has been working on my local end (MAMP) correctly but when I tried making everything work on our Amazon EC2 server, the images do not resize to the size set. They resize by actual code but do not resize the actual image and save it in the new size.

Read More

Apologies if the question/subject is completely non-sense but I have little to no experience with Amazon EC2 servers and I have been placed into a situation where the person in charge of all the work within EC2 had to leave the project.

I’m assuming that this has to do with the GD library not being installed.. I created a test page with phpinfo() and didn’t see a GD area on the results page.

How would I go about installing the library on my Amazon EC2 server? I just learned how to connect to the server via Terminal and that’s all I’ve got for now.. so you get an idea of how much I know about the subject.

Related posts

Leave a Reply

5 comments

  1. I’m guessing you have some type of Linux installed, probably Ubuntu or CentOS.

    Ubuntu: sudo apt-get install php5-gd
    CentOS: sudo yum install php-gd

    You probably have to restart Apache afterwards: service httpd restart or service apache2 restart — the names differ from distribution to distribution.

    Let me know if this works!

  2. In my case, I was getting error like there is version conflict between different versions of php-common when I entered “yum install php-gd” so I checked my php version using “php -v” in shell and then installed the corresponding gd using “yum install php56-gd” because I had php 5.6 installed in my machine.

    Hope someone will get help from this.

    Cheers

  3. to avoid compatibility problems first do:

    php --version
    

    to know your php version

    the answer is something in the form PHP X.Y.Z

    so you have to take X, Y and do:

    sudo yum install phpXY-gd
    

    for instance if php –version says PHP 5.5.26

    you will do:

    sudo yum install php55-gd
    
  4. In my case of ec2 server running Amazon Linux 2 with php version 7.2.24, following was the sequence:

    sudo yum install php-gd
    

    But event after repeat server restart with

    sudo systemctl restart httpd
    

    it was not working unless I rebooted with

    sudo reboot
    
  5. In Amazon Linux, we have to add the following line to the etc/php.ini file

    extension=gd.so

    Step 1: Install the package using following command

    sudo yum install php-gd

    Step 2: Include the following line to the etc/php.ini file

    extension=gd.so

    If the line is commented, then uncomment it.

    Step 3: Restart the httpd service

    sudo service httpd restart