12/13/10 – This post has been modified in light of the new XCache release (1.3.2). Please follow the walkthrough to upgrade your server.
I’ve been using XCache for a few weeks and have found it to be slightly faster than eAccelerator; therefore, I pieced together this walkthrough to help my fellow BlueHost users speed-up their PHP-laden websites. 🙂
Before I get started, please refer to my previous eAccelerator post to learn how to enable zlib compression for your site. By doing so, the server will automatically gzip content before sending it out to browsers. This will significantly reduce your HTML overhead and facilitate the optimization process we’re all striving to perfect.
Now let’s get started. To install XCache, you will need SSH access to your website. Using an appropriate SSH client, login and execute the following commands in order:
mkdir modules xcache
tar -zxf xcache-1.3.2.tar.gz
mv xcache.so /home/BLUEHOST-USERNAME/modules
Steps 1-6 create the necessary directories we’ll be using, download the XCache file, extract it, and point to the directory.
Steps 7-9 compile the XCache module according to the PHP version our server is running.
Steps 10-11 move the newly compiled module (xcache.so) to a readily accessible directory which we will define in our php.ini
Now edit the php.ini file located in your public_html directory with a regular editor program (ie, Wordpad for Windows, TextEdit for Mac OS X, Gedit for Linux).
Using the “Find” function, search for “Windows Extensions.” You will see a list of directives preceded by a semicolon. Above the “Windows Extension” header, copy and paste the following set of parameters to configure XCache. Remember to change “/home/BLUEHOST_USERNAME” to your home directory path which can be found on CPanel in the left “Stats” panel.
zend_extension = /home/BLUEHOST_USERNAME/modules/xcache.so
zend_extension_ts = /home/BLUEHOST_USERNAME/modules/xcache.so
xcache.shm_scheme = "mmap"
xcache.size = 32M
xcache.count = 8
xcache.slots = 8K
xcache.ttl = 0
xcache.gc_interval = 0
xcache.var_size = 16M
xcache.var_count = 1
xcache.var_slots = 8K
xcache.var_ttl = 0
xcache.var_maxttl = 0
xcache.var_gc_interval = 300
xcache.test = Off
xcache.readonly_protection = Off
xcache.mmap_path = "/dev/zero"
xcache.coredump_directory = ""
xcache.cacher = On
xcache.stat = On
xcache.optimizer = Off
xcache.coverager = Off
xcache.coveragedump_directory = ""
Now finally, save and upload your php.ini file back to your public_html directory. You’ll need to restart your FastCGI engine, so log into your CPanel, find “Process Manager” under the “Advanced” header, and kill off any /ramdisk/bin/fcgiphp5 processes. Once they’re dead, navigate back to your site (this will automatically “restart” the FastCGI process and incorporate XCache into the engine).
To verify that XCache is indeed loaded, create a phpinfo file, and navigate to it via a web browser. Scroll down and look for an XCache section like the following:
XCache has not interfered with WordPress 3.1 or any of the plugins I use. To uninstall XCache, you would just need to visit your CPanel, go to PHP Config, and install a fresh copy of your php.ini file (this will erase all the modifications you made to install XCache). Let me know if this guide helped! 🙂