How to Install PostgreSQL Using the Source Code
Edited by Husam Tomeh, Rob S, Eric, Tipper and 7 others
One Methods:Complete List of Commands
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!
EditSteps
-
1Obtain the source code from PostgreSQL website [1].Ad
-
2Unpack 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).
-
3Change the current directory to the newly created one (postgresql-8.3.3)
-
4Configure 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]
-
Default Configuration: run the command
-
5Start the build process by executing the command line
gmake
in 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. -
6Install 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 -
7Create a super-user account for PostgreSQL by executing the following command in the bash console:
adduser postgres -
8Create 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 -
9Create PostgreSQL cluster by executing:
su - postgres
/usr/local/pgsql/bin/initdb -D /p01/pgsql/data -
10Start up the PostgreSQL server (postmaster process) by executing:
/usr/local/pgsql/bin/postmaster -D /p01/pgsql/data >logfile 2>&1 & -
11Create a PostgreSQL database in the cluster by executing:
/usr/local/pgsql/bin/createdb test -
12Log-in to the database using the psql command:
/usr/local/pgsql/bin/psql test
EditComplete 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
EditSources and Citations
- Postgresql.com
- Installation instructions at PostgreSql website
Article Info
Thanks to all authors for creating a page that has been read 11,359 times.