Blog Posts

Packaging solution for (php-)projects

At Liip we have been relying on Debian and RedHat packages to deploy our web applications for some time now. For this we created or in some cases adapted some project/framework-specific solutions:

The existing solutions work very well but they're also very specific. Since we don't really want to reinvent the wheel for every new project/framework we decided to start looking for a more generic solution. The prerequisite was that it had to support Debian and Red Hat packages.

With fpm, by Jordan Sissel, we found a solution that can create either Debian or Red Hat packages. Basically, fpm just takes all the files inside a directory and creates a package from that.

Since the layout of the application in a development environment is usually different from the production system (on a dev environment you might have the project files in your home directory whereas in the production environment they should end up in /var/www/projectname) there was still some work involved beside running fpm. But we wanted something that was automated as much as possible: developers should only need to setup packaging once and after that they would only have to execute a simple command to build packages.

For this reason we decided to build a set of wrapper scripts around fpm. With these scripts, you just need to create a configuration file that defines the layout on the target system and some package parameters. Once you created the configuration file, a simple command creates a Makefile for you. After that, building your package is as easy as typing "make" in your project directory. What is really nice with this packaging solution it's that it's a) easy to use and b) platform-independent (for Debian packages at least) since you can use fpm on any platform you want.

We made the scripts available on github so other people can benefit from them. To help people get into it and demonstrate some of the possibilities of this solution, we created a demo project that you can try to package and deploy. If you just want to build Debian packages you can just install fpm and you should be good to go (it even works on OS X, so you don't need a Debian machine to create packages). For rpm packages you unfortunately still need rpmbuild.

Related Entries:
- LaraconEU 2014 - Empowering the PHP people
- Discussions and Pizza at PHPDay Italy
- Of HHVM, Hack and the future of PHP
- RESTing with Symfony2
- Content storage done right

About the author

Find more about him on Twitter and Google+.

Comments [11]

Christoph Luehr, 22.11.2011 11:19 CET

Note: .. the demo project on github seems to reference so a git submodule update won't work - i know i could just fetch the packaging part from github, but i guess the demo was not intended to work like this.

Anyway, thanks for the contribution.

Kind regards, Chris

Sylvain Fankhauser, 22.11.2011 11:32 CET

Thanks for the feedback, this has just been fixed!

cordoval, 22.11.2011 15:42 CET

what are the requirements, will this work only for VPSs?
is there a way perhaps to make it work for sharedhosting? probably not, but then what are the alternatives to this...

I am sure it works very nicely on VPSs


Adrian Schlegel, 22.11.2011 15:52 CET

You won't be able to install packages on a shared hosting. To install packages you need root privileges which you don't have on shared hostings. You will have to install your application through ftp or whatever access the hoster provides.

Hans de Raad, 24.11.2011 23:32 CET

Thanks for these useful pointers! Have you ever looked at the Open Build Project?
My company is running a local instance of it which provides packages for openSUSE, Fedor and Ubuntu.

Adrian Schlegel, 25.11.2011 09:55 CET

We looked into Open Build. As far as I understood you still need to have some knowledge of the inner workings of .deb and .rpm packages in order to create packages for the corresponding architecture. But we were looking for something that doesn't force people to have to write debian control or rpm spec files.

injection moulding, 15.02.2012 10:06 CET

I have a shared hosting account with multiple users. Can i use this application for the time being and switch to a dedicated hosting server later when i feel comfortable?

Adrian Schlegel, 16.02.2012 10:08 CET

Please see the fourth comment. This solution is NOT for shared hosting environments.

ikoniaris, 21.10.2012 00:54 CET

Thanks for this blog post and fpm reference. Finally an easy way to create a damn deb package :) Cheers!

Michael Frank, 07.12.2013 11:19 CET

A reliable blog always comes-up with new and exciting information and while reading I have feel that this blog is really have all those quality that characterize a blog to be a best one.
Marijuana Seeds

mohan, 12.12.2013 07:06 CET

The international leg usually has good movies on-demand but even then staring at a teeny screen on the back of someone else's seat isn't always the best so here are a few tips I have for those of you who will be taking long flights.tree service

Add a comment

Your email adress will never be published. Comment spam will be deleted!