Installing xcache for PHP5 on Debian Etch

XCache is an opcode cacher for PHP developed by the Lighttpd team. The full description directly from http://xcache.lighttpd.net/

XCache is an opcode cacher for PHP developed by the Lighttpd team. The full description directly from http://xcache.lighttpd.net/

XCache is a fast, stable PHP opcode cacher that has been tested and is now running on production servers under high load. It is tested (on linux) and supported on all of the latest PHP cvs branches such as PHP_4_3 PHP_4_4 PHP_5_0 PHP_5_1 PHP_5_2 HEAD(6.x). ThreadSafe/Windows is also supported. It overcomes a lot of problems that has been with other competing opcachers such as being able to be used with new PHP versions. See Introduction for more information.

There is no XCache package within the apt repositories for Debian Etch, however it is available within Debian SID/Testing. You will need to then download the source, compile it and install it. You can download the 1.2 stable source from the following here:

http://xcache.lighttpd.net/wiki/Release-1.2.2
http://xcache.lighttpd.net/pub/Releases/1.2.2/xcache-1.2.2.tar.gz

The second link is the full XCache source, you can use “wget”, “curl” or lynx to retrieve the archive onto your machine.

Once downloaded, extract the archive and a directory called xcache-1.2.2 should have been created and you will want to change directory into it:


[root@jager:/root/source/xcache]# tar -zxvf xcache-1.2.2.tar.gz
[root@jager:/root/source/xcache]# ls -al
total 280K
drwxr-xr-x 3 root root 4096 2008-01-14 18:58 ./
drwxr-xr-x 4 root root 4096 2008-01-14 18:58 ../
drwxr-xr-x 5 513 513 4096 2007-12-28 10:00 xcache-1.2.2/
-rw-r--r-- 1 root root 269238 2007-12-28 23:45 xcache-1.2.2.tar.gz
[root@jager:/root/source/xcache]# cd xcache-1.2.2

You will need to make sure that you have “php5-devel” installed so you can use “phpize” to create the module, a simply “apt-get install php5-dev” as root should do the trick. You may need to type “rehash” if using tcsh to be able to run “phpize”.

Now we need to prepare the module for configuration by typing the following:


[root@jager:/root/source/xcache/xcache-1.2.2]# phpize --clean && phpize
Cleaning..
Configuring for:
PHP Api Version: 20041225
Zend Module Api No: 20060613
Zend Extension Api No: 220060519

Then you will need to configure XCache before compiling, at this point you may want to run “./configure –help”. Which will provide information on the configuration options available for XCache that you can change when it compiles. If you don’t need to change anything, just run “./configure”.

If any errors were returned then you’re most likely missing some supporting packages and you will need to install them. If no errors were returned then you can simply run “make”.

Once the module has been compiled it should now reside within the “modules” directory. You can now copy to the proper PHP5 module directory:


[root@jager:/root/source/xcache/xcache-1.2.2]# cp modules/xcache.so /usr/lib/php5/20060613+lfs
`modules/xcache.so' -> `/usr/lib/php5/20060613+lfs/xcache.so'

Now that the module exists, we need to make a configuration file for it so that PHP5 will load the module and configuration. You should see a “xcache.ini” within the root folder of the extract archive. Just copy it to the correct configuration folder within /etc:


/etc/php5/apache/conf.d <- Configuration file for PHP5 as a Module in apache1.3x /etc/php5/apache2/conf.d <- Configuration file for PHP5 as a Module in apache2.x /etc/php5/cgi/conf.d <- Configuration file for PHP5 compiled as a CGI Binary /etc/php5/cli/conf.d <- Configuration file for PHP5 compiled as a Command Line Binary

For our example, I'm using the PHP5 CGI Binary:


[root@jager:/root/source/xcache/xcache-1.2.2]# cp xcache.ini /etc/php5/cgi/conf.d/.
`xcache.ini' -> `/etc/php5/cgi/conf.d/./xcache.ini'

Now make sure to edit the following configuration values within the xcache.ini file:


[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

Change the "zend_extension" to just "xcache.so" and comment out "zend_extension_ts " like so:


[xcache-common] ;; install as zend extension (recommended), normally "$extension_dir/xcache.so"
extension = 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

You will also need to change the following from:


; to enable : xcache.size=64M etc (any size > 0) and your system mmap allows
xcache.size = 64M
; set to cpu count (cat /proc/cpuinfo |grep -c processor)
xcache.count = 1

To something like the following:


; to enable : xcache.size=64M etc (any size > 0) and your system mmap allows
xcache.size = 64M
; set to cpu count (cat /proc/cpuinfo |grep -c processor)
xcache.count = 4

If you have a Dual Pentium4 with Hyper Threading.

Just restart apache by issuing "invoke-rc.d apache2 restart", and all should be working!

To test whether or not the extension/module was loaded and working, you can put the following code within an PHP file and pull it up in your browser and search for XCache:



And you should see the following:


This program makes use of the Zend Scripting Language Engine:
Zend Engine v2.2.0, Copyright (c) 1998-2006 Zend Technologies
with XCache v1.2.2, Copyright (c) 2005-2007, by mOo

Enjoy!

0 Shares:
You May Also Like

Rumors of new Gnash functionality exaggerated

This really sucks. When I use Debin I have to install the flash player for FireFox from a different source you get all your other applications within Debian. This is done by modifying the apt-get configuration file. Other Distribution's you have to download the linux plugin from Adobe and install it manually.
Rumors of new Gnash functionality exaggerated -

A free Flash viewer is one of the last major gaps in GNU/Linux desktop functionality, so last week's news that Gnash, the free Flash player, had reached the stage where it could play YouTube and Lulu.tv videos seemed too good to be true. Unfortunately, it was.

[Linux.com]

ZFS On Linux – It’s Alive!

This is just lovely. A file system that can take automatic snap shots!
ZFS On Linux - It's Alive! - lymeca writes "LinuxWorld reports that Sun Microsystem's ZFS filesystem has been converted from its incarnation in OpenSolaris to a module capable of running in the Linux user-space filsystem project, FUSE. Because of the license incompatibilities with the Linux kernel, it has not yet been integrated for distribution within the kernel itself. This project, called ZFS on FUSE, aims to enable GNU/Linux users to use ZFS as a process in userspace, bypassing the legal barrier inherent in having the filesystem coded into the Linux kernel itself. Booting from a ZFS partition has been confirmed to work. The performance currently clocks in at about half as fast as XFS, but with all the success the NTFS-3g project has had creating a high performance FUSE implementation of the NTFS filesystem, there's hope that performance tweaking could yield a practical elimination of barriers for GNU/Linux users to make use of all that ZFS has to offer."

Read more of this story at Slashdot.

[Slasdot]

CheckGmail 1.12 (Default branch)

CheckGmail 1.12 (Default branch) - Screenshot CheckGmail is a system tray application that checks a Gmail account for new mail. It is fast, secure, and uses minimal bandwidth via the use of Atom feeds.
License: GNU General Public License (GPL)
Changes:
This release adds information about attachments and clickable URIs in the message full text. Numerous bugs have been fixed, including the issues with XGL/Compiz, international character display, and multiple monitors.

[FreshMeat]

New LinuxCOE helps admins customize distros

This is a really neat idea. You can roll all of your scripted installations for all of your distributions into one application, instead of configuring each distributions application. For example, if you wanted to install RedHat, you no longer need Kickstart. The same would go for Ubuntu, no more preseed. Just one application to handle all of the scripted installations.
New LinuxCOE helps admins customize distros - Hewlett-Packard released version 4 of its Linux Common Operating Environment (LinuxCOE) software this month. LinuxCOE is a front end to a set of Perl scripts that helps administrators by building customized install images for various Linux... [Linux.com]

First Google Android Phone Approved by the FCC

The first Google Android Phone has been approved by the FCC. The HTC dream will be the first Android phone.
Today, the news broke that the HTC Dream, the first handset to run Android (aka "the Google Phone") has been approved by the FCC. In the documents provided, it appears that we have now a release date for this highly anticipated phone: November 10th, 2008.
Another challenger appears! Read the full article at readwriteweb.com