Blog.GC

在Scientific Linux上安装PostgreSQL,以及rails组件

| Comments

Scientific Linux系统仓库中的PostgreSQL是9.2版的,而官方最新稳定版已经到了9.4。关键是新版本支持jsonb,所以选择从官网仓库安装。

首先添加仓库,其他系统的仓库可以从这个地址找到http://yum.postgresql.org/repopackages.php

1
yum install http://yum.postgresql.org/9.4/redhat/rhel-7-x86_64/pgdg-sl94-9.4-1.noarch.rpm

然后安装PostgreSQL

1
yum install postgresql94-server postgresql94-contrib

也可以选择安装图形化界面

1
yum install pgadmin3_94

安装完成后,会自动添加postgres这个用户,通过切换到这个账户来管理PostgreSQL。

如果要在rails中使用PostgreSQL的话,首先要安装C++API库,同时要链接PostgreSQL的各个二进制文件

1
2
yum install libpqxx-devel
ln -s /usr/pgsql-9.4/bin/pg_* /usr/local/bin/

随后安装pg库

1
2
export CONFIGURE_ARGS="with-pg-include=/usr/pgsql-9.4/include/"
gem install pg

Comments

comments powered by Disqus