Archives

2008 (183)
2007 (276)
2006 (343)
2005 (56)
2004 (4)
2003 (8)
2002 (7)

Search

Type in this box and hit “enter” to search through all titles, content, authors, along with tags on bookmarks, photos, etc.

Searches for words which bring up more than half of all entries are ignored.

Tags

Top 30 tags I’ve added to blog posts and bookmarks.

beograd (15)
car (15)
code (48)
españa (24)
food (20)
geek (67)
holiday (17)
java (18)
kingsland (19)
kingsland road (22)
london (255)
madrid (16)
madrid march 2007 (16)
madríd (16)
olympic (15)
olympic torch (15)
olympic torch relay (15)
philosophy (28)
php (16)
programming (17)
railway (15)
road (24)
serbia (18)
shoreditch (70)
spain (24)
station (16)
street (47)
torch relay (15)
whitechapel (15)
whitechapel road (15)

About me

I live and work around Shoreditch, London. My obsession with making Internet stuff leads me to spend my days heading up the tech side at POKE. What you’re looking at is entirely my doing, though, and as you’ve probably guessed, in no way reflects POKE’s views on anything, at all, ever.

In addition to providing me with a soapbox, this site tracks what I’m up to online using feeds from Flickr, del.icio.us and others.

View my profile on LinkedIn

.

Regular reads

Sunday, August 3, 2008

Sphinx - Free open-source SQL full-text search engine

Adds a searchable external index of specified data, meaning fast searches without db joins/FULLTEXTs etc.

Monday, July 14, 2008

php-fpm: a smoother PHP/FastCGI process manager

I’ve been running PHP apps with the standard PHP FastCGI server behind nginx for a couple of years now, and in that time have worked up a set of tools to manage PHP processes with multiple configuration profiles. This has been based around my slightly hacked version of Alexey Kovyrin’s PHP–FCGI spawn script, along with a chkconfig–compatible init script I’ve written as a front–end to control it, taking in some simple per–profile configuration in /etc/sysconfig/php-fcgi.

Various contributors to the English nginx mailing list have posted in that time singing the praises of Andrei Nigmatulin’s php-fpm, a patch to the PHP source which adds “FastCGI Process Management” to the standard php-fcgi binary. It’s apparently in use in some pretty heavily–loaded sites, and I’ve had it in mind to check it out, but as my setup has been stable (if not exactly full–featured) over the last few projects, I haven’t had a huge impetus to get and do it. Today, however, I finally had enough downtime to check it out, and now I’m wishing I’d done it earlier.

My existing method basically worked like this:

· init script reads configuration file, with one “profile” per line detailing location of php.ini file, interface and port to run on, number of child processes to run, number of requests to serve before a re–spawn, etc.;

· init script uses these details to construct a command–line to call Alexey’s spawn script, once for each profile;

· spawn script constructs environment and command–line argument list to spawn a set of PHP processes for each profile entry.

This has worked fine, but as so often with these things, the init script became a bit unwieldy with additions over time, and is still unable to do anything elegant like graceful restarts on the PHP daemons.

php-fpm addresses these issues and more. The “profile” configuration is put into a sensible, clear configuration file (php-fpm.conf) which allows you to specify a number of named PHP process “pools”, each with its own detailed FastCGI server and PHP configuration.

The documentation’s somewhat light, and mostly in Russian, but it has all you need to get going, and the configuration file is easy to read. Once you’ve configured the pools you want (in my case sets of named dev/stage/live setups on different ports, so as to keep include_paths — and therefore library code — properly staged), you just need to run php-cgi --fpm. From there on, you can send various signals to the master process including SIGQUIT for a graceful stop, SIGUSR1 to cycle log files, and SIGUSR2 for a graceful reload/restart. The master process ID is stored in $PHP_PREFIX/logs/php-fpm.pid.

I’ll probably write a simple chkconfig/init wrapper to send these signals to the master using e.g. /etc/init.d/php-fpm graceful, but that’s about all I’ll need to do in order to replicate and extend my existing setup.

Not only does this simplify and tidy up my PHP–FCGI setup enormously, it also adds a number of convenient extra points, including IP–restriction and a nice fix for the fix for the “empty error” page problem. Intuitively it “feels” a lot more solid, and I’m looking forward to trying it out on the next suitable project. Nice bit of Russian coder humour there on the “extra points” page, too. Thanks, Andrei!

Wednesday, November 21, 2007

xajax PHP Class Library - The easiest way to develop asynchronous Ajax applications with PHP

Yeah yeah, A.N. Other AJAX library. Probably really cool, but can you be bothered with another one?

Tuesday, November 13, 2007

Lumine - Database Mapping For PHP

Hmm, looks interesting but it’s in Portuguese. Have to come back to get it translated.

Thursday, October 11, 2007

Multiuser Apache+PHP+mod_fastcgi setup

how to make apache talk to php via fastcgi over tcp

Wednesday, June 27, 2007

Mac OS X launchd plist to run PHP fcgi

Tuesday, June 12, 2007

Template Engines

Text* Snippets: php code

Monday, April 30, 2007

Roadsend Compiler - Trac

Wednesday, April 11, 2007

International PHP Mag: "OO approach for shared memory"