Home > Blog, Technomancy > Optimise your pair-hosted WordPress site – use php-cgiwrap

Optimise your pair-hosted WordPress site – use php-cgiwrap

Wordpress 2.8 named after Chet BakerThe developers at WordPress have been quick to build on the redesign of the Dashboard in version 2.7, with optimised performance in 2.8 and slick features for managing your themes and plugins including theme download/preview/activation directly from the Dashboard. Much work has been done on the automatic upgrade of the core software and plugins, so much so that Automatic Upgrade is the recommended upgrade path from version 2.7.x to 2.8.

Upgrade slows to grinding halt
However when I tried the automatic upgrade of this site (my personal blog), which is hosted with pair Networks, it took several hours to complete with no feedback on progress throughout that time, which didn’t look too promising. I decided to be patient and leave it to do its stuff. At the end of the process the updated Dashboard confirmed that it was now using version 2.8, but it was disappointing to see it flagging a suspicion that the upgrade had not fully completed.

FTP-based auto upgrade is the fallback option
Once it had been pointed out that the Automatic Upgrade can be completed in under a minute or so (thanks Leon) I went looking for the cause and solution for this less than perfect situation. It dawned on me that WordPress could only perform a quick update if this could be run directly from the PHP script without recourse to FTP. However on many hosting services including pair Networks, the default Apache setup runs PHP scripts as user nobody, which will not give the required access control for managing an upgrade of the core WordPress files. WordPress apparently detects this issue and offers an automatic FTP-based upgrade as a fallback option. It is easy to see how the FTP-based approach could drag out for hours as there are over 800 individual files to be transferred under the control of the PHP script, not to mention the management of existing files to be deleted or replaced.

Mahodder provides the answer – use php-cgiwrap on pair hosted WordPress sites
On the WordPress Support Forum I found a thread which specifically tackled the Automatic Upgrade issue on a pair-hosted WordPress site (thanks Mahodder). The solution is to enable the php-cgiwrap facility so the PHP scripts on your pair site (including any WordPress software) can run as your userid/group rather than the nobody/www user/group. This boils down to a two-step process:

  1. copy the php-cgiwrap interpreter to your cgi-bin directory
  2. modify your .htaccess to invoke the php-cgiwrap interpreter for PHP scripts

The full instuctions are given on the support document at pair Networks.

Dealing with the nobody hangover
The good news is that I am now taking advantage of the super-quick super-convenient automatic update facilities in WordPress 2.8 – the bad news is that established sites will have directories such as uploads, which will be owned by nobody and will now be inaccessible and unmanageable by WordPress. Indeed you can’t do much to sort them out via SSH connection to your pair host. I used a quick and dirty perl CGI script to fix such folders, but that’s a story for another day.