PostgreSQL, often simply “Postgres”, is an object-relational database management system (ORDBMS) with an emphasis on extensibility and standards-compliance. With more than 15 years of development history, it is quickly becoming the de facto database for enterprise level open source solutions.
In this article we will discuss about how to install PostgreSQL from source on Slackware64. Our objective is to make PostgreSQL installed and running on our machine.
The PostgreSQL we will use is the PostgreSQL 9.3.5
Extract the source code and go to that directory.
tar -jxf postgresql-9.3.5.tar.bz2 cd postgresql-9.3.5
Installation is using usual procedure in unix family: configure, make, install. Note that we are using /usr/local as our installation directory (where the PostgreSQL will reside). You can change it to anything you like. Root privileges is not necessary for compilation process, however it is need to install it to our directory /usr/local. If you choose to install it to non-root privileged area, you can drop the “su -c” thing.
./configure --prefix=/usr/local make -j4 su -c "make install"
At this point, PostgreSQL is installed, but can’t yet be operational. Let’s do configuration.
PostgreSQL User Account
We need a “postgres” user and group prior to building PostgreSQL. Do this using root privilege.
groupadd postgres useradd -d /var/lib/pgsql postgres passwd postgres
PostgreSQL Data Directory
Now we need to create PostgreSQL data directory if not exist. The data directory should be owned by postgres user.
mkdir /var/lib/pgsql/data chown -Rf postgres:postgres /var/lib/pgsql
Initialize the directory. Before we can start creating any PostgreSQL database, the empty directory created above should be initialized.
su - postgres /usr/bin/initdb -D /var/lib/pgsql/data
Next, validate the PostgreSQL data directory. Make sure all Postgres DB configuration file are created under the data directory.
Start PostgreSQL database. There are two ways to do it: using postmaster to do it, or invoking script.
/usr/bin/postmaster -D /var/lib/pgsql/data
To make PostgreSQL run as service, we should make the init script executable.
chmod +x /etc/rc.d/rc.postgres
Let’s try our fresh build PostgreSQL.
psql -U postgres
where postgres is user account we have created before.database, linux, postgresql, slackware