Integrating XCache Into PHP5 (Fedora /CentOS & Apache2)
This article explains how to integrate XCache into PHP5 on a Fedora 13 or CentOS 5.5 system (with Apache2). From the XCache project page: “XCache is a fast, stable PHP opcode cacher that has been tested and is now running on production servers under high load.” It’s similar to other PHP opcode cachers, such as eAccelerator and APC.
If you see that another PHP opcode cacher such as eAccelerator or APC is installed in phpinfo.php output, then you must remove it before you install Xcache. you need root access for removing this pkgs.
For eAccelerator:yum remove php-eaccelerator For APC:yum remove php-pecl-apc Restart Apache afterwards:/etc/init.d/httpd restart OR service httpd restartInstalling XCache
Unfortunately XCache isn’t available as an rpm package for Fedora /CentOS , therefore we have to build it from the sources. First we install all packages that we need to build XCache:
yum install php-develyum groupinstall ‘Development Tools’yum groupinstall ‘Development Libraries’ Next we download and uncompress the latest XCache version:cd /tmpwget http://xcache.lighttpd.net/pub/Releases/1.3.0/xcache-1.3.0.tar.gz
tar xvfz xcache-1.3.0.tar.gzThen we go to the new XCache source directory…
cd xcache-1.3.0
… and build XCache as follows:
phpize
./configure –enable-xcache
make
make install
Next we copy xcache.ini to the /etc/php.d directory:
cp xcache.ini /etc/php.d
Now we must configure XCache. The configuration options are explained here: http://xcache.lighttpd.net/wiki/XcacheIni. The least you should do is enable extension = xcache.so and disable all zend_extension lines; furthermore, set xcache.size to a size (in MB) > 0 to enable XCache:
vi /etc/php.d/xcache.ini—————————————–[xcache-common] ;; install as zend extension (recommended), normally "$extension_dir/xcache.so" ;zend_extension = /usr/local/lib/php/extensions/non-debug-non-zts-xxx/xcache.so ; zend_extension_ts = /usr/local/lib/php/extensions/non-debug-zts-xxx/xcache.so ;; For windows users, replace xcache.so with php_xcache.dll ;zend_extension_ts = c:/php/extensions/php_xcache.dll ;; or install as extension, make sure your extension_dir setting is correct extension = xcache.so ;; or win32: ; extension = php_xcache.dll [...] xcache.size = 60M [...] ---------------------------
That’s it. Restart Apache, and you’re done:
/etc/init.d/httpd restart OR service httpd restart Afterwards, open phpinfo.php again in a browser: http://localhost/phpinfo.php