Read RSS Reed
search...

Archive for May, 2009

Tracklist v2 released!

May 22nd, 2009

It’s done.

The new Tracklist is online. Yesterday evening Remo released the Tracklist v². The new version links to releases and shows the cover. But it is planned to add a new TOP Secret feature next week. ;-)

Tracklist v2

PHP 5 memcache extension on Debian Etch as session handler

May 13th, 2009

Have you ever thought about a method of saving sessions without getting a lot of session files or using a selfmade session handler?
The answer for this question is memcache. A module giving you the ability to store variables in memory for a defined time. You can install the module on a Linux and a Windows Server. I only want to explain you how to set it up on Linux Debian Etch.

At first you have to do is to install the server module.

apt-get install memcached

If the application is already started, we have to kill the process to setup what we want.

memcached -d -u www-data -m 2048 -l 127.0.0.1 -p 11211

Explain this command:
memcached (command)
-d (the parameter to run it in background)
-u www-data (to run it under the standard apache2 user www-data)
-m (Sets the space of the memcached server (in Mega Byte) (in this example 2048 MB (Mega Byte))
-l (Sets the IP the memcached server listens to)
-p (Sets the Port the memcached server listens to)

Now the memcache server runs as www-data with a space of 2024 MB RAM which is listen to localhost:11211. The next step is to involve PHP. For that we have to enable the module memcache.

You could get the latest version here. Please use the wget command to download the file. (Note: replace X.X.X. with the current version)

cd /usr/local/src
wget http://pecl.php.net/get/memcache-X.X.X.tgz
tar zxvf memcache-X.X.X.tgz
cd memcache-X.X.X
apt-get install php5-dev
phpize
./configure
make && make install

Okay we have compiled the files. Now you have to move the memcache.so to your extension folder of PHP5. In my case I found the memcache.so in /usr/local/lib/php/extensions/no-debug-non-zts-20060613/memcache.so, but maybe your location is different.

Now copy the file to /usr/lib/php5/20060613+lfs

The next step is to get the latest version of the memcache php5 extension in our extension directory. All we have to do now is to configure the php.ini by adding the following line.

extension=memcache.so

Before you could restart the apache2 server you need to set up the memcache that it will be used as session handler. The standard will look like this:

session.save_handler = files
session.save_path = "N;MODE;/path"
session.gc_probability = 0

You have to change it to:

session.save_handler = memcache
session.save_path="tcp://127.0.0.1:11211?persistent=1&weight=1&timeout=1&retry_interval=15"
session.gc_probability = 1

Save the ini file and restart your apache2 server.

/etc/init.d/apache2 restart

When you take now a look into your phpinfo it should look like this:

(the white spaces are private settings)
Congratulations! If you create now a session it will be stored into the memory instead of creating a file.