initial commit
[m6w6/m6w6.github.io] / _posts / 2005-11-17-boost-your-website-with-apc.md
1 ---
2 title: Boost your Website with APC
3 author: m6w6
4 tags:
5 - PHP
6 ---
7
8 Two weeks ago I plugged [APC](http://pecl.php.net/package/APC) onto my main
9 customers site, and I'm really satisfied by it now. I already tried it some
10 time ago, but back then it had some problems with PEARs Quickforms and
11 similiar heavy OO code, but those problems are fixed for about 90% now, some
12 8% can be easily fixed by reordering **require** statements and the like and
13 finally the remaining ~2% are going to be fixed by Rasmus in the foreseeable
14 future.
15
16 Note that I'm using APC with Debians PHP-4.3.10 and Apache2 package, which
17 proofs a lot IMO ;) and there shouldn't be much that hinders you from trying
18 it too!
19
20 Here's a very simple instruction to boost your PHP enabled webserver:
21 ```shell
22 ~$ pear download pecl/apc
23 ~$ tar xzf APC-3.0.8.tgz
24 ~$ rm -f package.xml
25 ~$ cd APC-3.0.8
26 ~/APC-3.0.8$ /usr/bin/phpize
27 ~/APC-3.0.8$ ./configure --with-php-config=/usr/bin/php-config
28 --enable-apc --enable-apc-mmap
29 ~/APC-3.0.8$ make all
30 ~/APC-3.0.8$ sudo make install
31 ```
32
33 APC is now installed somewhere in /usr/lib/php.
34
35 Some lines to add to php.ini:
36 ```ini
37 extension=apc.so
38
39 [apc]
40 apc.enabled = 1
41 apc.cache_by_default = 1
42 apc.shm_size = 32
43 apc.num_files_hint = 500
44 apc.mmap_file_mask = /tmp/apc.XXXXXX
45 ```
46
47 If you want to cache only a certain virtual host, set apc.cache_by_default to
48 0 in php.ini and add the respective php_admin_value to your `<VirtualHost>`
49 directive for the vhost.
50
51 The package also contains a useful status script, just copy the shipped
52 apc.php to your document root. You'll see how the usage of the SHM segment
53 grows by time, and after some time you'll also see what settings to use for
54 apc.num_files_hint and apc.shm_size when the whole site is cached.
55
56 Sean recently added some [APC docs](http://docs.php.net/apc), too!
57
58 Quod est demonstrandum, Website boosted! ;)