Activities

November 2009
M T W T F S S
« Oct   Dec »
 1
2345678
9101112131415
16171819202122
23242526272829
30  

How do I install postgresql manually

hello,

As of most operating system comes along with their own package repositories with the stable version of each packages. So that we can easily install it either using apt or yum.

Standard installation of PostgreSQL.
1.

# apt-get install postgresql*

(Debain/Ubuntu)
2.

# yum install postgresql*

( RHEL/Fedora/Centos)

Here I am listing manual installation steps of latest PostgreSQL from the Postgresql website.

1. Download the latest source code from, postgreSQL site (http://www.postgresql.org/ftp/source/)

#wget http://wwwmaster.postgresql.org/download/mirrors-ftp/source/v8.4.1/postgresql-8.4.1.tar.gz

2. #tar -zxvf postgresql-8.4.1.tar.gz
# ./configure
#gmake
#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/postmaster -D /usr/local/pgsql/data >logfile 2>&1 &
#/usr/local/pgsql/bin/createdb test
#/usr/local/pgsql/bin/psql test
#createuser root
#exit — logout from postgres user
#psql -l Now you many now administrate the postgres from the root console

Installing as service ( service files can be found from source code directory)
1. go to /installation/startup-scripts
2. copy linux file to /etc/init.d/postgresql
3.

#chmod 755 /etc/init.d/postgresql && cd /etc/init.d/

4,

#chkconfig --add postgresql

5,

#chkconfig postgresql on

6.

#service postgresql start

Set /usr/local/pgsql/bin in system PATH

7.

#PATH=$PATH:/usr/local/pgsql/bin;export PATH

We can’t execute or adminsitrate any command initialy even we have root access to the server. We need to add the the user ‘root’ as a super user in posgressql. For doing this,
#su – postgres
#create user root : Will ask for the role given, Just press yes to execute. Now you can administrate the posgresql from system root console.

8. Creating new database using #createdb
9. Create user using #createuser
10. Listing Databases #psql -l

#####################################

How to create access privileges to other hosts in the network.

Posgresql initially will not permitt any host to access the server remotely.For enabling remote access, we need to modify the certain settings on config. file. A. editing on /etc/postgressql.conf. B. pg_hba.conf

1. edit postgresql.conf which should be look like this
# – Connection Settings –

listen_addresses ='*'

# what IP address(es) to listen on;
# comma-separated list of addresses;
# defaults to ‘localhost’, ‘*’ = all
port = 5432

2. edit pg_hba.conf should look like this

# TYPE DATABASE USER CIDR-ADDRESS METHOD

# “local” is for Unix domain socket connections only
local all all trust
# IPv4 local connections:
host all all 127.0.0.1/32 trust
host all all 192.168.0.1 255.255.255.0 trust

# I assume you have 162.0.0.0/24 network

Note that The last line which gives access permission to all of the given network ranges(192.168.0.x)

<code> # service postgresql restart

How to test whether it is working or not ?

Just login to the other desktop on the same network and telnet to the ostgresql port.

# telnet  192.168.20.254 5432

if you got a window open means that it’s listening.

Installing PhpPGadmin for posgres

1. Locate and unzip phpPgAdmin-4.0.1.tar.gz file to Apache web directory

2. Edit the file phpPgAdmin-4.0.1/conf/config.inc.php. find the entry and find the entry on the file and make the true to false
extra_login_security = true to false

which should look like this

 $conf['$conf['extra_login_security'] = false;'] = false;

-Njoy

4 comments to How do I install postgresql manually

  • Bob McConnell

    The wget line above does not return the archive, but only a web page requesting me to select a mirror. You need to add more specific instructions how to get through the mirror quagmire and actually download the file.

  • admin

    Hello,

    Normally it’s common download page which you ask to select your nearest download location.

    This will work for now anyway
    #wget http://wwwmaster.postgresql.org/redir/226/f/source/v8.4.2/postgresql-8.4.2.tar.gz

    Regards,
    Liju

  • vadimv82

    Thank you. Your manual helped me so much.

    Because i had such a problem that i had 3 instances of postgres running. 8.1, 8.3 and 8.4.
    And i also had to install 9.1. While installing using RPMs and YUM i got package conflicts.

    And you saved my day. All worked nice and easy.

    I would also add that if you have several postgreses running, don’t forget to add port with -p 5321 for example.
    And also how to change postgres password.

    psql -d template1
    template1=# alter user postgres with password postgres
    template1-# \c postgres
    postgres-# \password postgres

    • Thanks Vadim for the visit and suggestion given.

      This is two year aged post and I’d not been used postgres anymore after that. However your attitude to share the logic is simply awesome and would help definitely to other people like us.

      See you..
      Liju

Leave a Reply

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>