We’ll now walk through the installation of MemCache on our Ubuntu 20.04 environment. The very basic definition of what Memcached is is as follows. Memcached is a free and open-source program that eases the re-extraction of information from a database with an object caching program, which allows for PHP-based apps such as WordPress and Joomla to run smoothly without much latency. In other words, it helps with the database loads, since the re-extraction of information is much easier.
Many users have issues installing Memcached on an Ubuntu 20.04 OS. We have decided to create a tutorial, where you can manually install and activate Memcached on your Ubuntu 20.04. Make sure to follow all steps below in order to succeed. In case you are stuck somewhere, feel free to ask away in the comments section, at the very end of this tutorial. Alternatively, subscribe to a fully managed VPS hosting plan, and let our expert customer support take care of things for you.
Let’s proceed with the installation.
1. Updating your system
First, we need to keep our system up, after login up on your SSH server with:
We need to run the updating and upgrading command, as you can see below:
apt update -y
apt upgrade -y
2. Installing the service
Once you finish the update of your system, you can install the MemCache service with the following command:
apt install memcached libmemcached-tools -y
After you install the service, you can see the status from it with these commands:
systemctl status memcached
service memcached status
That’s all, your MemCache service is now up and running and by default, it will run on the IP address 127.0.0.1 with port 11211.
If for some reason you need to change this port to another one, you can edit the following file:
To change the port of your Memcached, you need to switch the value after the -p parameter:
# Default connection port is 11211
You can also set the Memcached to run on an IP address of your server instead of the local one but this is a BAD practice since there are some methods to use your service to multiplicate the packets and make a DDoS attack. You can read more about this attack here.
Once you change what you need in the Memcached conf, you can restart the service using the same command shown before:
systemctl restart memcached
service memcached restart
We are done from here, you successfully installed Memcached on your server. You need to integrate it with your PHP applications. This can be done easily and you just need to figure it out by reaching a web developer or researching on the internet.
Of course, if you have an active VPS hosting package with us, you can open a ticket through your dashboard and our admins will make all the setup of the Memcache for you. We are available 24 hours per day, 7 days a week, 365 days per year to help you.