Install Postgresql 9.5 on CentOS 6

# Get correct RPM from http://yum.postgresql.org/repopackages.php

cd /home/
mkdir installers
cd installers

wget https://download.postgresql.org/pub/repos/yum/9.5/redhat/rhel-6-x86_64/pgdg-centos95-9.5-2.noarch.rpm

rpm -i pgdg-centos95-9.5-2.noarch.rpm

# Install EPEL repos as:
# http://www.tecmint.com/how-to-enable-epel-repository-for-rhel-centos-6-5/

wget http://download.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
rpm -ivh epel-release-6-8.noarch.rpm

yum install postgresql95 postgresql95-contrib postgresql95-server postgresql95-devel postgis2_95 postgis2_95-devel

service postgresql-9.5 initdb 'en_US.UTF8'
chkconfig postgresql-9.5 on

# Darle password al usuario postgres linux/db:

passwd postgres
service postgresql-9.5 restart
su postgres
psql -c "ALTER USER postgres WITH PASSWORD 'xxxxxx'" -d template1
exit

nano /var/lib/pgsql/9.5/data/postgresql.conf

# En la línea #listen_addresses quitamos el carácter # (habilitar) y reemplazamos la palabra localhost por el carácter *
# Configure la cantidad máxima de conexiones (max_connection) a 200.
# Guarde y cierre el archivo con Crtl+o, Enter, y Ctrl+x

nano /var/lib/pgsql/9.5/data/pg_hba.conf

# Definir en la seccion #IPv4 local connections :
host    all             all             127.0.0.1/32            password
host    all             all             0.0.0.0/0               password

service postgresql-9.5 restart

# firewall rule for 5432 port
nano /etc/sysconfig/iptables
# Then add this entry before -A INPUT -j REJECT line
-A INPUT -p tcp -m state --state NEW -m tcp --dport 5432 -j ACCEPT
# restart firewall
service iptables restart
# verify open ports:
netstat -tulpn
# Make sure iptables is allowing port 80 / 110 / 143 connections:
iptables -L -n

# Disable enforce
nano etc/selinux/config
# change the SELINUX line to 
SELINUX=disabled

Advertisements