Atlantic.Net Blog

How to Install Memcached on Oracle Linux 8

Hitesh Jethva
by Atlantic.Net (429 posts) under Tutorials, VPS Hosting
0 Comments

Memcached is a free and open-source in-memory caching service. You can use it with your web application to increase the speed of applications by caching session data, user authentication tokens, and API calls in memory. It is multithreaded, scales vertically, and allows you to share a large amount of data across multiple application instances. Some major companies including Facebook, Youtube, and Twitter use Memcached as a caching service.

In this post, we will show you how to install Memcached on Oracle Linux 8.

Prerequisites

  • A server running Oracle Linux 8 on the Atlantic.Net Cloud Platform
  • A root password configured on your server

Step 1 – Create Atlantic.Net Cloud Server

First, log in to your Atlantic.Net Cloud Server. Create a new server, choosing Oracle Linux 8 as the operating system with at least 2GB RAM. Connect to your Cloud Server via SSH and log in using the credentials highlighted at the top of the page.

Once you are logged in to your server, run the following command to update your base system with the latest available packages.

dnf update -y

Step 2 – Install Memcached on Oracle Linux 8

The memcached package is included in the Oracle Linux 8 default repo, so you can install it easily by running the following command:

dnf install memcached libmemcached -y

Once the Memcached is installed, you can see the detailed information of Memcached with the following command:

rpm -qi memcached

Sample output:

Name        : memcached
Epoch       : 0
Version     : 1.5.22
Release     : 2.el8
Architecture: x86_64
Install Date: Wednesday 22 June 2022 12:21:28 PM EDT
Group       : System Environment/Daemons
Size        : 414767
License     : BSD
Signature   : RSA/SHA256, Sunday 02 August 2020 01:50:39 AM EDT, Key ID 82562ea9ad986da3
Source RPM  : memcached-1.5.22-2.el8.src.rpm
Build Date  : Sunday 02 August 2020 01:50:04 AM EDT
Build Host  : jenkins-10-147-72-125-33c0adfe-729e-4329-8974-7885a317ca02.appad2iad.osdevelopmeniad.oraclevcn.com
Relocations : (not relocatable)
Vendor      : Oracle America
URL         : https://www.memcached.org/
Summary     : High Performance, Distributed Memory Object Cache
Description :
memcached is a high-performance, distributed memory object caching
system, generic in nature, but intended for use in speeding up dynamic
web applications by alleviating database load.

Step 3 – Manage Memcached Service

By default, the Memcached service is managed by systemd. You can use the systemctl command to manage the Memcached service. To start the Memcached service, run the following command:

systemctl start memcached

To enable the Memcached service to start after the reboot, run the following command:

systemctl enable memcached

To check the status of the Memcached service, run the following command:

systemctl status memcached

Sample output:

● memcached.service - memcached daemon
   Loaded: loaded (/usr/lib/systemd/system/memcached.service; disabled; vendor preset: disabled)
   Active: active (running) since Wed 2022-06-22 12:21:53 EDT; 7s ago
 Main PID: 53667 (memcached)
    Tasks: 10 (limit: 23694)
   Memory: 7.6M
   CGroup: /system.slice/memcached.service
           └─53667 /usr/bin/memcached -p 11211 -u memcached -m 64 -c 1024 -l 127.0.0.1,::1

Jun 22 12:21:53 oraclelinux8 systemd[1]: Started memcached daemon.

Step 4 – Configure Memcached

The Memcached default configuration file is located at /etc/sysconfig/memcached. You can edit it with the following command:

nano /etc/sysconfig/memcached

The default configuration is shown below. You can change it per your requirements:

PORT="11211"
USER="memcached"
MAXCONN="1024"
CACHESIZE="64"
OPTIONS="-l 127.0.0.1,::1"

Save and close the file, then restart the Memcached service to apply the changes:

systemctl restart memcached

Step 5 – Install Memcached PHP Extension

You can use Memcached as a caching service for all PHP-based applications. To do so, you will need to install the Memcached extension for PHP.

First, install the EPEL and Remi repositories with the following command:

dnf install epel-release -y
dnf install https://rpms.remirepo.net/enterprise/remi-release-8.rpm -y

Next, disable the default PHP repo and enable the Remi PHP repo with the following command:

dnf module list reset php
dnf module enable php:remi-7.4 -y

Next, install the Memcached PHP extensions using the following command:

dnf install php-pecl-memcache php-pecl-memcached -y

Step 6 – Verify Memcached for PHP

To verify the Memcached integration with PHP, you will need to install the Nginx web server and PHP package to your server.

dnf install nginx php php-cli -y

Next, create an info.php file with the following command:

nano /var/www/html/info.php

Add the following code:

<?php
phpinfo();
?>

Save and close the file, then create a symbolic link of info.php file to the Nginx default web root directory:

ln -s /var/www/html/info.php /usr/share/nginx/html/

Next, restart the Nginx service to apply the changes:

systemctl start nginx

Now, open your web browser and type the URL http://your-server-ip/info.php. You should see the following page:
Memcached test page
As you can see, both Memcache and Memcached PHP extensions are enabled.

Conclusion

In this post, we explained how to install Memcached on Oracle Linux 8. We also explained how to integrate Memcached with PHP applications. You can now use Memcached to speed up your web application. Try it on VPS hosting from Atlantic.Net!

Get A Free To Use Cloud VPS

Free Tier Includes:
G3.2GB Cloud VPS Free to Use for One Year
50 GB of Block Storage Free to Use for One Year
50 GB of Snapshots Free to Use for One Year


Looking for a Hosting Solution?

We Provide Cloud, Dedicated, & Colocation.

  • Seven Global Data Center Locations.
  • Flexible Private, Public, & Hybrid Hosting.
  • 24x7x365 Security, Support, & Monitoring.
Contact Us Now! Med Tech Award FTC
SOC Audit HIPAA Audit HITECH Audit

Recent Posts

How to Install Sails.js Framework with Nginx on Oracle Linux 8
How to Install OTRS on Oracle Linux 8
How to Install and Configure Caddy Web Server with PHP on Oracle Linux 8
How to Install and Use PIP Python Package Manager on Oracle Linux 8
How to Install FTP Server with ProFTPD on Oracle Linux 8

Get started with 12 months of free cloud VPS hosting

Free Tier includes:
G3.2GB Cloud VPS Server Free to Use for One Year
50 GB of Block Storage Free to Use for One Year
50 GB of Snapshots Free to Use for One Year


New York, NY

100 Delawanna Ave, Suite 1

Clifton, NJ 07014

United States

San Francisco, CA

2820 Northwestern Pkwy,

Santa Clara, CA 95051

United States

Dallas, TX

2008 Lookout Dr,

Dallas, Texas 75044

United States

Ashburn, VA

1807 Michael Faraday Ct,

Reston, VA 20190

United States

Orlando, FL

440 W Kennedy Blvd, Suite 3

Orlando, FL 32810

United States

Toronto, Canada

20 Pullman Ct, Scarborough,

Ontario M1X 1E4

Canada

London, UK

14 Liverpool Road, Slough,

Berkshire SL1 4QZ

United Kingdom

Resources