Memcached

From DreamHost
Jump to: navigation, search
The instructions provided in this article or section are considered advanced.

You are expected to be knowledgeable in the UNIX shell.
Support for these instructions is not available from DreamHost tech support.
Server changes performed by DreamHost may break your modifications. You, as the user, are responsible for troubleshooting and resolving issues with your customizations.

Overview

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.

memcached is only available on VPS and Dedicated hosting plans.

Installing the memcached server daemon

  1. Log into your server via SSH. Make sure you log into the server using an admin user on the VPS.
  2. Run the following command to change to the root user:
    sudo su
  3. Run the following to install the memcached daemon (server-based) package:
    apt-get install memcached
  4. 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

  1. Review the memcached installation documentation at php.net.
  2. 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:

  1. 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
    
  2. 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/
  3. After the shared object is compiled, add it to your PHP configuration.
    Note2 icon.png Note: For further information on adding a phprc file under the user your domain runs on, visit the following page:


  4. Add the following line to that phprc file:
    extension = “/usr/local/php54/lib/php/extensions/no-debug-non-zts-20100525/memcache.so”
    
  5. Kill off all running PHP processes. For further information, visit the following page:
  6. Check your PHP configuration in a phpinfo.php file to confirm the extension is loading. For further information, visit the following page:
    01 memcached.png