OK, I have always had an issue with getting XenForo to play nice with Memcached, but that was the case when trying to use it on managed servers with no root access.
Prerequisites: in addition to installing memcached, you must have both memcache and memcached PHP extensions installed. In Ubuntu,
apt-get install php5-memcache apt-get install php5-memcached
For whatever reason, Zend needs both installed for this to work.
You must also configure memcached on your server to run with a socket, vs. localhost with port 11211. This is quite simple.
Create a directory (such as /var/memcached ) and chown it to your memcache user.
In memcached.conf, comment out these lines:
# -p 11211 # -l 127.0.0.1
…and add these lines:
-s /var/memcached/memcached.socket -a 0766
Make certain you also have your memcache user specified in the file:
What you’ve just done is disable the tcp service but enabled the Unix socket. Good work.
Now it’s time to change your configuration file in XenForo.
First, make sure you have the frontend cache configured:
$config['cache']['enabled'] = true; $config['cache']['frontend'] = 'Core'; $config['cache']['cacheSessions'] = true; $config['cache']['frontendOptions'] = array( 'caching' => true, 'automatic_serialization' => true, 'lifetime' => 3600, 'cache_id_prefix' => 'xf_myforum_' );
Using the examples above, you’ll want to add this below:
$config['cache']['backend'] = 'Memcached'; $config['cache']['backendOptions'] = array( 'compression' => false, 'servers' => array( array( 'host' => 'unix:///var/memcached/memcached.socket', 'port' => 0 ) ) );
And for now, comment out your file backend config if you have been using it, and keep it in your file in case memcached ever acts up–you can quickly revert:
/* ///// Backup in case Memcache totally borks $config['cache']['backend'] = 'File'; $config['cache']['backendOptions'] = array( 'cache_dir' => '/var/caches/xf/xfcache_myforum', 'hashed_directory_level' => 2, 'hashed_directory_umask' => 0707, 'cache_file_umask' => 0707 ); */
If all goes well, you’ll be using memcached for XF’s cache, and also be using the faster and more direct Unix socket instead of TCP.