Storing your PHP sessions using memcached

http://www.dotdeb.org/2008/08/25/storing-your-php-sessions-using-memcached/

sudo apt-get install memcached
sudo apt-get install php5-memcache

and change some of your PHP settings :

sudo nano /etc/php5/apache2/php.ini

session.save_handler = files
; session.save_path = "N;/path"

to :

session.save_handler = memcache
; change server:port to fit your needs...
session.save_path="tcp://localhost:11211?persistent=1&weight=1&timeout=1&retry_interval=15"

sudo service apache2 restart

To see if its working:

http://www.mycreativity.nl/blog/setting-up-memcached-on-my-raspberry-pi/

echo "stats settings" | nc localhost 11211

This shows that the Memcached is now listening on port 11211 with localhost connections only. We will change this to the, catch-all, IP 0.0.0.0 by changing the line: “-l 127.0.0.1” to “-l 0.0.0.0” in the file “/etc/memcached.conf”. After changing the config you can see if we can now make a connection from external machines use the following command:

netstat -ln4t | grep :11211
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s