How To Install Memcached on Fedora 23

Step #1: Install Memcached

First, we’ll clean up our package files:

dnf clean all

As a matter of best practice we’ll now update our packages:

dnf -y update

To install Memcached and related packages, run the command:

dnf -y install memcached

Step #2: Configure Memcached

Use the following command to view information on the memcached command:

memcached -h

The default configuration file is located at /etc/sysconfig/memcached. Open that file to view the configuration:

vim /etc/sysconfig/memcached

In vim, remember that you can press “a” to enter text insertion mode; pressing the escape key (Esc) on your keyboard returns you to command mode. 

The contents of the file should appear similar to this:


  • PORT is the port on which memcached will run. By default it is 11211.
  • USER is the user as which memcached runs.
  • MAXCONN is the maximum number of connections to memcached.
  • CACHESIZE is the size of the cache, in MB.
  • OPTIONS contains any additional specified options. In this case, there are none.

If you would like to change the port (PORT), the user Memcached runs as (USER), the maximum number of allowed connections to Memcached (MAXCONN), or the cache size in megabytes (CACHESIZE), simply change the options in the configuration file.

After making any changes, save and exit the configuration file with :wq and then restart Memcached:

systemctl restart memcached

Step #3: Configure Memcached to Start on Boot

The following code will ensure that Memcached starts at boot:

systemctl enable memcached

That will produce output similar to:

[root@host ~]# systemctl enable memcached
Created symlink from /etc/systemd/system/ to /usr/lib/systemd/system/memcached.service.

To check the status of Memcached:

systemctl status memcached

To stop Memcached:

systemctl stop memcached

To start Memcached:

systemctl start memcached

Step #4: Install the Memcached PHP Extension

If needed, install the Memcached PHP extension with the following command:

dnf -y install php-pecl-memcache

Now restart memcached and Apache for the settings to take effect:

systemctl restart memcached
systemctl restart httpd

To verify that the PHP module is loaded, run the command:

php -m | grep memcache

That should produce output similar to:

[root@host ~]# php -m | grep memcache

And finally, you can check the php.ini to confirm your Memcached settings:

php -i | grep memcache

That should produce output similar to:

[root@host ~]# php -i | grep memcache
memcache support => enabled
memcache.allow_failover => 1 => 1
memcache.chunk_size => 32768 => 32768
memcache.compress_threshold => 20000 => 20000
memcache.default_port => 11211 => 11211
memcache.hash_function => crc32 => crc32
memcache.hash_strategy => consistent => consistent
memcache.lock_timeout => 15 => 15
memcache.max_failover_attempts => 20 => 20
memcache.protocol => ascii => ascii
memcache.redundancy => 1 => 1
memcache.session_redundancy => 2 => 2
Registered save handlers => files user memcache



Was this answer helpful?

 Print this Article

Also Read

How to Back Up / Restore MySQL Databases From The Command Line

Creating A Backup The mysqldump command is used to create textfile “dumps” of databases managed...

Create a MySQL Database on Linux via Command Line

Create a MySQL Database First we’ll login to the MySQL server from the command line with the...

How to Install XCache on CentOS 7

Step #1: Add the EPEL Repository Ansible is part of Extra Packages for Enterprise Linux (EPEL),...

How To Install Graylog2 And Centralize Logs On Ubuntu 14.04

About Graylog2 Components Graylog2 has four main components: Graylog2 Server nodes: Serves as...

How To Install VIM (Vi IMproved) on Fedora 23

Step #1: The Installation As a matter of best practice we’ll update our packages: dnf -y update...