Installing PostgreSQL from Source

Some Linux distributions, such as Debian Etch (4.0), do not offer PostgreSQL version 8.2 as an installable package. Before you continue, examine the software dependencies listed in ??? to ensure that your Linux distribution supports the required version of PostgreSQL.

Note

Some Linux distributions, such as Debian Etch (4.0), do not offer PostgreSQL version 8.2 as an installable package. Before you continue, examine the software dependencies listed in ??? to ensure that your Linux distribution supports the required version of PostgreSQL.

  1. Install the application stow on your system if it is not already installed. Issue the following command as the root user:

    apt-get install stow
    
  2. Download, compile, and install the latest release for PostgreSQL 8.2 (which was version 8.2.12 at the time of this writing). As the root user, follow these steps:

    
    wget http://wwwmaster.postgresql.org/redir/198/h/source/v8.2.17/postgresql-8.2.17.tar.bz2
    tar xzf postgresql-8.2.17.tar.gz
    cd postgresql-8.2.17
    ./configure --with-perl --enable-integer-datetimes --with-openssl --prefix=/usr/local/stow/pgsql
    make
    make install
    cd contrib
    make
    make install
    cd xml2
    make
    make install
    cd /usr/local/stow
    stow pgsql
    
    
  3. Create the new user postgres to run the PostgreSQL processes. As the root user, execute this command:

    adduser postgres
  4. Initialize the database directory and start up PostgreSQL. As the root user, follow these steps:

    
    mkdir -p /usr/local/pgsql/data
    chown postgres /usr/local/pgsql/data
    su - postgres
    initdb -D /usr/local/pgsql/data -E UNICODE --locale=C
    pg_ctl -D /usr/local/pgsql/data -l /home/postgres/logfile start
    
    

    Note

    If an error occurs during the final step above, review the path of the home directory for the postgres user. It may be /var/lib/postresql instead of /home/postres.