Arch Linux BasedManjaro

How To Install Memcached on Manjaro

Install Memcached on Manjaro

In this tutorial, we will show you how to install Memcached on Manjaro. Memcached is a powerful in-memory caching system widely used in web applications to boost performance by storing frequently accessed data in memory. Installing Memcached on a Manjaro Linux system can significantly enhance the speed and efficiency of your web applications.

This article assumes you have at least basic knowledge of Linux, know how to use the shell, and most importantly, you host your site on your own VPS. The installation is quite simple and assumes you are running in the root account, if not you may need to add ‘sudo‘ to the commands to get root privileges. I will show you the step-by-step installation of Memcached on a Manjaro Linux.


  • A server or desktop running one of the following operating systems: Manjaro, and other Arch-based distributions.
  • It’s recommended that you use a fresh OS install to prevent any potential issues.
  • SSH access to the server (or just open Terminal if you’re on a desktop).
  • An active internet connection. You’ll need an internet connection to download the necessary packages and dependencies for Memcached.
  • A non-root sudo user or access to the root user. We recommend acting as a non-root sudo user, however, as you can harm your system if you’re not careful when acting as the root.

Install Memcached on Manjaro

Step 1. Before diving into the Memcached installation, it’s crucial to make sure your Manjaro system is up to date. Open a terminal and execute the following commands:

sudo pacman -Syu
sudo pacman -S base-devel

Step 2. Installing Memcached on Manjaro.

Installing Memcached on Manjaro is straightforward thanks to the Pacman package manager. Run the following command to install Memcached and its required dependencies:

sudo pacman -S memcached

Pacman will handle the installation process and prompt you to confirm. Press ‘Y‘ and then ‘Enter‘ to proceed. Memcached will be downloaded and installed on your system.

Once Memcached is installed, it’s time to start the service. Use the following command to start the Memcached service:

sudo systemctl start memcached

You can also enable Memcached to start on boot by running:

sudo systemctl enable memcached

Step 3. Configure Memcached for Optimal Performance.

Memcached’s default configuration is usually sufficient for most use cases. However, if you need to customize its behavior, you can edit the configuration file located at /etc/memcached.conf. Use your preferred text editor to make changes:

sudo nano /etc/memcached.conf

Inside the configuration file, you can adjust various settings according to your needs. Some common configurations to consider are:

  • Memory Allocation: Set the maximum amount of memory Memcached can use. Modify the -m flag to allocate memory in megabytes. For example, to allocate 256MB, use -m 256.

  • Listening IP and Port: By default, Memcached listens on localhost ( on port 11211. You can change the listening IP and port by modifying the -l and -p flags.
  • Caching Mechanism: Memcached uses the Least Recently Used (LRU) algorithm for cache eviction. You can modify the cache eviction policy by specifying the -o flag. For example, to use the Least Frequently Used (LFU) algorithm, add -o lfuda.

After making any adjustments, save the file and restart the Memcached service for the changes to take effect:

sudo systemctl restart memcached

To verify that Memcached is running and accessible, you can use the telnet command to connect to the Memcached server:

telnet localhost 11211

If the connection is successful, you should see a response indicating that you’ve connected to the Memcached server.

Step 4. Memcached with PHP (Optional).

If you’re using PHP for your web applications, you can integrate Memcached to enhance your application’s speed and efficiency. Install the Memcached PHP extension using the following command:

sudo pacman -S php-memcached

You need to configure PHP to use the Memcached extension. Open your PHP configuration file with a text editor:

sudo nano /etc/php/php.ini

Add the following line to enable the Memcached extension:

Save the file and restart your web server for the changes to take effect:

sudo systemctl restart apache # Use your web server's name (e.g., apache or nginx)

You can test if PHP is successfully using Memcached by creating a simple PHP script:

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

Add the following PHP code to the file:

$memcached = new Memcached;
$memcached->addServer('localhost', 11211);

$key = 'my_key';
$data = 'Hello, Memcached!';

$memcached->set($key, $data);

$result = $memcached->get($key);

if ($result) {
echo "Data from Memcached: " . $result;
} else {
echo "Data not found in Memcached. ";

Save the file, and you can access it via your web browser to test Memcached integration.

Congratulations! You have successfully installed Memcached. Thanks for using this tutorial to install the latest version of Memcached on the Manjaro system. For additional help or useful information, we recommend you check the official Memcached website.

VPS Manage Service Offer
If you don’t have time to do all of this stuff, or if this is not your area of expertise, we offer a service to do “VPS Manage Service Offer”, starting from $10 (Paypal payment). Please contact us to get the best deal!


r00t is a seasoned Linux system administrator with a wealth of experience in the field. Known for his contributions to, r00t has authored numerous tutorials and guides, helping users navigate the complexities of Linux systems. His expertise spans across various Linux distributions, including Ubuntu, CentOS, and Debian. r00t's work is characterized by his ability to simplify complex concepts, making Linux more accessible to users of all skill levels. His dedication to the Linux community and his commitment to sharing knowledge makes him a respected figure in the field.
Back to top button