After you have configured and compiled the PostgreSQL source code, it is time to install the compiled libraries,
binaries, and data files into a more appropriate home on the system. If you are upgrading from a previous version of
PostgreSQL, be sure to back up your database before beginning this step. Information on performing PostgreSQL database
backups can be found in Chapter 9.
Installation of the compiled files is accomplished with the commands demonstrated in Example 2-10. When executed in the manner shown in Example 2-10, the
su
command temporarily logs you in as the
root
user to execute the required
commands. You must have the
root
password to execute both of the commands shown in Example 2-10.
Note: If you specified a non-default installation directory in Step 3, use the directory you specified instead of
/usr/local/pgsql
.
Example 2-10. The gmake install command
$
su -c "gmake install"
Password:
gmake -C doc install
gmake[1]: Entering directory /usr/local/src/postgresql-7.1.3/doc'
mkdir /usr/local/pgsql
mkdir /usr/local/pgsql/man
mkdir /usr/local/pgsql/doc
mkdir /usr/local/pgsql/doc/html
[...]
$
su -c "chown -R postgres.postgres /usr/local/pgsql"
Password:
The
su -c "gmake install"
command will install the freshly compiled source either into the
directory structure you chose in Step 3 with the
--prefix
configuration option, or, if this was left
unspecified, into the default directory of
/usr/local/pgsql
. The use of the
su -c "chown -R postgres.postgres /usr/local/pgsql"
command will ensure that the
postgres
user owns the PostgreSQL installation directories. Using the
su -c
command lets you save a step by only logging you in as the
root
user for the duration of the command’s execution.
If you chose to configure the PostgreSQL source with the Perl or Python interface, but did not have root access, you
can still install the interfaces manually. Use the commands demonstrated in Example 2-11 to install the Perl and Python modules manually.
Example 2-11. Installing Perl and Python modules manually
$
su -c "gmake -C src/interfaces/perl5 install"
Password:
Password:
gmake: Entering directory /usr/local/src/postgresql-7.1.3/src/interfaces/perl5'
perl Makefile.PL
Checking if your kit is complete...
Looks good
Writing Makefile for Pg
gmake -f Makefile clean
[...]
$
su -c "gmake -C src/interfaces/python install"
Password:
gmake: Entering directory /usr/local/src/postgresql-7.1.3/src/interfaces/python'
sed -e 's,@libpq_srcdir@,../../../src/interfaces/libpq,g' \
-e 's,@libpq_builddir@,../../../src/interfaces/libpq,g' \
-e 's%@EXTRA_LIBS@% -lz -lcrypt -lresolv -lnsl -ldl -lm -lbsd -lreadline -ltermcap %g' \
-e 's%@INCLUDES@%-I../../../src/include%g' \
[...]
You may also want to install the header files for PostgreSQL. This is important, because the default installation
will only install the header files for client application development. If you are going to be using some of PostgreSQL's
advanced functionality, such as user-defined functions or developing applications in C that use the
libpq
library, you will need this functionality. To install the required header files, perform the
commands demonstrated in Example 2-12.
Example 2-12. Installing all headers
$
su -c "gmake install-all-headers"
Password:
gmake -C src install-all-headers
gmake[1]: Entering directory /usr/local/src/postgresql-7.1.3/src'
gmake -C include install-all-headers
[...]