Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I will be soon setting up Simple Machines forum on a fresh Ubuntu Server 10.04 VPS. The forum software is written in PHP. I will using Nginx as the web server, and I will be following a guide to install PHP-FPM on it: http://constantshift.com/install-php-fpm-5-3-2-on-ubuntu-10-04-lucid-lynx/

But the guide doesn't really explain anything about setting up Memcached or APC for caching. After looking around the net, searching this site and searching Stack Overflow, I'm still lacking answers for how to set these up successfully.

Can anyone help with information, guides, links? Much appreciated.

share|improve this question
add comment

3 Answers

up vote 10 down vote accepted

First, decide if you need memcached. APC is both an "accelerator" (an opcode cache, which is fairly transparent), and a caching solution (provides an in-memory data store that code needs to write/read from). memcache only does the latter.

The only reason you'd typically need memcached is if you're going to be running multiple servers that need to read/write from the same cache. As long as you're only running a single web server host, APC will do the trick.

Installing APC is pretty easy.

[root@host]# pecl install apc     #or sometimes pecl install apc-beta
[root@host]# service php5-fpm start

You'll probably notice an immediate performance boost, just with APC's default settings.

You can then tweak as needed. See the docs for various settings.

The most common setup I've seen is a single segment, sized in a way that makes sense for your system:

In php.ini:

extension=apc.so
apc.enabled = 1
apc.shm_segments = 1
apc.shm_size = 50M 

APC comes with a handy apc.php script that will give you lots of useful data (like how many hits/misses you're getting), along with pretty graphs.

share|improve this answer
    
i'm getting php5-fpm: unrecognized service after following your steps to install APC –  rlemon Jan 25 '12 at 15:21
add comment

Memcached is a server. So install it with apt-get install memcached The PHP need an extension to work with memcached : apt-get install php5-memcache The accelerator APC is provided by another extension : apt-get install php-apc

Don't forget to restart your Web server to use the new modules.

I forget the links : [http://php.net/manual], then check memcache, apc

share|improve this answer
    
So this is installing it... But do I need to do any configurations of it? Will it just work out of the box? That's the real bit I don't understand. –  littlejim84 Sep 11 '10 at 0:14
    
As usual on Debian/Ubuntu, you have a working package. But, you will maybe need some modifications if you have specific needs. If you just start in this world, it will be sufficient. Don't forget to see the docs, there is good explanation how it works –  Dom Sep 11 '10 at 17:03
add comment

In php.ini avoid using apc.shm_size = 50M but use apc.shm_size = 50. The M postfix makes PHP to ignore the changed size, although PHP is going to declare to you everywhere that 50M is what it uses. You'd be only mistaken.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.