|    A detailed description of compiling and installation, with all included options, is outside the scope of this book. However, the two most popular forms of installation will be covered: source-based and packaged installs .    Source-Based Installation   The source files can be retrieved from the PostgreSQL FTP site (  ftp.postgresql.org  ) or from numerous mirror sites around the world.    Once the file is downloaded, it will probably be in a  tarred- gzipped  format. In order to compile, it first must be unpacked. Move the file to a clean directory (for example,  /usr/src/postgres  ) and issue the following commands:    >tar xzf postgresql-7.1.tar.gz    After the code is unpacked, you can delete the original  tar.gz  file if disk space is an issue; otherwise , move it to a safe location.    Next, review the  INSTALL  text file included in the created directory for installation notes. Briefly, the rest of the procedure is as follows :    -  
  Create a user account to serve as the DBA's account (  postgres  is a popular choice).You can do this using  userconf  ,  useradd  , or whatever tool your system provides for user management.      -  
  Review the installation options for your system. Here is a partial list of options supported (type   ./configure --help   for a full list):      --prefix=BASEDIR  (where  BASEDIR  is the path of choice)     --enable-locale      --enable-multibyte  (to include support for multibyte characters like Chinese and so on)     --enable-syslog  ( turn on  syslog  feature)     --enable-assert  (enable assert checking; debug feature)     -- enable-debug  (compile with debugging flags on)     --with-perl  (include Perl interface support)     --with-tcl  (include tcl interface support)     --with-odbc  (include ODBC drivers)     -  
  Configure the source code with those options selected (for example,  configure --with-odbc  ).      -  
  Type   make   (or   gmake   ) to build binaries.      -  
  If the  make  fails, examine the log files generated (usually in  ./config.log  ) for any reasons why the compile didn't work.      -  
  Type   make install   to install the binaries to the location specified (default is  /usr/local/pgsql  ).      -  
  Tell your machine where the libraries are located, either by setting the  LD_LIBRARY_PATH  environmental variable to the  <BASEDIR>/lib  path or by editing the  /etc/ld.so.conf  file to include it.      -  
  Include the  <BASEDIR>/bin  path in the user's or system's search path (that is,  /etc/profile  ).      -  
  Create the directory to hold the databases, change the ownership to the DBA, and initialize the location (assumes a user named  postgres  exists):     # mkdir /usr/local/pgsql/data  # chown postgres /usr/local/pgsql/data  # su - postgres  > /usr/local/pgsql/bin/initdb -D /usr/local/pgsql/data     -  
  Start the  postmaster  server (as the DBA account) in the background. Specify the data directory previously created, such as:     >/usr/local/pgsql/bin/postmaster -D /usr/local/pgsql/data &     -  
  As DBA, create the users you need using the  createuser  command.      -  
  Switch to the user created and create the database(s) needed (that is,  createdb  ).             Error Message Routing   The actions taken in step 11 will result in the routing of error messages to the terminal where this command was executed.To route error messages to a log file, use the  >>server.log 2>>1 &  ending. Refer to the  INSTALL  notes for more information.    |        Package-Based Installation   Essentially, package-based installation (for example, RPM or DEB) automates the preceding process. It is still a good idea, however, to read the process outlined in the preceding section so that you at least understand what things the package will be doing to your system.    Depending on the package management system installed on your machine, the commands will be different. The following assumes you have RPM-based package management tools, but the Debian package management system is very similar in concept:    -  
  Download the list of RPM files that you require (  ftp.postgresql.org/pub/binary  ).     (examples)  postgresql-server-7.0.3-2.i386.rpm   Server programs (req)  postgresql-7.0.3-2.i386.rpm   Clients & Utilities (req)  postgresql-devel-7.0.3-2.i386.rpm   Development Libraries  postgresql-odbc-7.0.3-2.i386.rpm   ODBC Libraries  postgresql-perl-7.0.3-2.i386.rpm   Perl interface  postgresql-python-7.0.3-2.i386.rpm   Python interface  postgresql-tcl-7.0.3-2.i386.rpm   TCL Interface  postgresql-tk-7.0.3-2.i386.rpm   Tk Interface  postgresql-test-7.0.3-2.i386.rpm   Regression Test Routines     -  
  Install the files.      -  
  Verify that a user for PostgreSQL was created by examining  /etc/passwd  (or the equivalent).      -  
  Switch to the DBA user account (typically  postgres  ) and create the users you need (for example,  createuser  web).         Switch to that user and create the working database (for example,  createdb  web site).    |