[ HOW-TO] Install XCache on CentOS 5.2 64-bit that has DirectAdmin installed
Category:
First of all, if you are using DirectAdmin in PHP-CGI (suPHP) mode, don't waste your time follow this HOW-TO. Although these steps work with PHP-CGI but you will get nothing from doing it. For PHP-CLI, I found that it help to decrease my server load from about 10 or more down to about 1 but always less than 2. (I have quad core CPU and my problem before is that CPU usage is almost always 100%.) It's useful module that you should have it installed.
Step 1 : Get XCache and uncompress it
cd /tmp wget http://xcache.lighttpd.net/pub/Releases/1.2.2/xcache-1.2.2.tar.gz tar -xvf xcache-1.2.2.tar.gz
Step 2 : Use phpize command to prepare xcache as a PHP extension for compiling:
cd xcache-1.2.2 phpize
Configuring for: PHP Api Version: 20041225 Zend Module Api No: 20060613 Zend Extension Api No: 220060519
Step 3 : Configure, compile and install XCache
./configure --enable-xcache make make install
Installing shared extensions: /usr/local/lib/php/extensions/no-debug-non-zts-20060613/
Notice that the location of file extension is : /usr/local/lib/php/extensions/no-debug-non-zts-20060613/
Step 4 : Enable extension and also create configuration
All document I found said you need to create xcache.ini. However, I did a bit different, I just merge xcache.ini into php.ini
nano -w /usr/local/lib/php.ini
Put following configuration in php.ini
[xcache-common] ;; install as zend extension (recommended), normally "$extension_dir/xcache.so" zend_extension = /usr/local/lib/php/extensions/no-debug-non-zts-20060613/xcache.so zend_extension_ts = /usr/local/lib/php/extensions/no-debug-non-zts-20060613/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.admin] xcache.admin.auth = On xcache.admin.user = "mOo" ; xcache.admin.pass = md5($your_password) xcache.admin.pass = "" [xcache] xcache.shm_scheme = "mmap" xcache.size = 60M xcache.count = 1 xcache.slots = 8K xcache.ttl = 3600 xcache.gc_interval = 300 ; Same as aboves but for variable cache ; If you don't know for sure that you need this, you probably don't xcache.var_size = 4M xcache.var_count = 1 xcache.var_slots = 8K xcache.var_ttl = 0 xcache.var_maxttl = 0 xcache.var_gc_interval = 300 ; N/A for /dev/zero xcache.readonly_protection = Off xcache.mmap_path = "/dev/zero" xcache.cacher = On xcache.stat = On
Make sure that [xcache-common] and its content come before [Zend] or you will get an error about incompatibility something like that.
Step 5 : Restart httpd service
/etc/init.d/httpd restart
After restart, type php-v. You will see that XCache is installed :
with XCache v1.2.2, Copyright (c) 2005-2007, by mOo
php -v
PHP 5.2.6 (cli) (built: Oct 12 2008 03:54:55)
Copyright (c) 1997-2008 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2008 Zend Technologies
with XCache v1.2.2, Copyright (c) 2005-2007, by mOo
with Zend Extension Manager v1.2.2, Copyright (c) 2003-2007, by Zend Technologies
with Suhosin v0.9.27, Copyright (c) 2007, by SektionEins GmbH
with Zend Optimizer v3.3.3, Copyright (c) 1998-2007, by Zend Technologies
This tutorial is based on -> Redhat / CentOS / Fedora Linux Install XCache for PHP 5
Update (Aug 24, 09): XCache 1.3.0 can use the same steps. Also, configuration file is updated to match the one got from XCache 1.3.0
- "xcache.size = 60M" vs "xcache.size = 32M"
- "xcache.var_size = 4M" vs "xcache.var_size = 0M"
========================================
Update (Jan 28, 2010) : XCache 1.3.0 with PHP 5.3.1. There is mainly a change on Directory.
========================================
Step 1 : Get XCache and uncompress it
cd /tmp wget http://xcache.lighttpd.net/pub/Releases/1.3.0/xcache-1.3.0.tar.gz tar -xvf xcache-1.3.0.tar.gz
Step 2 : Use phpize command to prepare xcache as a PHP extension for compiling:
cd xcache-1.3.0 phpize
Configuring for: PHP Api Version: 20090626 Zend Module Api No: 20090626 Zend Extension Api No: 220090626
Step 3 : Configure, compile and install XCache
./configure --enable-xcache make make install
Installing shared extensions: /usr/local/lib/php/extensions/no-debug-non-zts-20090626/
Notice that the location of file extension is : /usr/local/lib/php/extensions/no-debug-non-zts-20090626/
Step 4 : Enable extension and also create configuration
All document I found said you need to create xcache.ini. However, I did a bit different, I just merge xcache.ini into php.ini
nano -w /usr/local/lib/php.ini
Put following configuration in php.ini
[xcache-common] ;; install as zend extension (recommended), normally "$extension_dir/xcache.so" zend_extension = /usr/local/lib/php/extensions/no-debug-non-zts-20090626/xcache.so zend_extension_ts = /usr/local/lib/php/extensions/no-debug-non-zts-20090626/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.admin] xcache.admin.auth = On xcache.admin.user = "mOo" ; xcache.admin.pass = md5($your_password) xcache.admin.pass = "" [xcache] xcache.shm_scheme = "mmap" xcache.size = 60M xcache.count = 1 xcache.slots = 8K xcache.ttl = 3600 xcache.gc_interval = 300 ; Same as aboves but for variable cache ; If you don't know for sure that you need this, you probably don't xcache.var_size = 4M xcache.var_count = 1 xcache.var_slots = 8K xcache.var_ttl = 0 xcache.var_maxttl = 0 xcache.var_gc_interval = 300 ; N/A for /dev/zero xcache.readonly_protection = Off xcache.mmap_path = "/dev/zero" xcache.cacher = On xcache.stat = On
Make sure that [xcache-common] and its content come before [Zend] or you will get an error about incompatibility something like that.
Step 5 : Restart httpd service
/etc/init.d/httpd restart
After restart, type php-v. You will see that XCache is installed :
with XCache v1.3.0, Copyright (c) 2005-2009, by mOo
php -v
PHP 5.3.1 (cli) (built: Jan 28 2010 14:34:21)
Copyright (c) 1997-2009 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2009 Zend Technologies
with XCache v1.3.0, Copyright (c) 2005-2009, by mOo
========================================
Note (Jul 2, 2011) : Problem compile XCache if you have both PHP 5.2.x and 5.3.x on the same server.
========================================
If your server have both PHP 5.2.x and 5.3.x, when you compiled it's possible that the compiled file will always compiled for PHP 5.2.x. So, the xcache.so will be in " /usr/local/lib/php/extensions/no-debug-non-zts-20060613/ ". But if you want to use XCache with PHP 5.3.x, you need it in "/usr/local/lib/php/extensions/no-debug-non-zts-20090626/"
So, you need to specify PHP 5.3.x path when using command "phpize" and "./configure" Below is what I use :
/usr/local/php5/bin/phpize ./configure --enable-xcache --with-php-config=/usr/local/php5/bin/php-config make make install
Comments
Anonymous
Thu, 12/11/2008 - 17:56
Permalink
you are a hero!
I have been trying to install this xcache with directadmin for the last month and never succeeded, the merging of the files did the trick - thank you very much!
Anonymous
Wed, 02/11/2009 - 06:51
Permalink
Thank You
I too have been trying to get around DirectAdmin. By the way, your instructions also work with my VPS's 32-bit CentOS 4.7[Final] along its PHP5+DirectAdmin installed. In addition, I too can attest that merging the .ini files was simply practical.
Thanks again for making this step by step tutorial available.
Anonymous
Mon, 08/24/2009 - 08:57
Permalink
xcache.var_size
I think that this setting must not be blank (xcache.var_size = 0M_
For test just do this :
This page has been visited <?php echo xcache_inc("count"); ?> times.
with xcache.var_size = 0M and then with xcache.var_size = 32M
BXTra
Mon, 08/24/2009 - 11:03
Permalink
Just checked configuration
Just checked configuration file comes with XCache 1.3.0. The default is 4M :)
Add new comment