4.9 C
Amsterdam
Saturday, December 5, 2020

How to install Memcached on Ubuntu 20.04?

Must read

How To Install Docker Swarm On Ubuntu 20.04

In this tutorial, you'll learn that how to Install Docker Swarm on Ubuntu 20.04. Docker Swarm is most popular tool that can be used...

How To Install Keeweb Password Manager On Ubuntu 20.04

Today we are going to learn that how to install KeeWeb Passwrod Manager On Ubuntu 20.04. KeeWeb Password Manager provides the best and easy...

How to change the MAC address in Windows 10

Hello! How are you? Today we will see how to change the MAC address on a computer with Windows 10. In fact, it is...

How To Configure Slave BIND DNS Server On Ubuntu 20.04

In our previous guide we covered the setup of Master(Primary) DNS Server. Here we'll learn that how to configure slave bind dns server on...
angeloma
angeloma
Senior Writer and partner

Hi, folks. In this post, you’ll learn how to install Memcached on Ubuntu 20.04, and also we’ll quickly examine some configuration parameters.

For those who don’t know, Memcached Free & open-source, high-performance, distributed memory object caching system. Using Memcached will speed up the loading of data from your web sites and applications. If I tell you that Netflix uses it, then you can know that Memcached is a tool to take into account.

Memcached is simple yet powerful. Its simple design promotes quick deployment, ease of development, and solves many problems facing large data caches.

So, let us start.

Install Memcached on Ubuntu 20.04

Being such an important tool nowadays, Memcached is included in the official distribution repositories. This makes installation much easier but is also a fairly secure method.

So, open a terminal and run the following command:

sudo apt install memcached libmemcached-tools
Reading package lists… Done
Building dependency tree
Reading state information… Done
The following additional packages will be installed:
libmemcached11 libmemcachedutil2
Suggested packages:
libanyevent-perl libcache-memcached-perl libmemcached libyaml-perl
The following NEW packages will be installed:
libmemcached-tools libmemcached11 libmemcachedutil2 memcached
0 upgraded, 4 newly installed, 0 to remove and 87 not upgraded.
Need to get 293 kB of archives.
After this operation, 1064 kB of additional disk space will be used.
Do you want to continue? [Y/n]

Then the installation of the program will begin.

Like other programs, Memcached is managed as a system service. So with the systemctl command, we can start it, stop it, restart it, or see its status.

To start it and make it start with the system

sudo systemctl start memcached
sudo systemctl enable memcached

And to verify their status:

sudo systemctl status memcached
● memcached.service - memcached daemon
Loaded: loaded (/lib/systemd/system/memcached.service; enabled; vendor preset: enabled)
Active: active (running) since Wed 2020-08-26 22:20:43 UTC; 39s ago
Docs: man:memcached(1)
Main PID: 2047 (memcached)
Tasks: 10 (limit: 846)
Memory: 1.8M
CGroup: /system.slice/memcached.service
└─2047 /usr/bin/memcached -m 64 -p 11211 -u memcache -l 127.0.0.1 -P /var/run/memcached/memcached.pid
Aug 26 22:20:43 osradar systemd[1]: Started memcached daemon.
1.- Memcached status
1.- Memcached status

Configuring Memcached on Ubuntu 20.04

The Memcached configuration file is /etc/memcached.conf and there you can check all the options it presents.

Let’s modify it, but first let’s backup the original file:

sudo cp /etc/memcached.conf /etc/memcached.conf.bak
sudo nano /etc/memcached.conf

We can modify the port of the application, which is 11211 by default

-p [port]

Also, we can modify the number of incoming connections which by default is 1024

-c [number]

Finally, the IP address of the server where Memcached is installed must be entered:

-l your-server-ip

Save the changes and exit the editor.

To apply the changes, you can restart the service

sudo systemctl restart memcached

Enabling the PHP support

The idea is that web applications should take advantage of Memcached, so support must be enabled.

If you already have a LAMP server installed and running, just install this package:

php-memcached

Then restart Apache.

sudo systemctl restart apache2

And to demonstrate that Memcached is enabled for use in PHP, create a phpinfo file.

sudo nano /var/www/html/phpinfo.php

And add the following:

<?php
phpinfo();
?>

Save the changes and exit the editor.

Now with your favorite web browser, open it.

http://your-server/phpinfo.php

When you scroll down, you will see the Memcached section.

2.- Memcached and PHP working on Ubuntu 20.04
2.- Memcached and PHP working on Ubuntu 20.04

This confirms the installation and configuration. Now your applications made in PHP will take advantage of Memcached.

Conclusion

In this post, you have learned the first steps with Memcached installing it and configuring it. Also enabling support for the PHP language which is the most popular language for web applications.

So share this post and join our Telegram Channel.

More articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

-

Latest article

How To Install Docker Swarm On Ubuntu 20.04

In this tutorial, you'll learn that how to Install Docker Swarm on Ubuntu 20.04. Docker Swarm is most popular tool that can be used...

How To Install Keeweb Password Manager On Ubuntu 20.04

Today we are going to learn that how to install KeeWeb Passwrod Manager On Ubuntu 20.04. KeeWeb Password Manager provides the best and easy...

How to change the MAC address in Windows 10

Hello! How are you? Today we will see how to change the MAC address on a computer with Windows 10. In fact, it is...

How To Configure Slave BIND DNS Server On Ubuntu 20.04

In our previous guide we covered the setup of Master(Primary) DNS Server. Here we'll learn that how to configure slave bind dns server on...

Install Fossil on Linux – An alternative to Git

Hello, friends. In this post, we will talk about a serious alternative to Git. In a few words, we'll show you how to install...
x