Simple install of memcached on Ubuntu
Posted on January 22, 2010
Memcached is a free, high performance distributed memory object caching system. In English, it can make your single server PHP applications faster or for a little more technical users you can write cache and share cache objects over a web server farm or cluster. Great, eh.
No seriously, it can really make your PHP faster.Here is how to install it really simply on Ubuntu for use with PHP.
- apt-get install memcached php5-memcache
Simple as that!
Lets check it's running
- itsupport@intranet4:~$ ps uxa | grep memcache
- nobody 8108 0.0 0.8 19104 17664 ? S Jan20 0:00 /usr/bin/memcached -m 64 -p 11211 -u nobody -l 127.0.0.1
By default its running on localhost only and on the default port of 11211. You can change these if you need network access or whatever in /etc/memcached.conf. But we'll leave it as default for now.
Now, how hard was that?
PHP lists a simple example file to test PHP and memcached interoperatability.
- <?php
-
- $memcache = new Memcache;
-
- $version = $memcache->getVersion();
- echo "Server's version: ".$version."<br/>\n";
-
- $tmp_object = new stdClass;
- $tmp_object->str_attr = 'test';
- $tmp_object->int_attr = 123;
-
- echo "Store data in the cache (data will expire in 10 seconds)<br/>\n";
-
- $get_result = $memcache->get('key');
- echo "Data from the cache:<br/>\n";
-
-
- ?>
Related posts
- Installing memcached on CentOS/cPanel
memcached a (distributed) memory object caching system vital if your running a HA Linux* setup... - Installing memcached on CentOS (cPanel)
Welcome to hell. No really, compared to installing memcached on Ubuntu, CentOSs really sucks. CentOS... - Ridiculously simple NTLM Authentication for Apache (Ubuntu)
We all know Ubuntu makes things amazingly simple. This is the best I've found so... - [Snippet] Stupid Simple cPanel Install
Open a clean server, Go have your lunch. Maybe lunch +VAT depending on the speed... - Installing nginx & PHP-FPM securely on CentOS
I won't go into the reasons why you should install nginx, if you're here, you've...



