Dragonfly Cloud is now available in the AWS Marketplace - learn more

Question: How to install Memcached on Ubuntu?

Answer

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.

Step 1: Update the Package List

Firstly, update the package list on your server using the following command:

sudo apt-get update

Step 2: Install Memcached

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.

Step 3: Verify Installation

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

Step 4: Configure Memcached (Optional)

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:

-m 256

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.

Was this content helpful?

White Paper

Free System Design on AWS E-Book

Download this early release of O'Reilly's latest cloud infrastructure e-book: System Design on AWS.

Free System Design on AWS E-Book

Switch & save up to 80% 

Dragonfly is fully compatible with the Redis ecosystem and requires no code changes to implement. Instantly experience up to a 25X boost in performance and 80% reduction in cost