LoginSignup
1
0

More than 5 years have passed since last update.

Ubuntu 16.04 に Rails & PostgreSQLを導入

Last updated at Posted at 2018-11-08

Railsの導入

こちらのサイトが参考になります。
http://exrecord.net/how-to-construct-ruby-on-rails-environment-in-ubuntu

PostgreSQLの導入

以下を参考にしてインストールします。

まず、/etc/apt/sources.list.d/pgdg.listを作成し、以下を追記します。

/etc/apt/sources.list.d/pgdg.list
deb http://apt.postgresql.org/pub/repos/apt/ xenial-pgdg main

次にレポジトリを追加し、インストールします。

# レポジトリを追加
$ wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
sudo apt-get update

# インストール
$ sudo apt-get install postgresql-client-10 postgresql-client-common postgresql-common postgresql-server-dev-10 postgresql-10 pgdg-keyring

# インストールを確認
$ dpkg -l | grep postgres
ii  pgdg-keyring                               2018.1                                       all          keyring for apt.postgresql.org
ii  postgresql-10                              10.5-2.pgdg16.04+1                           amd64        object-relational SQL database, version 10 server
ii  postgresql-client-10                       10.5-2.pgdg16.04+1                           amd64        front-end programs for PostgreSQL 10
ii  postgresql-client-common                   195.pgdg16.04+1                              all          manager for multiple PostgreSQL client versions
ii  postgresql-common                          195.pgdg16.04+1                              all          PostgreSQL database-cluster manager
ii  postgresql-server-dev-10                   10.5-2.pgdg16.04+1                           amd64        development files for PostgreSQL 10 server-side programming

さらに、パスワードなしでログイン出来るように設定します。まず、pg_hba.confを開いてください。

$ sudo vi /etc/postgresql/10/main/pg_hba.conf

そして、最下部にある METHOD を以下のように全て trust に書き換えてください。

/etc/postgresql/10/main/pg_hba.conf
local   all             postgres                                trust

# TYPE  DATABASE        USER            ADDRESS                 METHOD

# "local" is for Unix domain socket connections only
local   all             all                                     trust
# IPv4 local connections:
host    all             all             127.0.0.1/32            trust
# IPv6 local connections:
host    all             all             ::1/128                 trust
# Allow replication connections from localhost, by a user with the
# replication privilege.
local   replication     all                                     trust
host    replication     all             127.0.0.1/32            trust
host    replication     all             ::1/128                 trust

これでインストールは完了です。
以下のコマンドで起動出来ます。

$ sudo systemctl start postgresql
1
0
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0