CentOS Install XCache for PHP 5(不仅适用于kloxo)


XCache 简介:

XCache is a open-source opcode cacher, which means that it accelerates the performance of PHP on servers. It optimizes performance by removing the compilation time of PHP scripts by caching the compiled state of PHP scripts into the shm (RAM) and uses the compiled version straight from the RAM. This will increase the rate of page generation time by up to 5 times as it also optimizes many other aspects of php scripts and reduce serverload.


/script/ xcache-install,


Step # 1: Download xcahce source code

Use wget command to download latest stable release:

# cd /opt
#  wget http://xcache.lighttpd.net/pub/Releases/1.3.0/xcache-1.3.0.tar.gz

Step # 2: Untar tar ball

Use tar command:

# tar -zxvf xcache-1.3.0.tar.gz
# cd  xcache-1.3.0

Step # 3: Compile and install xcahce

Use phpize command to prepare xcache as a PHP extension for compiling:

# phpize

Configure, compile and install xcache:

# ./configure --enable-xcache
# make
# make install 

Default xcache.so installation location

  • 64 bit PHP module installed at /usr/lib64/php/modules/xcache.so
  • 32 bit PHP module installed at /usr/lib/php/modules/xcache.so


Step # 4: Create xcache.ini file

Under RHEL / CentOS, you place php modules configuration at /etc/php.d/ directory:

# cd /etc/php.d/

Create xcache.ini file:

# vi xcache.ini

Configuration 内容参看:xcache.ini

Alternatively, you can also copy default xcache.ini to /etc/php.d/

#  cp xcache.ini /etc/php.d/
# vi /etc/php.d/xcache.ini

Restart your Apache web server:

# service httpd restart

If you are using Lighttpd web server, enter:

# service lighttpd  restart

Step # 5: Make sure xcache is working

Type the following command for verification:

$ php -v