CentOS 6.6下编译安装PostgreSQL9.4.1及phpPgAdmin配置
安装前准备
# 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
关闭数据库实例
开启远程连接
$ 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
-A INPUT -p tcp -m tcp --dport 80 -j ACCEPT
配置phppgadmin
到http://phppgadmin.sourceforge.net/doku.php下载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
保存后,访问该路径,输入用户名和密码即可访问。
------------------------------------华丽丽的分割线------------------------------------
------------------------------------华丽丽的分割线------------------------------------
PostgreSQL 的详细介绍:请点这里
PostgreSQL 的下载地址:请点这里