At liberiangeek.net, we’re constantly looking for ways to improve our blog performance. We’ve been tweaking our server settings, installing new caching plugins and migrating our servers to Google Compute Engine.
All of the above steps are to help improve our website speed and enable better user experience. Recently we switched our domain registrar to Google Domains, moved our server to Google Compute Engines, switched to Nginx web server from Apache, and installed WP Super Cache, a WordPress plugin to cache static pages which may improve performance.
After implementing all of the above tasks, we improved our website performance a lot. Our pages were mostly loading under 4 seconds, which isn’t a bad thing if you can get majority of your pages to load under 4 seconds.
Well, we still weren’t satisfied. WP Super Cache is great but wasn’t working for us as expected. In fact, there’s not an official support for Nginx web server, so we had to manually configure some settings in order to function with Nginx.
One such setting was not to cache pages for logged-in users. That feature didn’t work as expected. Some of our pages were being cached, but those cached pages weren’t being deleted as we had hoped.
Don’t get me wrong, WP Super Cache is great for most blogs out there. It will help improve your server’s performance. But if you’re like me who constantly looking for ways to improve, there may be other options.
While looking for a simple caching plugin that works with Nginx, I stumbled upon WP-FFPC WordPress plugin.
This plugin works with any web server, including Apache2, Nginx, Lighttpd and others. When using Nginx with WP-FFPC, it’s recommended to also install memcached as well as its PHP plugin.
This tutorial is going to show you how to easily install Memcached and its PHP extensions so that it can be used in CentOS 7.
Memcached is a distributed memory object caching program. Instead of caching content to the hard drive, content are cached in memory which is much faster than caching on the hard disk.
Here’s how its developer describe memcached
Free & open source, high-performance, distributed memory object caching system, generic in nature, but intended for use in speeding up dynamic web applications by alleviating database load.
When you’re ready to install Memcached, continue with the steps below.
- Installing Memcached in CentOS 7
To install Memcached in CentOS 7, you must enable some repositories in CentOS 7 since memcached isn’t readily available to install. Two important and great repositories to have are EPEL and Remi.
Both offer great software packages are mostly not readily available to install in CentOS 7. So, to get started installing memcached, enable these repositories.
- Installing EPEL 7 in CentOS 7
First enable EPEL 7 in CentOS 7. To do that, run the commands below.
cd /tmp/ && wget http://dl.fedoraproject.org/pub/epel/beta/7/x86_64/epel-release-7-1.noarch.rpm
Next, run the commands below to install the EPEL repository just downloaded.
sudo yum install epel-release-7-1.noarch.rpm
- Install Remi repository in CentOS 7
To install Remi, another great repository for CentOS, run the commands below.
rpm --import http://rpms.famillecollet.com/RPM-GPG-KEY-remi
Finally, run the commands below to install it.
rpm -ivh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
That’s it! Now that those two repositories are installed, go and run the commands below to install Memcached and its PHP extensions.
sudo yum install memcached libmemcached-devel
After installing, edit memcached’s configuration file and make the following changes for OPTIONS=”” line.
Save the file and you’re done.
To verify if Memcached is working, run the commands below
watch "echo stats | nc 127.0.0.1 11211"
If nc isn’t installed, run the commands below to install it
sudo yum install nc