- These instructions are intended specifically for installing Memcached on a single Fedora 23 node. If you’re using a different operating system, check out our guides to installing Memcached on Ubuntu 15.04, CentOS 6 and CentOS 7.
- We’ll be working as root on a Liquid Web Self Managed Fedora 23 server.
Step #1: Install MemcachedFirst, we’ll clean up our package files:
dnf clean allAs a matter of best practice we’ll now update our packages:
dnf -y updateTo install Memcached and related packages, run the command:
dnf -y install memcached
Step #2: Configure MemcachedUse the following command to view information on the memcached command:
memcached -hThe default configuration file is located at /etc/sysconfig/memcached. Open that file to view the configuration:
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. For a refresher on editing files with vim, see New User Tutorial: Overview of the Vim Text Editor. If vim is not installed on your OS, you can follow our tutorial on installing vim at How to Install VIM (Visual editor IMproved) on Fedora 23.The contents of the file should appear similar to this:
PORT="11211" USER="memcached" MAXCONN="1024" CACHESIZE="64" OPTIONS=""
- 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.
systemctl restart memcached
Step #3: Configure Memcached to Start on BootThe following code will ensure that Memcached starts at boot:
systemctl enable memcachedThat will produce output similar to:
[root@host ~]# systemctl enable memcached Created symlink from /etc/systemd/system/multi-user.target.wants/memcached.service to /usr/lib/systemd/system/memcached.service.To check the status of Memcached:
systemctl status memcachedTo stop Memcached:
systemctl stop memcachedTo start Memcached:
systemctl start memcached
Step #4: Install the Memcached PHP ExtensionIf needed, install the Memcached PHP extension with the following command:
dnf -y install php-pecl-memcacheNow restart memcached and Apache for the settings to take effect:
systemctl restart memcached systemctl restart httpdTo verify that the PHP module is loaded, run the command:
php -m | grep memcacheThat should produce output similar to:
[root@host ~]# php -m | grep memcache memcacheAnd finally, you can check the php.ini to confirm your Memcached settings:
php -i | grep memcacheThat should produce output similar to:
[root@host ~]# php -i | grep memcache /etc/php.d/40-memcache.ini, 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