ubuntu14.04源代码安装postgresql 9.1

时间:2021-08-08 22:24:32

项目须要使用gisgraphy,怎奈gisgraphy3.0仅仅支持postgis1.5.因此仅仅能安装老版本号的posgresql和postgis了。从postgis的support matrix图能够看到postgis不同版本号支持的postgresql,

ubuntu14.04源代码安装postgresql 9.1

watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvbG9uZ3NoZW5nZ3Vvamk=/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center" alt="">

我安装的是postgresql9.1.14.

1.下载postgresql9.1版本号的源代码,http://www.postgresql.org/docs/9.1/static/install-short.html

2.解压缩,然后切换到解压缩后的目录下

3.执行命令:./configure

此处可能会出现例如以下错误:

configure: error: readline library not found

我的解决的方法是:安装libreadline6-dev

sudo apt-get install libreadline6-dev

问题得到解决

4.执行命令:

make

make install

5.验证安装是否成功,输入命令:

ls -l usr/local/pgsql/

假设 bin include lib 和 share都出现,说明成功安装。

ubuntu14.04源代码安装postgresql 9.1

6.设置用户账户

adduser postgres

passwd postgres

输入password

7.创建postgresql 数据文件夹:

mkdir /usr/local/pgsql/data/

chown postgres:postgres /usr/local/pgsql/data

ls -ld /usr/local/pgsql/data

会出现例如以下界面

ubuntu14.04源代码安装postgresql 9.1

watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvbG9uZ3NoZW5nZ3Vvamk=/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast" alt="">

8.初始化postgresql数据文件夹

su postgres

/usr/local/pgsql/bin/initdb -D /usr/local/pgsql/data/

9.验证postgresql数据文件夹

ls -l /usr/local/pgsql/data

出现例如以下界面:

ubuntu14.04源代码安装postgresql 9.1

watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvbG9uZ3NoZW5nZ3Vvamk=/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast" alt="">

10.启动pgsql数据库

/usr/local/pgsql/bin/postmaster -D /usr/local/pgsql/data >logfile 2>&1 &

cat logfile

出现例如以下界面:

ubuntu14.04源代码安装postgresql 9.1

watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvbG9uZ3NoZW5nZ3Vvamk=/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast" alt="">

11.创建postgresql 数据库。并验证安装是否成功

/usr/local/pgsql/bin/createdb test

/usr/local/pgsql/bin/psql test

要是出现例如以下界面,则恭喜你,成功安装

ubuntu14.04源代码安装postgresql 9.1