XCache is a PHP opcode cacher created by the same developer who brought us Lighttpd. An opcode cacher significantly increases PHP’s performance by caching the compiled state of PHP code to avoid time-consuming recompilation each time a script is executed. There are a handful of great opcode cachers on the market currently, incuding APC and eAccelerator (here’s a more comprehensive list). APC is written by some of the developers of PHP and will be bundled with PHP6. eAccelerator has a long history and might be the most popular and widely supported opcode cacher. I chose XCache due to its reputation for superior performance (source) and its ability to take advantage of multi-core processors.
Setting up XCache on Gentoo Linux is dead simple.
Install XCache
emerge -va dev-php5/xcache
Configure XCache
nano /etc/php/cgi-php5/ext-active/xcache.iniEdit anything you see fit. See this page for details.
Since Slicehost is running on twin dual-core processors, I changed “xcache.count” to 5 (n+1 where n is the number of processors) to take advantage of the Splitted Cache feature.
Restart PHP
I have PHP running as a FastCGI daemon, so I restart with
/etc/init.d/fcgi.php restart
Check phpinfo() to verify that XCache is loaded. You should see the following in the “Powered by Zend” box:
with XCache v1.2.1, Copyright (c) 2005-2007, by mOo
If you liked this post, please subscribe to my feed. Thanks for visiting!


0 Responses to “Speed up PHP with XCache on Gentoo Linux”