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

0
493

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.

大家会发现刚装完的kloxo默认并没有安装上xcache即使在面板里enable也无效,官方的说法是登录设shell运行

/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

如果是kloxo用户到这步就行了,因为kloxo本身已经有xcache.ini了,如果是Linux用户可以接着往下。


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