Compiling Software from Source
Directory Structure
When we compile a program from source, we install it in its own directory under
/usr/local, e.g.
/usr/local/bind for BIND. This makes it easier to uninstall or upgrade than if the program's files were scattered all over the filesystem.
Config files should go in the installation directory, e.g.
/usr/local/apache/etc rather than in
/etc/apache. When necessary, we make symlinks to them in
/etc.
Scripts that run
./configure, with appropriate options for each program, are kept in
/usr/local/configure-wrappers. Each script is called
configure-programname, e.g.
configure-apache.
Tarballs containing source code for programs we've compiled and installed are kept in
/usr/local/src.
Environment Variables in /etc/profile
- LOCAL_PATH
- The
bin directories of programs installed under /usr/local.
- LOCAL_MANPATH
- The
man directories of programs installed under /usr/local.
- PERL5LIB
- Any Perl 5 libraries that are part of programs installed under
/usr/local.
Daemons
When we compile and install a daemon from source, we modify the
PATH in its init script (in
/etc/init.d) to include the daemon's own
sbin directory, e.g.
/usr/local/bind/sbin. If the init script doesn't use a
PATH, we modify the init script to use the path to the installed executable.
Upgrades
When you compile and install a program from source, subscribe to the mailing list that the developers use to send out announcements of new releases. In general, it's a good idea to run the most recent stable version; it's likely to contain fixes for bugs in previous versions. However, if a new version introduces major changes (typically indicated by a higher major version number), you may want to be cautious. For example, if you're running Foobar version 1.5.28, and Foobar 2.0.0 -- a complete rewrite -- is released, you might want to wait a while, e.g. until version 2.0.5.
to top