6
readers helped!

This helped me

How to Install PostgreSQL Using the Source Code

Ever wanted to install the PostgreSql server with some custom options? Need to install the PostgreSQL server from source code instead of pre-configured packages? This article guides you through a short installation procedure to get the PostgreSql server up and running!

Steps

  1. How.com.vn English: Step 1 Obtain the source...
    Obtain the source code from PostgreSQL website [1].
  2. How.com.vn English: Step 2 Unpack the source code package.
    Use the following bash/console command:

    gunzip postgresql-8.3.3.tar.gz
    tar xf postgresql-8.3.3.tar
    • postgresql-8.3.3 is the name of the current version. Future versions might differ in the 8.3.3 part.
    • A directory named postgresql-8.3.3 will be created under the current directory (the one you executed the above script from).
      How.com.vn English: Step 2 Unpack the source code package.
    Advertisement
  3. How.com.vn English: Step 3 Change the current directory to the newly created one (postgresql-8.3.3)
  4. How.com.vn English: Step 4 Configure the source tree for your system and choose the installation options you want:
    • Default Configuration: run the command
      ./configure
      on your bash/console
    • Custom Configuration (this is for advanced users only): you can set a lot of custom configuration options using command line options listed in the PostgreSQL documentation [2]
  5. How.com.vn English: Step 5 Start the build process by executing the command linegmakein your console/bash.
    This might take a few minutes depending on your hardware. The last line displayed should be:
    All of PostgreSQL is successfully made. Ready to install.
  6. How.com.vn English: Step 6 Install PostgreSql files by executing the bash/console command:

    gmake install
    which will install the files to /usr/local/pgsql unless you used the --prefix=PREFIX command line option, in which case the files will be installed to the path specified by PREFIX
  7. How.com.vn English: Step 7 Create a super-user account for PostgreSQL by executing the following command in the bash console:

    adduser postgres
  8. How.com.vn English: Step 8 Create a directory to hold PostgreSQL data tree by executing the following commands in the bash console:

    mkdir /p01/pgsql/data
    chown postgres /p01/pgsql/data
  9. How.com.vn English: Step 9 Create PostgreSQL cluster by executing:

    su - postgres
    /usr/local/pgsql/bin/initdb -D /p01/pgsql/data
  10. How.com.vn English: Step 10 Start up the PostgreSQL server (postmaster process) by executing:

    /usr/local/pgsql/bin/postmaster -D /p01/pgsql/data >logfile 2>&1 &
  11. How.com.vn English: Step 11 Create a PostgreSQL database in the cluster by executing:

    /usr/local/pgsql/bin/createdb test
  12. How.com.vn English: Step 12 Log-in to the database using the psql command:

    /usr/local/pgsql/bin/psql test
    Advertisement
Method 1
Method 1 of 1:

Complete List of Commands

This is the full list of commands to be executed that are described in this article to install the server. This can be saved into a script to be executed later.

./configure
gmake
su
gmake install
adduser postgres
mkdir /usr/local/pgsql/data
chown postgres /usr/local/pgsql/data
su - postgres
/usr/local/pgsql/bin/initdb -D /usr/local/pgsql/data
/usr/local/pgsql/bin/postgres -D /usr/local/pgsql/data >logfile 2>&1 &
/usr/local/pgsql/bin/createdb test
/usr/local/pgsql/bin/psql test


Expert Q&A

Ask a Question
200 characters left
Include your email address to get a message when this question is answered.
Submit

      Advertisement

      References

      About this article

      Tested by:
      How.com.vn Technology Team
      How.com.vn is a “wiki,” similar to Wikipedia, which means that many of our articles are co-written by multiple authors. To create this article, 11 people, some anonymous, worked to edit and improve it over time. This article has been viewed 44,693 times.
      How helpful is this?
      Co-authors: 11
      Updated: June 3, 2021
      Views: 44,693
      Thanks to all authors for creating a page that has been read 44,693 times.

      Is this article up to date?

      ⚠️ Disclaimer:

      Content from Wiki How English language website. Text is available under the Creative Commons Attribution-Share Alike License; additional terms may apply.
      Wiki How does not encourage the violation of any laws, and cannot be responsible for any violations of such laws, should you link to this domain, or use, reproduce, or republish the information contained herein.

      Notices:
      • - A few of these subjects are frequently censored by educational, governmental, corporate, parental and other filtering schemes.
      • - Some articles may contain names, images, artworks or descriptions of events that some cultures restrict access to
      • - Please note: Wiki How does not give you opinion about the law, or advice about medical. If you need specific advice (for example, medical, legal, financial or risk management), please seek a professional who is licensed or knowledgeable in that area.
      • - Readers should not judge the importance of topics based on their coverage on Wiki How, nor think a topic is important just because it is the subject of a Wiki article.

      Advertisement