I tried out XCache for PHP 5 again last night. I had used it in the past a little, but then put it on the shelf for awhile because it seemed a little buggy. The developer has been hard at work and the project has come a long way since I last checked in. The developer also contributes to lighttpd, and I’ve also recently started to dabble with that again.
But anyway back to XCache - it is an opcode cacher for PHP and helps speed up PHP scripts by caching their compiled versions, as PHP is an interpreted language - the compiling happens at runtime. It also has a variable cache, which seems to me to be a quick and easy memcache alternative. You can simply store variables in the cache, and retrieve them later. Pretty cool! I ran into a problem with this once by adding such mechanisms into my code, and then trying to run that code on machines that didn’t have xcache installed. Doh!
Inasmuch, the opcode cache works if xcache is available and activated with no changes to the source PHP code, which is nice for portability.
When trying to install the XCache FreeBSD port, I ran into a problem:
Cannot find autoconf. Please check your autoconf installation and the $PHP_AUTOCONF environment variable is set correctly and then rerun this script.
I reinstalled php5 and autoconf but still got the error, so I logged out, and logged back in, and then it worked. Huh.FreeBSD PHP5
While on the subject, I’ll mention how to enable php5 on freebsd / lighttpd:
- Edit /usr/local/etc/lighttpd.conf uncomment "mod_fastcgi",
- Enable XCache php5: copy xcache.ini /usr/local/etc/php/ (I had to create that folder)
I also noticed that the php cgi module has been hardened: “This server is protected with the Suhosin Patch 0.9.6.2”.