Setting up PostgreSQL on Red Hat Enterprise Linux

As a regular user, or as root if you leave off the sudo bits:

sudo yum -y install postgresql postgresql-server php-pgsql
sudo /sbin/chkconfig postgresql on
sudo /sbin/service postgresql start

This is setting up the postgres user. Enter a password you'll remember when prompted.

sudo passwd postgres

After this command, enter that password again. Now you'll be logged in as the new postgres user.

su - postgres
create user gpsdata;
create database gpsdata owner gpsdata;

The following makes it possible to access the database from another computer.

vi /var/lib/pgsql/data/postgresql.conf 
add the line:

vi /var/lib/pgsql/data/pg_hba.conf
add the line:
host    all         all        trust

sudo /etc/init.d/postgresql restart

Now you've just got to open port 5432 on your firewall.

sudo vi /etc/sysconfig/iptables
add the line:
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 5432 -j ACCEPT

sudo /etc/init.d/iptables restart

1 thought on “Setting up PostgreSQL on Red Hat Enterprise Linux

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.