Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I am running Arch linux with systemd, nginx, and php with php-fpm. I am trying (and failing) to configure memcached to store sessions using a unix socket. I have memcached installed and active, however, I am unable to disable networking. I added the following line to /etc/conf.d/memcached

MEMCACHED_ARGS="-s unix:///tmp/memcached.sock -a 666"

I also tried:

MEMCACHED_ARGS="-s /tmp/memcached.sock -a 666"
MEMCACHED_ARGS="-s unix:/tmp/memcached.sock -a 666"

when I restart memcached I always get:

memcached.service - Memcached Daemon
          Loaded: loaded (/usr/lib/systemd/system/memcached.service; enabled)
          Active: active (running) since Sat 2013-01-19 17:41:15 PST; 5min ago
        Main PID: 773 (memcached)
          CGroup: name=systemd:/system/memcached.service
                  └─773 /usr/bin/memcached -l 127.0.0.1

when I run php script with sessions php error log shows (not surprisingly):

[19-Jan-2013 16:46:45 America/Los_Angeles] PHP Warning:  Unknown: Failed to write session data (memcached). Please verify that the current setting of session.save_path is correct (unix:/tmp/memcached.sock) in Unknown on line 0

I also installed the php-memcached package but I don't what it does or how to get it going. I uncommented the following line in /etc/php/conf.d/memcached.ini:

extension=memcached.so

but that didn't change anything.

Any insights or suggestions would be greatly appreciated.

share|improve this question

1 Answer 1

up vote 2 down vote accepted

Memcached config.d

A file path is all that's needed for Memcached's unix socket.

MEMCACHED_ARGS="-s /tmp/memcached.sock -a 666"

You can confirm that Memcached is operating normally by running the stats command through the unix socket.

bash $> echo stats | nc -U /tmp/memcached.sock
# returns list of server statistics

Configure PHP's session to use Memcached

Edit php.ini, or /etc/php/conf.d/memcached.ini, and add session support.

extension=memcached.so
session.save_handler="memcached"
session.save_path="/tmp/memcached.sock"

Restart services and verify php logs

share|improve this answer
    
info here is good. Thanks. I also had to put memcached config info into service file because config file wasn't getting read. Furthermore I had to install php-memcached package per pontikis.net/blog/install-memcached-php-archlinux –  Jesse Goodfellow Nov 3 '13 at 19:00
    
Instead of making the file world-writable, you could also run memcached as the web server user (if possible). –  Josh Feb 14 at 2:51

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.