Memcached is a free and open-source distributed memory caching system that is often used to speed up dynamic web applications by caching data in memory. Installing Memcached on Ubuntu is a straightforward process.
Firstly, update the package list on your server using the following command:
sudo apt-get update
Install Memcached by running the following command:
sudo apt-get install memcached
During the installation process, you may be prompted to confirm the installation of dependencies required for Memcached.
Once the installation is complete, check if Memcached is running by executing the following command:
systemctl status memcached
If Memcached is running successfully, you should see output similar to the following:
memcached.service - memcached daemon Loaded: loaded (/lib/systemd/system/memcached.service; enabled; vendor preset: enabled) Active: active (running) since Mon 2023-04-25 11:48:05 UTC; 2 days ago Main PID: 1234 (memcached) Tasks: 3 (limit: 4915) Memory: 6.9M CGroup: /system.slice/memcached.service └─1234 /usr/bin/memcached -m 64 -p 11211 -u memcache -l 127.0.0.1
By default, Memcached listens only on localhost (127.0.0.1) on port 11211. You can customize Memcached's configuration by modifying the
/etc/memcached.conf file. For example, to increase the amount of memory allocated to Memcached from the default of 64MB to 256MB, you can modify the
-m option as follows:
After making changes to the configuration file, you need to restart the Memcached service using the following command:
sudo systemctl restart memcached
That's it! You have now installed Memcached on Ubuntu and verified that it is running successfully.