# yum install readline-devel zlib-devel
下载源码并解压、编译安装
# wget https://ftp.postgresql.org/pub/source/v9.4.1/postgresql-9.4.1.tar.bz2
# tar -xjvf postgresql-9.4.1.tar.bz2
# cd postgresql-9.4.1
# ./configure
# make
# make install
--------------------------------------
添加用户 (因为下面创建database cluster时不能用root帐号)
# useradd postgres
# passwd postgres
建立好database cluster目标文件夹
# mkdir -p /mnt/data/pgsql
# chown -R postgres /mnt/data/pgsql
环境变量设置
# su - postgres
$ vi .bash_profile
# postgres
PGDATA=/mnt/data/pgsql
PATH=/usr/local/pgsql/bin:$PATH
export PGDATA PATH
让环境变量生效
$ source .bash_profile
--------------------------------------
创建database cluster
$ pg_ctl initdb
WARNING: enabling "trust" authentication for local connections
You can change this by editing pg_hba.conf or using the option -A, or
--auth-local and --auth-host, the next time you run initdb.
Success. You can now start the database server using:
/usr/local/pgsql/bin/postgres -D /mnt/data/pgsql
or
/usr/local/pgsql/bin/pg_ctl -D /mnt/data/pgsql -l logfile start
启动数据库实例
设置好PGDATA环境变量后,可以不带-D选项
$ pg_ctl start -l /mnt/data/pgsql/pgsql.log
关闭数据库实例
$ pg_ctl stop
开启远程连接
$ cd /mnt/data/pgsql/
$ vi pg_hba.conf
# IPv4 local connections:
host all all 0.0.0.0/0 trust
$ vi postgresql.conf
listen_addresses = '*'
配置防火墙
$ su - root
# vi /etc/sysconfig/iptables
-A INPUT -p tcp -m tcp --dport 80 -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 5432 -j ACCEPT
# service iptables restart
配置phppgadmin
到下载5.1版本
解压到站点目录下,并重命名为pgadmin
# cd pgadmin
# vim conf/config.inc.php
$conf['servers'][0]['host'] = '127.0.0.1';
$conf['servers'][0]['port'] = 5432;
$conf['servers'][0]['pg_dump_path'] = '/usr/local/pgsql/bin/pg_dump';
$conf['servers'][0]['pg_dumpall_path'] = '/usr/local/pgsql/bin/pg_dumpall';
$conf['extra_login_security'] = false
保存后,访问该路径,输入用户名和密码即可访问。
------------------------------------华丽丽的分割线------------------------------------
如何在CentOS 7/6.5/6.4 下安装PostgreSQL 9.3 与 phpPgAdmin
CentOS 6.3环境下yum安装PostgreSQL 9.3
Ubuntu下LAPP(Linux+Apache+PostgreSQL+PHP)环境的配置与安装
PostgreSQL配置Streaming Replication集群
------------------------------------华丽丽的分割线------------------------------------