Memcached can be used to speed up WordPress and WooCommerce. Many WordPress plugins and themes use transients as settings. These transients are temporary and by default are stored in the MySQL database. This means MySQL will be used when retrieving these settings from the database stored on the hard drive. Memcached uses RAM to store these transients instead which makes retrieving them significantly faster.
Install Latest Memcached Object Cache WordPress PHP5 Debian
This is for php5, a new guide will be published for php7
Install the Memcached Daemon
Update your repository list and install libmemcached and the current version of the memcached daemon in the repository as well as the libraries and building tools for compiling the latest memcached from source.
At this point memcached is installed, but the version may not be current, you can use telnet to check
You will see this output on the screen
Trying 127.0.0.1...
Connected to 127.0.0.1.
Escape character is '^]'.
Enter the version command and press Enter
You will see the memcached version
VERSION 1.4.21
Exit the telnet session by entering quit
And leaving was successful
Connection closed by foreign host.
Build the latest Memcached
This bash snippet will get the latest download link from the Memcached website, download and extract it
Now enter the Memcached folder, build the latest memcached from source and install it. If you don’t want to use authentication then remove the –enable-sasl part
Configure Memcached on Debian
Back up the original memcached configuration and create a new one
Paste this memcached configuration so it listens on localhost (127.0.0.1)
Ctrl+X, Y and Enter to Save
You can check the memcached version using the new built-in command
Now the Memcached version is displayed
memcached 1.4.26
Now we just need the latest C extension for PHP5 called pecl memcached so PHP can interface with the memcached daemon through the libmemcached C extension.
Build the Latest PECL PHP Memcached Extension
Install git so you can grab the latest version of memcached
Enter the temporary directory and grab the latest php-memcached extension source code
Enter the source directory, compile and install it, if you do not want SASL (authentication) support remove the –enable-sasl
You should eventually see that it was successful
Installing shared extensions: /usr/lib/php5/20131226/
All that is left to do is enable the memcached php extension.
Add the memcached extension
Since I use php5-fpm with nginx I am symlinking into the php5 fpm and cli folders.
Apache2 users will want to symlink this file
Now restart php5-fpm or Apache
I recommend using the free Memcached is your friend plugin with fixes to prevent plugin and PHP crashes.
You can find the WordPress Memcached status under Tools > Memcached.
1 thought on “Install Latest Memcached Object Cache WordPress PHP5 Debian”
Comments are closed.