Install Memcache in Ubuntu 16.04

Install Memcache in Ubuntu 16.04
by Janeth Kent Date: 28-09-2016 php memcache ubuntu linux


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.

Getting Started

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.

Tutorial

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.

nano /etc/memcached.conf

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
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.

nano /var/www/html/index.php

<?php
phpinfo();
?>

To run this page, visit http://your_ip/index.php. Look for any information on your memcached module.

Conclusion

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.

 
by Janeth Kent Date: 28-09-2016 php memcache ubuntu linux hits : 3800  
 
Janeth Kent

Janeth Kent

Licenciada en Bellas Artes y programadora por pasión. Cuando tengo un rato retoco fotos, edito vídeos y diseño cosas. El resto del tiempo escribo en MA-NO WEB DESIGN END DEVELOPMENT.

 
 
 

Related Posts

HTTP Cookies: how they work and how to use them

Today we are going to write about the way to store data in a browser, why websites use cookies and how they work in detail. Continue reading to find out how…

The most popular Array Sorting Algorithms In PHP

There are many ways to sort an array in PHP, the easiest being to use the sort() function built into PHP. This sort function is quick but has it's limitations,…

MySQL 8.0 is now fully supported in PHP 7.4

MySQL and PHP is a love story that started long time ago. However the love story with MySQL 8.0 was a bit slower to start… but don’t worry it rules…

Linux For Dummies: Permissions

In the previous articles I made a short introduction to the Unix world and in the following article I have dealt with the basic commands for the file system management. Today we are…

Linux for Dummies: Ubuntu Terminal

I introduced in the previous article, available here, the basic concepts concerning the Linux world. Today we are going to have a look to some basic operations that we can perform…

The Best RSS Readers for Ubuntu

Even if most of the tech experts actively claim that RSS (Rich Site Summary) is dead especially after Google Reader was discontinued 5 years ago but it isn’t yet as…

A roadmap to becoming a web developer in 2019

There are plenty of tutorials online, which won't cost you a cent. If you are sufficiently self-driven and interested, you have no difficulty training yourself. The point to learn coding…

How to install Letsencrypt Certificates with Certbot in Ubuntu

In this article we will explain how to install, manage and configure the SSL Security certificate, Let's Encypt in NGINX server used as proxy. This certificate is free but does…

How to Set up a Fully Functional Mail Server on Ubuntu 16.04 with iRedMail

Setting up your own mail server from scratch on Linux is complex and tedious, until you meet iRedMail. This tutorial is going to show you how you can easily and…

10 PHP code snippets to work with dates

Here we have some set of Useful PHP Snippets, which are useful for PHP Developers. In this tutorial we'll show you the 10 PHP date snippets you can use on…

8 Free PHP Books to Read in Summer 2018

In this article, we've listed 8 free PHP books that can help you to learn new approaches to solving problems and keep your skill up to date.   Practical PHP Testing This book…

Best Websites to Learn Coding Online

You know and we know that it’s totally possible to learn to code for free... If you can teach yourself how to write code, you gain a competitive edge over your…

We use our own and third-party cookies to improve our services, compile statistical information and analyze your browsing habits. This allows us to personalize the content we offer and to show you advertisements related to your preferences. By clicking "Accept all" you agree to the storage of cookies on your device to improve website navigation, analyse traffic and assist our marketing activities. You can also select "System Cookies Only" to accept only the cookies required for the website to function, or you can select the cookies you wish to activate by clicking on "settings".

Accept All Only sistem cookies Configuration