How to install Memcached on Ubuntu 17.04

To install Memcached on Ubuntu 17.04

Memcached is a high performance system daemon that allows you to cache information on RAM memory this allows you speed up the applications and websites that are powered by databases. It also helps you to avoid bad performance on your dedicated or VPS server. It is very useful for optimizing dynamic websites and enabled speed by caching objects in memory. Memcached does not write to disk, instead store its content in system memory which makes it faster. It is to be noted that majority of CMS tools that are used today have tools to take advantage of Memcached. If configured correctly, you may be able to see huge improvements to your websites and applications. It is also very simple to install Memcached and this tutorial covers the ground on the installation of Memcached on Ubuntu 17.04.

Installing Memcached

In order to install Memcached on Ubuntu, you should have Apache server installed in your machine in prior.

root@linuxhelp:~# apt-get install apache2 -y
Reading package lists... Done
Building dependency tree      
Reading state information... Done
The following additional packages will be installed:
  apache2-bin apache2-data apache2-utils libapr1 libaprutil1
  libaprutil1-dbd-sqlite3 libaprutil1-ldap liblua5.2-0
Suggested packages:
  apache2-doc apache2-suexec-pristine | apache2-suexec-custom
The following NEW packages will be installed:
  apache2 apache2-bin apache2-data apache2-utils libapr1 libaprutil1
  libaprutil1-dbd-sqlite3 libaprutil1-ldap liblua5.2-0
0 upgraded, 9 newly installed, 0 to remove and 306 not upgraded.
Need to get 1,580 kB of archives.
.
.
.
Processing triggers for libc-bin (2.24-9ubuntu2) ...
Processing triggers for ureadahead (0.100.0-19) ...
Processing triggers for systemd (232-21ubuntu2) ...
Processing triggers for ufw (0.35-4) ...

Once Apache is installed, you shall proceed with the installation of the memcached application. Run the following command for the same purpose.

root@linuxhelp:~# apt-get install memcached
Reading package lists... Done
Building dependency tree      
Reading state information... Done
Suggested packages:
  libcache-memcached-perl libmemcached libanyevent-perl libyaml-perl
  libterm-readkey-perl
The following NEW packages will be installed:
  memcached
0 upgraded, 1 newly installed, 0 to remove and 306 not upgraded.
Need to get 101 kB of archives.
After this operation, 272 kB of additional disk space will be used.
Get:1 http://in.archive.ubuntu.com/ubuntu zesty/main amd64 memcached amd64 1.4.33-1ubuntu2 [101 kB]
Fetched 101 kB in 0s (107 kB/s)
Selecting previously unselected package memcached.
(Reading database ... 171630 files and directories currently installed.)
Preparing to unpack .../memcached_1.4.33-1ubuntu2_amd64.deb ...
Unpacking memcached (1.4.33-1ubuntu2) ...
Processing triggers for ureadahead (0.100.0-19) ...
Setting up memcached (1.4.33-1ubuntu2) ...
Created symlink /etc/systemd/system/multi-user.target.wants/memcached.service &rarr  /lib/systemd/system/memcached.service.
Processing triggers for systemd (232-21ubuntu2) ...
Processing triggers for man-db (2.7.6.1-2) ...
Processing triggers for ureadahead (0.100.0-19) ...

It doesn’ t get over with this you should also install all the necessary PHP modules. So, run the following command which installs those PHP modules.

root@linuxhelp:~#  apt-get install -y  php libapache2-mod-php php-memcached php-cli
Reading package lists... Done
Building dependency tree      
Reading state information... Done
The following additional packages will be installed:
  libapache2-mod-php7.0 libmemcached11 php-common php-igbinary php-msgpack
  php7.0 php7.0-cli php7.0-common php7.0-json php7.0-opcache php7.0-readline
Suggested packages:
  php-pear
The following NEW packages will be installed:
  libapache2-mod-php libapache2-mod-php7.0 libmemcached11 php php-cli
  php-common php-igbinary php-memcached php-msgpack php7.0 php7.0-cli
  php7.0-common php7.0-json php7.0-opcache php7.0-readline
0 upgraded, 15 newly installed, 0 to remove and 306 not upgraded.
.
.
.
Setting up php-memcached (3.0.1+2.2.0-1) ...
Setting up libapache2-mod-php (1:7.0+49) ...
Setting up php7.0 (7.0.22-0ubuntu0.17.04.1) ...
Setting up php (1:7.0+49) ...

Later, you need to start the Apache and Memcached service.

root@linuxhelp:~# systemctl start apache2 memcached

And then, you should create a PHP file in HTML location for getting the PHP information. Run the command for creating that file.

root@linuxhelp:~# nano /var/www/html/info.php

In that file you need to add the following line.

< ?php
phpinfo() 
?> 

Once it is done, you need to restart Apache2 service.

root@linuxhelp:~# systemctl restart apache2

Open the browser and give http://localhost/info.php as URL. The PHP modules which are installed in server are displayed.

You can scroll down to see if Memcached is installed in your machine.

With this, the installation of Memcached on Ubuntu 17.04 comes to an end.

FAQ
Q
Can memcached work with ASPX?
A
There are ports and interfaces for many languages and environments. ASPX relies on an underlying language such as C# or VisualBasic, and if you are using ASP.
Q
How is an event such as a crash of one of the memcached servers handled by the Memcached client?
A
There is no automatic handling of this. If your client fails to get a response from a server, code a fallback mechanism to load the data from the MySQL database.
Q
What is a recommended hardware configuration for a Memcached server?
A
memcached has a very low processing overhead. All that is required is spare physical RAM capacity. A memcached server does not require a dedicated machine. If you have web, application, or da
Q
What is the Purpose of Memcached?
A
Memcached is a high performance system daemon that allows you to cache information on RAM memory; this allows you speed up the applications and websites that are powered by databases. It also
Q
Can memcached be run on a Windows environment?
A
No. Currently memcached is available only on the Unix/Linux platform. There is an unofficial port available, see http://www.codeplex.com/memcachedproviders.