Installing phpMemcachedAdmin on Debian 7.5

To be able to monitor and manage a Memcached server, a connection needs to be established to it. Several options are available, with the most basic being making use of telnet. We can also make use of phpMemcachedAdmin, allowing us to monitor and manage our Memcached server through a web interface.

It provides us with real-time stats for get, set, delete, increment, decrement, evictions, reclaimed and cas commands, as well as server stats (network, items, server version) with googlecharts and server internal configuration.

Downloading phpMemcachedAdmin

To download the latest release of phpMemcachedAdmin, we access it at http://blog.elijaa.org/index.php?pages/phpMemcachedAdmin-Download.

Installing phpMemcachedAdmin

Once downloaded, we can extract the archive and setup the virtual host to publish the extracted directory.

Configuring phpMemcachedAdmin

To configure phpMemcachedAdmin, we will host it on a secure virtual host on Apache.

Virtual Host settings

The virtual host will use the IP address 192.168.100.14, using the certificate in /etc/ssl/CA/certs/sitename.cert and the private key in /etc/ssl/CA/private/sitename.key.nopass. Authentication will also be required using a htpasswd file in /etc/apache2/security/htpasswd.sitename.

To create this htpasswd file, we execute the following command in a “root” shell.

htpasswd -c /etc/apache2/security/htpasswd.sitename admin

We will then be prompted to enter a password for the user admin, and using these credentials we will be able to access the phpMemcachedAdmin web interface.

Virtual Host Configuration

<VirtualHost 192.168.100.14:80>
    RewriteEngine on
    ReWriteCond %{SERVER_PORT} !^443$
    RewriteRule ^/(.*) https://%{HTTP_HOST}/$1 [NC,R,L]
</VirtualHost>

<VirtualHost 192.168.100.14:443>
    ServerName sitename
    ServerAdmin webmaster@domain

    SSLEngine On
    SSLCertificateFile /etc/ssl/CA/certs/sitename.cert
    SSLCertificateKeyFile /etc/ssl/CA/private/sitename.key.nopass

    DocumentRoot /var/www/phpmemcachedadmin
    <Directory /var/www/phpmemcachedadmin>
        Options FollowSymLinks
        DirectoryIndex index.php
        <IfModule mod_php5.c>
            AddType application/x-httpd-php .php
            php_flag magic_quotes_gpc Off
            php_flag track_vars On
            php_flag register_globals Off
            php_admin_flag allow_url_fopen Off
            php_value include_path .
        </IfModule>
        <IfModule mod_authn_file.c>
            AuthType Basic
            AuthName "Memcached Administration"
            AuthUserFile /etc/apache2/security/htpasswd.sitename
        </IfModule>
        Require valid-user
    </Directory>

    ErrorLog ${APACHE_LOG_DIR}/sitename/error.log
    CustomLog ${APACHE_LOG_DIR}/sitename/access.log combined
</VirtualHost>

Enabling the Virtual Host

To enable the virtual host, we execute the following command in a “root” shell.

a2ensite sitename

To reload the configuration, we execute the following command in a “root” shell.

service apache2 reload
Advertisements