将Rails和PostgreSQL安装到Ubuntu 16.04系统中
引入Rails
这个网站可以作为参考。
http://exrecord.net/how-to-construct-ruby-on-rails-environment-in-ubuntu
在中文中引入PostgreSQL
请按照以下内容进行安装。
https://www.postgresql.org/download/linux/ubuntu/ (公式サイト)
https://weblabo.oscasierra.net/postgresql10-ubuntu1604-install/
首先,创建一个/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。
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