Amazon EC2 - PHP GD image library

2019-06-15 16:11发布

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.

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.

3条回答
何必那么认真
2楼-- · 2019-06-15 16:42

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楼-- · 2019-06-15 16:51

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楼-- · 2019-06-15 17:06

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!

查看更多
登录 后发表回答