Trying to figure out how to create a website? Today you will find out! An…
Today I ran into a problem when I was trying to setup a new WordPress based website hosted on a clean LEMP server using Ubuntu. The thing I noticed was that thumbnails and featured images where not properly resized, well they weren’t resized at all. Correct CSS styles were applied but image size remained uncropped. I did some research on WordPress.org and other WordPress related support forums but could find the answer.
Actually the first thing that came in my mind was that I made some mistakes in my theme pre as this was my own custom theme. I red every topic about
and couldn’t find a single mistake in my pre. And turned out that I didn’t suck at PHP and WordPress functionality but it turned out to be a bigger problem and it has something to do with my server configuration (Ubuntu in my case). Once I realized that it took a moment to realize what is missing – GD module for PHP5.
GD module for php5 is used to handling graphics directly from PHP scripts. It supports the PNG, JPEG, XPM formats as well as Freetype/ttf fonts. If you don’t have this PHP module installed it means that several WordPress features won’t work, such as image resizer, image cropping, thumbnail and featured image generator and even oEmbed for Twitter, SoundCloud and other content won’t work. I learned this a hard way.
If you are facing the same issues with your WordPress installation you are in the right place because I will show you have to fix this. This will work only if you are running your own VPS/Dedicated server running Ubuntu and won’t help if you are on shared hosting account. However, you can ask them to install GD PHP5 module for you but most shared host already has it installed. If you are on shared web hosting it is highly likely that featured images and thumbnails are not generated because of some other reason.
Solution for Ubuntu and Debian:
To install GD PHP5 module on Ubuntu (any version after 12.04) and other Debian based systems you should run the following commands:
sudo apt-get install php5-gd sudo service nginx restart
In case you are on Apache (LAMP) server then you can restart it like this
sudo service apache2 restart
Solution for CentOS
sudo yum install php-gd sudo service httpd restart
These simple commands will install GD PHP5 module for your Ubuntu/Debian or CentOS which will enable WordPress functionalities such as thumbnail generator, featured image generator, image editor, oEmbed and probably some more that I didn’t notice.
Let me know if this is not the case in your situation and I will try to help.