Install Memcache in Ubuntu 16.04
Memcache is an in-memory key-value store that is ideal for speeding up infrastructure. Perhaps a slow operation needs access to rarely-changing data, or files are accessed on slow storage systems. By integrating Memcache, the result of slow queries or reads can be keyed to a unique value, and future accesses can read the data directly from RAM. Memcache is a convenient infrastructural tool for speeding up a variety of slow operations.
This guide expects that you have root access on an Ubuntu 16 server. It also expects the presence of a LAMP stack. When complete, you’ll have Memcache installed, along with the necessary components to integrate it into your LAMP app or service.
Begin by installing the Memcache daemon package, called memcached.
apt-get install memcached -y
Next we’ll need the Memcache PHP extension. This will provide the necessary functions to integrate Memcache into your applications, or to activate its support in apps for which integrations already exist.
apt-get install php-memcached -y
Memcached must now be configured. We’ll edit its configuration file to make a few key optimizations.
Change this value to one that makes sense for your circumstances. Particular switches of interest are “-p” to change the memcached port, “-m” to allocate RAM to the cache, and “-c” to set the maximum connections allowed to the cache daemon.
Once you’ve reconfigured memcached, and when the PHP module is installed, you’ll need to restart memcached. You’ll also need to restart Apache so any hosted apps pick up the new module.
systemctl restart httpd.service
systemctl restart memcached.servive
Let’s ensure that the memcached module is loaded.
php -m | grep memcached
We’ll now create a phpinfo page. This function dumps lots of valuable information on your PHP environment. This should include details on the memcached module.
To run this page, visit http://your_ip/index.php. Look for any information on your memcached module.
The Memcache service is now installed, enabled, and configured for your specific needs. The PHP module is also installed, and is available in your LAMP stack. Any PHP applications that might benefit from a fast, in-memory caching layer can now integrate with this new installation.
Comments area, use one of your social accounts to log-in and post a comment.
Responses to the post
- How to install and setup Varnish in Ubuntu 16.04
- Install Apache, MariaDB and PHP7 on Ubuntu 16.04
- How to force screen/s resolution in Ubuntu and make it permanent
- Mallorca's Ham
- Ubuntu servers security: 25 security tools to armor your system
- Install Syncthing on Ubuntu 16.04 using Debian Repository
- SQLMAP installation and usage in Ubuntu and Kali linux
- PHP Libraries For Summer 2016
- PHP7: Install PHP7 with NGINX and MEMCACHE in Ubuntu 14.04
- PHP:How To Upgrade to PHP 7 on Ubuntu 14.04
- Install HHVM + Nginx on Ubuntu 14.04
- PHP7: Guide and References to all the changes between version 5.x and 7 of PHP