How to Integrate XCache Into PHP5 on Debian Etch with lighttpd
This is a handy guide for integrating Xcache into PHP5 on Debian Etch system using lighttpd. This definition is taken from Xcache project page, and that is “XCache is a fast, stable PHP opcode cacher that has been tested and is now running on production servers under high load.” It is identical to other PHP opcode cachers, like eAccelerator and APC. These lines of code worked very well for me that is the reason for sharing it with you, but I am not guaranteeing that would work for you accurately; as it depends on system specifications and requirements.
Instructions
-
1
Note: 1 Beginning Note
These have been tested on a Debian Etch server with IP address 192.168.0.100 where lighttpd and PHP5 and those were working perfectly.I’ll use lighttpd’s default document root /var/www in this article for concealment purposes. You may use any of other vhost but for that you might have to set the path into info.php file.(info.php is being used in this article) -
2
Checking PHP5's Current State
Before installing Xcache first check out about our PHP installation. For checking purpose we will create a file named as info.php in our document root /var/www.
vi /var/www/info.php
Once file is created then we will call it by browser: http://192.168.0.100/info.php
Now as we have installed PHP 5.2.0
But we can’t find Xcache mentioned anywhere on page. -
3
Installing XCache
Unluckily XCache is vacant as a Debian package only for Debian Lenny (testing) and Sid (unstable), but not available for Etch. For that reason we will now install the XCache package from Lenny. For doing this, open /etc/apt/sources.list
And add the line deb http://ftp2.de.debian.org/debian/ lenny main; your/etc/apt/sources.list could then look like this:
vi /etc/apt/sources.list
deb http://ftp2.de.debian.org/debian/ etch main
deb-src http://ftp2.de.debian.org/debian/ etch main
deb http://ftp2.de.debian.org/debian/ lenny main
deb http://security.debian.org/ etch/updates main contrib
deb-src http://security.debian.org/ etch/updates main contrib
For sure (to avoid mess our system), we need to install packages from Lenny but only when if there’s no suitable package from Etch, But if there are then we want to install one of Etch. To do this, we provide packages from Etch a higher priority in /etc/apt/preferences:
vi /etc/apt/preferences
Package: *
Pin: release a=etch
Pin-Priority: 700
Package: *
Pin: release a=lenny
Pin-Priority: 650
-
4
Note: Keep in mind that terms (etch and lenny) are used for suitable terms in /etc/apt/sources.list;
And if you are using stable and testing on your end. Then make sure to use /etc/apt/preferences as well. -
5
Afterwards, now we will update our packages database:
apt-get update
... upgrade the installed packages:
apt-get upgrade
(You might see the following question:
Do you want to upgrade glibc now? [Y/n] <-- Y)
...and install php5-xcache:
apt-get install php5-xcache
That's it. Restart lighttpd, and you're done:
/etc/init.d/lighttpd restart -
6
Now, open info.php once again
browser: http://192.168.0.100/info.php
And now you can see Xcache mentioned on page that means it worked as per expectations. -
7
In case if you ever want to change the Xcache configuration you can easily do that by editing
/etc/php5/cgi/conf.d/xcache.ini.
And then restart lighttpd after editing.