Can't get Memcached to work

eberkund

Well-known member
I'm trying to switch from this,

PHP:
$config['cache']['enabled'] = true;
$config['cache']['cacheSessions'] = true;
$config['cache']['backend'] = 'File';
$config['cache']['backendOptions'] ['cache_dir'] = '/root/campingbabble/public_html/internal_data/cache';

$config['cache']['frontend'] = 'Core';
$config['cache']['frontendOptions'] ['cache_id_prefix'] = 'xf_';
$config['cache']['frontendOptions'] ['caching'] = true;
$config['cache']['frontendOptions']['automatic_serialization'] = true;
$config['cache']['frontendOptions'] ['lifetime'] = 1800;

To this,

PHP:
$config['cache']['enabled'] = true;
$config['cache']['frontend'] = 'Core';
$config['cache']['frontendOptions']['cache_id_prefix'] = 'xf_';

$config['cache']['backend'] = 'Memcached';
$config['cache']['backendOptions'] = array(
    'compression' => false,
    'servers' => array(
        array(
            'host' => 'localhost',
            'port' => 11211,
        )
    )
);

But whenever I do, it works momentarily (for a minute) as I browse the site and then I get "An unexpected error has occured" on all pages until I remove all caching from the config.

I installed and tested memcached on my server using this:
https://www.digitalocean.com/community/tutorials/how-to-install-and-use-memcache-on-ubuntu-14-04
 
Maybe it's 'Memcache' or 'Libmemcached' instead of 'Memcached' here,

Code:
$config['cache']['backend'] = 'Memcached';

Make sure memcached service is running too, and paste your memcached.conf if the issue persists.
 
memcached.ini
Code:
extension=memcached.so

I tried 'Memcache' and 'Libmemcached' and those give an error right away within even letting me browse a few pages before it starts doing that

Service is running:
Code:
root@server:~# ps aux | grep memcached
memcache 27167  0.0  0.2 325392  1180 ?        Sl   14:58   0:00 /usr/bin/memcached -m 64 -p 11211 -u memcache -l 127.0.0.1
root     31726  0.0  0.1  11740   940 pts/0    S+   18:32   0:00 grep --color=auto memcached
 
Oh also the /etc/memcached.conf file is default:

Code:
# memcached default config file
# 2003 - Jay Bonci <jaybonci@debian.org>
# This configuration file is read by the start-memcached script provided as
# part of the Debian GNU/Linux distribution.

# Run memcached as a daemon. This command is implied, and is not needed for the
# daemon to run. See the README.Debian that comes with this package for more
# information.
-d

# Log memcached's output to /var/log/memcached
logfile /var/log/memcached.log

# Be verbose
# -v

# Be even more verbose (print client commands as well)
# -vv

# Start with a cap of 64 megs of memory. It's reasonable, and the daemon default
# Note that the daemon will grow to this size, but does not start out holding this much
# memory
-m 64

# Default connection port is 11211
-p 11211

# Run the daemon as root. The start-memcached will default to running as root if no
# -u command is present in this config file
-u memcache

# 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.
-l 127.0.0.1

# Limit the number of simultaneous incoming connections. The daemon default is 1024
# -c 1024

# Lock down all paged memory. Consult with the README and homepage before you do this
# -k

# Return error when memory is exhausted (rather than removing items)
# -M

# Maximize core file limit
# -r
 
Nevermind, I fixed it. The issue turned out to be that I had installed php5-memcached instead of php5-memcache

So I just did

Code:
apt-get remove php5-memcached
apt-get autoremove
apt-get install php5-memcache
service apache2 restart

and now it is working :D
 
Last edited:
I too have had this issue, but as far as I can see you can't run memcached on 14.04 with PHP5.
I'm about to ask some advice myself now too.. So is it working on 10.04 with PHP5?
 
Hmm I have tried everything and cannot get it to work whatsoever.
I have a higher setting on PHP5 which is preventing the install...


The following packages have unmet dependencies:
php5-memcached : Depends: php5-common (= 5.3.29-1~dotdeb.0) but 5.5.9+dfsg-1ubuntu4.9 is to be installed

I've spoken with DO too, and they didn't know.. and after two days of hunting and trying, I eventually gave up, Been trying for several weeks now with no success and today, I thought I got somewhere as the memcached server was running, but php modules wouldn't work.
Grr
 
Hmm I have tried everything and cannot get it to work whatsoever.
I have a higher setting on PHP5 which is preventing the install...
What do you mean?

I am using the default version of PHP that is installed which is 5.5.9
 
Nah, won't work.. I did try it and just did it again to be sure..
It's a no go from here. So frustrating.!
Thank you though. Been trying for a long time and just can't get it going.
 
Maybe try installing on a fresh server if you do not have a lot of other things installed?

Because I can assure you it does work and I didn't have to do any complicated configurations either and I am using digital ocean as well
 
I do have a lot of stuff running, and had to run a huge set of updates and tweaks for ffmpeg
This I think is the basis for the issues.

I've had to do a lot of configs to get it running as is. Painstaking.
Mainly for video uploads, but I am not sure if I have any broken package dependencies see?
 
I am not sure, I am no Linux expert

I know you can remove package dependencies for removed packages by using `apt-get autoremove`
 
Agreed, you can.. Did that, even rolled back to a different PHP package = no joy as the pin didn't work, unless I didn't do it correctly.
It's been a challenging month! Put it that way :D
 
The following packages have unmet dependencies:
php5-memcached : Depends: php5-common (= 5.3.29-1~dotdeb.0) but 5.5.9+dfsg-1ubuntu4.9 is to be installed
I notice you are using DotDeb... what does your /etc/apt/sources.list look like?
Have you tried removing all the PHP related .DEB's and installing fresh again with either the latest DotDeb added to your /etc/apt/sources.list or removing all the DotDeb from there and running apt-get update again?
 
Hi mate,
I did try yeah, and I don't know if it's inexperience or what have you, but this brought down the server.
The server rebooted and I lost the site completely too. Virtualmin was up, but the site wouldn't even load.

Most likely something I did or didn't do.
It's proving to be challenging now.
 
Top Bottom