Previous Section  < Day Day Up >  Next Section

Recipe 4.4. Installing Programs from Source Code

4.4.1 Problem

You want to install a program from source code, but you're having trouble navigating the thickets of tarballs, makefiles, and bunzips.

4.4.2 Solution

Unpack the tarball (compressed archive), then configure, make, and install the program.

Start in the directory where you store your tarballs and source trees. This example uses JOE (Joe's Own Editor):

# cd /usr/src/downloads

# tar zxvf joe-2.9.8.tar.gz

# cd joe-2.9.8

# ls

# less README

# less INFO

# ./configure —help

# ./configure <options, if needed>

# make

# make install | tee joe-makeinstall

The last command stores the installation output in the text file joe-makeinstall.

Some programs are archived with the bunzip2 utility, rather than the more traditional gzip. This is how to unpack a .bz2 archive:

# tar jxvf joe-2.9.8.tar.bz2

To uninstall a source-built program, use:

# make uninstall

Uninstalling works only if the program author included a make uninstall option. Piping the output of make install to a text file gives you a reference if you have to remove all the files manually. Or generate a list using Recipe Recipe 4.3.

4.4.3 Discussion

The steps described in this section are the standard way of installing programs from source code. However, not all program authors follow the same procedures. Be sure to review all the program documentation first.

Studying your configure options is the most important part. Some programs, like Apache, have dozens of compile-time options. For prudent basic security, you only want to compile in support for things you really need. This is most important on servers that are exposed to untrusted networks, such as web and mail servers.

Good reasons to compile programs from source are:

  • You can configure exactly the options you need.

  • You can optimize the program for your architecture.

  • You have ultimate control over what is installed.

The bad part:

  • Upgrades and removals can be messy.

  • Dependency hell is only a short step away.

  • Compiling a large program can take hours.

Some servers should be built from sources. For example, an Apache web server really needs to be source-built to get full customization and optimization.

For a desktop system, forget it. They're too big and complex. Use the nice package-based Linux distributions for these.

4.4.4 See Also

  • info tar, make(1), bzip2(1)

    Previous Section  < Day Day Up >  Next Section