Memcached Sessions

    In a clustered environment, PHP sessions need to be shared.  Here are steps to enable sessions stored in memcache. 

      

    Install memcached

    CentOS

    yum install memcached
    /etc/init.d/memcached start
    

    NOTE: edit /etc/sysconfig/memcached and set appropriate config values

      

    Install memcache pecl package

    See http://www.php.net/memcache for more info

    yum install php-devel
    pecl install memcache
    echo "extension=memcache.so" > /etc/php.d/memcache.ini
    /etc/init.d/httpd restart
    

      

    Patch Deki codebase

    NOTE: The following patch can be applied to the deki /trunk branch

    wget -O /tmp/memcache.patch http://www.mindtouch.com/~petee/memcache.patch
    cd /var/www/dekiwiki
    patch -p0 < /tmp/memcache.patch
    

      

    Configure LocalSettings.php

    To enable memcached sessions, you'll need to define two variables in LocalSettings.php

    $wgSessionsInMemcached = true;
    

      

    $wgMemCachedServers = array( 'tcp://127.0.0.1:11211?persistent=1&weight=1&timeout=1&retry_interval=15');
    

    NOTE: multiple memcache servers can be used by adding multiple entries to the $wgMemCachedServers arary.

    Debugging

    To ensure that sessions are being stored in memcache, enable verbose logging by setting the following in /etc/sysconfig/memcached

    OPTIONS="-vv"
    Tag page
    You must login to post a comment.

    Copyright © 2011 MindTouch, Inc. Powered by