Joomla and Memcache (with unix sockets)

Memcache or Memcached?

This tutorial has been tested with Memcached (with a trailing d), but it should work with Memcache too.

Be aware they are two different software, made by different authors.

0. Install (if you haven’t yet)

1. Install server and PHP module

sudo apt install php-memcached memcached

2. To test it, create a phpinfo.php file in the Joomla root folder:

<?php phpinfo();

3. Open the page in your browser:

For example: http://localhost/phpinfo.php

4. Look for a memcached reference:

1. Add memcache to www-data group:

sudo usermod -g www-data memcache

www-data is the default nginx/apache user on most Linux distributions. Change it to your actual user if necessary. You can double check this in your phpinfo:

2. Enable UNIX sockets:

Add these lines to /etc/memcached.conf:

# Create unix sock
-s /tmp/memcached.sock

# Set permissions to the group
-a 775

3. Disable TCP (optional)

For extra security, disable TCP connections. Comment these 2 settings on /etc/memcached.conf:

# Default connection port is 11211
#-p 11211

# Specify which IP address to listen on. The default is to listen on all IP addresses
# This parameter is one of the only security measures that memcached has, so make sure
# it's listening on a firewalled interface.

4. Restart service:

sudo service memcached restart

5. Configure Joomla:

At Joomla > Admin > System > Global Configuration > System Tab > Cache Settings:

  • Handler: Memcached
  • Host: /tmp/memcached.sock
  • System Cache: ON

6. Sessions with Memcached

For extra speed, enable Memcache for your Sessions:

Close Menu