Installing Software from Source¶
Many software packages can be installed to your home directory by building the software from source. To build software from source and install it to your home directory:
On CentOS 5 servers (servers less than web300), some software may be difficult or impossible to install because system libraries such as glibc are too old. In such cases, consider migrating to a CentOS 7 server.
Open an SSH session to your account.
Create a temporary directory. Some software installations may require a user-writable temporary directory. To create the directory, enter mkdir -p $HOME/tmp and press Enter.
Set the TEMPDIR environment variable to point to the temporary directory. Enter export TEMPDIR=$HOME/tmp and press Enter.
Download the source to your home directory.
Typically, source is distributed in a zip or tar archive that contains the software package’s source files, configuration scripts, and documentation. To download this file directly to your home directory with wget: enter wget url, where url is the URL for the source archive, and press Enter. The source archive is created in the current directory.
Unpack the source archive.
To unpack a zip file, enter unzip file, where file is the path to the source archive, and press Enter.
To unpack a tar file, enter tar -xf file, where file is the path to the source archive, and press Enter.
The new directory containing the source files is created in the current directory.
Switch to the source directory. Enter cd source, where source is the path to the directory containing the source files, and press Enter.
Read the software’s documentation. Some software packages may require additional installation steps or configuration switches. Review the package’s README and INSTALL files, if available.
Run the package’s configure script. The script prepares the build environment for the package; typically, switches on this script determine where to install the software and where to find relevant dependencies. The most frequently used switches include:
This switch determines where the software will be installed, including shared libraries and executables. You will use --prefix=$HOME to choose your home directory as the installation destination.
If applicable, this switch notifies the software where to find the cURL executable. You can use --with-curl=/usr to specify the system’s cURL executable. Alternatively, you can use --with-curl=$HOME to specify a different version of cURL that you may have installed in your home directory.
If applicable, this switch notifies the software where to find the wget executable. You can use --with-wget=/usr to specify the system’s wget executable. Alternatively, you can use --with-wget=$HOME to specify a different version of wget that you may have installed in your home directory.
To see all of the available options, enter ./configure --help and press Enter.
To run the configure script, enter ./configure --prefix=$HOME switches, where switches are any additional, space-separated switches the software requires, and press Enter.
Build the binaries from the source: enter make and press Enter. The build runs.
This step may take a few minutes to complete.
Install the software. Enter make install. The completed software is copied to appropriate locations, such as executables in ~/bin and libraries in ~/lib.
Depending on Non-Standard Libraries and Headers Causes Errors¶
Some software packages may depend on non-standard libraries or headers. If these dependencies are not available, then you may encounter an error such as cannot open shared object file: No such file or directory or various other errors while running the software’s configure script. These problems can be resolved with the help of some environment variables: CPPFLAGS, LDFLAGS, and LD_LIBRARY_PATH.
Don’t forget to set appropriate configure switches, too. See the Installing Software from Source step-by-step instructions for details.
CPPFLAGS is used to support non-standard headers. For installations which require additional headers, you may add your home directory’s include directory to CPPFLAGS. Before running configure or make, enter export CPPFLAGS="-I$HOME/include $CPPFLAGS" and press Enter.
LDFLAGS is used to support non-standard libraries. For installations and executions which require additional libraries, you may add your home directory’s lib directory to LDFLAGS. Before running configure or make, enter export LDFLAGS="-L$HOME/lib $LDFLAGS" and press Enter.
Like LDFLAGS, LD_LIBRARY_PATH is used to support non-standard libraries. For installations and executions which require additional libraries, you may add your home directory’s lib directory to LD_LIBRARY_PATH. Before running configure, make, or the software after it is installed, enter export LD_LIBRARY_PATH=$HOME/lib:$LD_LIBRARY_PATH and press Enter.
To simplify future usage, permanently amend your LD_LIBRARY_PATH by adding the export statement to your $HOME/.bash_profile file. To permanently add $HOME/lib to your LD_LIBRARY_PATH, enter echo "export LD_LIBRARY_PATH=$HOME/lib:$LD_LIBRARY_PATH" >> $HOME/.bash_profile and press Enter.
Finally, for commands which run outside of your shell process, like an Apache server for a Django application or a cron script, you may need to make additions to LD_LIBRARY_PATH elsewhere.
For example, a Django application’s start script already defines the LD_LIBRARY_PATH environment variable. To add $HOME/lib to the application’s LD_LIBRARY_PATH, edit $HOME/webapps/app/apache2/bin/start from this:
LD_LIBRARY_PATH=/home/<username>/webapps/<app>/apache2/lib /home/<username>/webapps/<app>/apache2/bin/httpd.worker -f /home/<username>/webapps/<app>/apache2/conf/httpd.conf -k start
LD_LIBRARY_PATH=/home/<username>/lib:/home/<username>/webapps/<app>/apache2/lib /home/<username>/webapps/<app>/apache2/bin/httpd.worker -f /home/<username>/webapps/<app>/apache2/conf/httpd.conf -k start
where <username> is your username and <app> is the name of the application.
Likewise, to change a cron job’s LD_LIBRARY_PATH, prepend LD_LIBRARY_PATH=$HOME/lib to your cron job’s command. For example, edit this cron task:
1 0 * * * command
1 0 * * * LD_LIBRARY_PATH=/home/username/lib command
where username is your username and command is the task to be executed.