How to upgrade software installed from source?

I install NGinx from source since the packages from the ubuntu repository are quite old. I was wondering what is the best method to upgrade these types of installations?

My current workflow involves.

  • Downloading the new source
  • Install the software with the same paths.
  • Restarting the software.

Something tells me this is not the best route.

Suggestions?


You are right to think this isn't the best route. This route requires many manual steps, and is very error prone, and doesn't scale well.

When working with linux distributions, you should stick to the package management as much as possible.

The advantages of using package management:

  • Dependency support
  • Easy installation/removal
  • Software inventory
  • Upgrade/Downgrade support, including handling of configuration files
  • The source package basically documents your build process, and automated it for you once it's written.
  • Package signing
  • and more.

When you start working from source only, you loose all of these great features, and things start to get messy pretty quickly.

In order to solve your spesific problem, you should check out the ubuntu backports repository, maybe they have an updated version for NGinx that you can use.

If they don't have a suitable version, then the best solution would be to create a backported ubuntu package yourself. It really isn't that hard, and it's less work than compiling it from source manually each time. Backporting requires, basically, taking the source package from ubuntu, replacing the old upsteam tar.gz file with the latest one that you want, and rebuilding the package.

You can use this guide to help you backport the package.


I found it quite convenient to installed different version in separate locations and just symlink to the version you want to use, like:

lrwxr-xr-x  1 root  wheel     7B Jun  7 18:26 /usr/local/foo -> foo-1.0
drwxr-xr-x  2 root  wheel   512B Jun  7 18:26 /usr/local/foo-1.0
drwxr-xr-x  2 root  wheel   512B Jun  7 18:26 /usr/local/foo-1.1

The benefits are:

  • minimized service downtime during an upgrade
  • easy rollback
  • you can still use the same o' path, like /usr/local/foo/bin/bar

Of course you still have to re-apply any configuration changes you've done to the previous version, but for that you can use some versioning system (RCS/SVN/GIT) or configuration management tool like Bcfg2.

And, of course this is suitable only for a handful or less hosts.


Next time... how about compiling it into a *.rpm or *.deb?