Running Perch on PHP Fog

New PHP cloud hosting startup PHP Fog is an interesting prospect for Perch customers. Time will tell how it works in practice, but the promise of cloud hosting is a fast, reliable platform that can scale up as your site becomes more popular.

Whilst Perch was initially designed for small sites, what we have found is that customers are using it for simple sites, but some of those can be quite large and deal with heavy traffic loads. A scalable cloud platform is certainly a good option, even if you don’t think you’ll need all that power any time soon.

To see how Perch would work on PHP Fog, we signed up for a free account and put it through its paces.

Adding files to your site

Transferring your files to your PHP Fog site (or app as they call it) is a little bit different to the normal SFTP process. PHP Fog uses the git source control system to manage file transfer. The idea is that you clone a special source repository that they give you to your local machine, work on your files and then move them back to the server with a git push command.

The first stumbling block is that you need to set up SSH keys for your local computer to be able to seamlessly authenticate with PHP Fog’s servers. Good step-by-step documentation is provided (including sensible steps like backing up your existing configuration before making changes) but this is a mildly terrifying command line process if you’re not used to it. I already use SSH keys for other tasks, so just had to dig out my public key and copy it over. Once the SSH keys are configured, your computer and the server can communicate without needing to prompt you for a password each time, so the scary process is worth it.

I’d not used git before, but am familiar with subversion, and for this purpose that was enough. PHP Fog give good instructions as to how to get started. I cloned my site’s repository onto my local computer, and then copied the perch folder into it. The command git add . (note the dot) adds the new files to the repository, and git commit -m "Adding Perch" commits the change. All I needed to do was a git push and the files were transferred to the server.

Installing Perch

The setup process is then pretty much the same. The PHP Fog control panel gives you all the database details you need (server, database name, username and password). The only difference is that when we ask you to copy the configuration information into your config.php file, you need to do this locally, commit the change and push the files again.

After setup, delete the setup folder with git rm perch/setup -r (and commit and push).

Setting permissions

Perch needs the perch/resources folder to be writable in order to upload files and images. Fortunately, PHP Fog provides a control panel for setting permissions on files and folders.

The only stumbling block was that after entering perch/resources as a writable folder, the changes didn’t take effect. After some sniffing around the (rather good) documentation, I found that git doesn’t create empty folders – and of course the resources folder is empty by default.

To get around this, I created a text file (I called it tmp.txt) in my local resources folder, added, committed and pushed it to the server. This meant that the perch/resources folder was no longer empty, so it got created on the server. I could then set my permissions again through the PHP Fog control panel and they took effect as expected.

Conclusion

Perch runs well on PHP Fog, but you need to be comfortable using git and happy to follow those SSH key instructions. Therefore, PHP Fog is probably biased towards the more technical user, although in all other respects it’s extremely friendly and non-technical to configure and operate.

Deploying a site using git push is extremely easy if you’re a confident git user. If you’re not, it’s actually fairly daunting. If you’re the sort of person who’s happy to learn some command line tools in order to get a job done, then PHP Fog is well worth checking out as a possible way to host a Perch site.