Search This Techtime!

Install XCache

XCache is an Alternative APC, eAccelerator, and MemCache, It increase the server performance significantly,  XCache extension works by caching the compiled bytecode (opcode or intermediate code) form of PHP scripts to avoid the overhead to parse and compile PHP source code on every page request, and thus reduces server loads, boosts the performance of PHP scripts and increases the speed of PHP code from 2-10 times.

XCache latest version supports PHP 5.3, the latest released stable version is 1.30.

Here I will explain how to Install XCache on CentOS System 32bit/64bit OS.

1. Choose the version of XCache that suites you, If you have php Version 4.0 + you should try Xcache 1.2.x version, If your webserver is running php 5.x - 5.3 Version then you should Install Xcache 1.30.
You can easily find your installed php version by typing php -v in Shell/Telnet, or by creating a php file with , and upload the file to website via ftp and open the file in a browse.
Here is an screen shot of the image taken.


1. Retrieve and download the source package of the version of XCache you choose to install, change your present work director (PWD) or Current working directory (CWD) to /usr/local/src/you can do this by typing cd /usr/local/scr in shell

wget http://xcache.lighttpd.net/pub/Releases/1.3.0/xcache-1.3.0.tar.gz (for XCache 1.3)

or

wget http://xcache.lighttpd.net/pub/Releases/1.0.3/xcache-1.0.3.tar.gz (for XCache 1.0.3)

Latest Xcache Release can be found here http://xcache.lighttpd.net/wiki/ReleaseArchive.

3.  Following this quick commands.
Untar, unzip, unpack or extract the archive with one of the following commands:
~/src $ tar -zxf xcache-*.tar.gz

Go into the xcache directory with source content:
/usr/local/src $ cd xcache

Trigger PHP building environment:
/usr/local/src/xcache $ phpize

Run the configure with the option that you want, the basic is as below which will enable the XCache by default:
/usr/local/src/xcache $ ./configure --enable-xcache

Now Run Make Command to compile to source:
/usr/local/src/xcache $ make

Make sure every was normal, without any errors.

Now Install from the compiled files by using the following command, if you are logged in as root you do not need to use su.
/usr/local/src/xcache $ su
/usr/local/src/xcache # make install

Important Write down the xcache.so path.
It is allowed to compile xcache in scr folder it self, but it is recommended to do it in outside folder.

4. Now Xcache is installed, Congradulations.
We need to enable xcache in php.ini so that it can be used.
To do this type this command (Remember to find the exact path of php.ini, which can be found in above created file with phpinfo, which will show the php.ini loaded path.)
/usr/local/src/xcache # cat xcache.ini >> /etc/php.ini

(it's two > not one)

(now edit /etc/php.ini with your favorite editor)
/usr/loca/src/xcache # $EDITOR /etc/php.ini (Usually pico editor is good as you can search in this editor by typing CTRL+W)
(make sure zend_extension=../../xcache.so is the first before any other zend_extension=***)

5. Editing php.ini:
When you open the file in say pico.

$ pico /etc/php.ini
or
$pixo /usr/local/lib/php.ini

After that go to section called:
[xcache-common]

;; install as zend extension (recommended)

zend_extension = /usr/local/lib/php/extensions/no-debug-non-zts-xxx/xcache.so

;; install as zend extension with thread-safe

; zend_extension_ts = /usr/local/lib/php/extensions/non-debug-zts-xxx/xcache.so

;; install as PHP extension (extension_dir must be set to the full path to xcache.so)

; extension = xcache.so
Change the above non(no)-debug-non-zts-xxxxxx/xcache.so
Where as xxxxxx is the number associated with the folder.

6. If you want to do Xcache admin from web:
Do the following:

[xcache.admin]

xcache.admin.user = "admin"

xcache.admin.pass = md5($your_password)
In above enter the admin user name (Case sensitive.)
Admin password md5, this can be done by setting up a php page with webserver
with md5("password") in php file.
And upload it to server to get the md5 password.

7. xcache.size = 64M
xcache.size=0 means it is disabled and anything more then 0 means it is enabled.

Now Restart the Apache httpd web server. The following commands should work:

/etc/init.d/apache* restart

or

/etc/init.d/httpd* restart

Thats it your now having a installed copy of Xcache. which you can see in your phpinfo.

Install XCache Install XCache Reviewed by Imran Baig on 5:55:00 PM Rating: 5
Powered by Blogger.