|The instructions provided in this article or section are considered advanced.|
You are expected to be knowledgeable in the UNIX shell.
Memcached is a high-performance, distributed memory object caching system, generic in nature, but intended for use in speeding up dynamic web applications by alleviating database load. Many web applications (MediaWiki, Drupal, and so on) offer support for memcached.
Danga Interactive developed memcached to enhance the speed of LiveJournal.com, a site which was already doing 20 million+ dynamic page views per day for 1 million users with numerous webservers and database servers. memcached dropped the database load to almost nothing, yielding faster page load times for users, better resource utilization, and faster access to the databases on a memcache miss.
Installing the memcached server daemon
- Log into your server via SSH. Make sure you log into the server using an admin user on the VPS.
- Run the following command to change to the root user:
- Run the following to install the memcached daemon (server-based) package:
apt-get install memcached
- After installing the memcached daemon, download a client package to access the server and extend PHP to connect to your memcached daemon.
Using the PECL memcached client
- Review the memcached installation documentation at php.net.
- Obtain the prerequisite libmemcache at https://launchpad.net/libmemcached
wget http://download.tangent.org/libmemcached-1.0.8.tar.gz tar -zxvf libmemcached-1.0.8.tar.gz cd libmemcached-1.0.8 ./configure make make install
Using PECL’s memcache client
To use the PECL memcache client:
- Download the source code and compile it:
wget http://pecl.php.net/get/memcache-3.0.5.tgz tar -zxvf memcache-3.0.5.tgz cd memcache-3.0.5
- Compile for PHP 5.4:
/usr/local/php54/bin/phpize ./configure --with-php-config=/usr/local/php54/bin/php-config make make install
- The ‘make install’ command ends with the following response:
Installing shared extensions: /usr/local/php54/lib/php/extensions/no-debug-non-zts-20100525/
- After the shared object is compiled, add it to your PHP configuration.
Note: For further information on adding a phprc file under the user your domain runs on, visit the following page:
- Add the following line to that phprc file:
extension = “/usr/local/php54/lib/php/extensions/no-debug-non-zts-20100525/memcache.so”
- Kill off all running PHP processes. For further information, visit the following page:
- Check your PHP configuration in a phpinfo.php file to confirm the extension is loading. For further information, visit the following page: