Jul 23, 2012

Install PostgreSQL 8.2.23 in CentOS 5.8


  1. Download source files from here
  2. Upload files to the CentOS server
  3. Prepare the necessary files
    1. #yum -y install gcc gcc-c++ autoconf libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel libidn libidn-devel openssl openssl-devel openldap openldap-devel nss_ldap openldap-clients openldap-servers
  4. #tar -zxf postgresql-8.2.23.tar.gz
  5. #cd postgresql*
  6. #./configure --prefix=/usr/local/pgsql  --without-readline
  7. #make && make install
  8. Setting PostgreSQL config process
    1. create user: #adduser postgres
    2. create password: #passwd postgres
    3. Authorized folder/files: 
      1. #mkdir /usr/local/pgsql/data
      2. #chown -R postgres /usr/local/pgsql
    4. login as postgres: su postgres
    5. initial dataset: /usr/local/pgsql/bin/initdb -D /usr/local/pgsql/data
    6. edit config
      1. #vi /usr/local/pgsql/data/postgresql.conf
      2. find listen_addresses = ‘localhost’ to listen_addresses = '*'
      3. #vi /usr/local/pgsql/data/pg_hba.conf 
      4. IPv4 local connections:
      5. host    all         all         127.0.0.1/32          trust 
        host    all         all         192.168.1.0/24      password
  9. Update user env. parameters
    1. #vim /var/lib/pgsql/.bash_profile
    2. [ -f /etc/profile ] && source /etc/profile
    3. PGDATA=/usr/local/pgsql/data
      export PATH=/usr/local/pgsql/bin:$PATH
      export PGDATA
  10. Start the service
    1. start SQL service: 
      1. #su - postgres
      2. #/usr/local/pgsql/bin/pg_ctl start -i -D /usr/local/pgsql/data
    2. check SQL status: ps aux | grep postgres
    3. update postgres user
      1. #su - postgres
      2. #psql postgres
      3. #alter user postgres ENCRYPTED PASSWORD 'postgres';

Note that: you have a short cut to figure out:
command line: yum -y install postgresql postgresql-libs postgresql-server

No comments: