vine/Postgresql

PostgreSQLの設定メモ

/var/lib/pgsql/data/postgresql.confの設定

  • ネットワークからアクセスできるようにする
tcpip_socket = true
  • Port設定
port = 5432

/var/lib/pgsql/data/pg_hba.confの設定

  • アクセス制限
host    all         all         127.0.0.1         255.255.255.255   trust

操作メモ

初期設定

  • ユーザの作成
$ createuser hoge
  • データベースの作成
$ createdb SampleDB

Apacheからアクセスできるようにする.

  • Apachユーザの追加
$ createuser apache
  • Apacheユーザに権限を与える
$ psql -n SampleDB
SampleDB=> grant all on SampleTable to apache;

覚書

  • データベースの一覧表示
$ psql -l
  • テーブルの一覧表示
=> \dt

RubyのDBインターフェースをインストール

Ruby/PostgreSQLのインストール

参考ページ

$ tar zxvf ruby-postgres-0.7.1.tar.gz
$ cd ruby-postgres-0.7.1
$ ruby  extconf.rb  --with-pgsql-include-dir=/usr/include/pgsql/ --with-pgsql-lib-dir=/usr/lib/pgsql/
$ make
$ su
# make install

Ruby/DBIのインストール

参考ページ

$ tar zxvf ruby-dbi-all-0.0.21.tar.gz
$ cd ruby-dbi-all
 $ ruby setup.rb config --with=dbi,dbd_pg,dbd_mysql
 $ ruby setup.rb setup
 $ su
 # ruby setup.rb install

コメントする

メールアドレスが公開されることはありません。 が付いている欄は必須項目です