PostgreSQL15のインストール
sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
sudo apt-get update
sudo apt-get -y install postgresql
PostgreSQL15のパスワードの変更
sudo su - postgres
psql
alter role postgres with password 'Passwd123';
PostgreSQL15の接続設定
sudo gedit /etc/postgresql/15/main/postgresql.conf
sudo gedit /etc/postgresql/15/main/pg_hba.confその他 Ubuntiのツールのインストール(これは、PostgRESTには関係ありません)
sudo apt install net-tools
sudo apt-get -y install baobab
PostgRESTのダウンロードと解凍
Tutorial 0 - Get it Running
を参考に、少し変更する
sudo su - postgres
psql
create database test_1;
\c test_1;
create schema api;
create table api.todos (
id serial primary key,
done boolean not null default false,
task text not null,
due timestamptz
);
insert into api.todos (task) values
('finish tutorial 0'), ('pat self on back');
create role web_anon nologin;
grant usage on schema api to web_anon;
grant select on api.todos to web_anon;
PostgRESTの起動用.confを作成
db-uri = "postgres://postgres:Passwd123@localhost:5432/test_1"
db-schemas = "api"
db-anon-role = "web_anon"
db-uri = "postgres://user:pass@host:5432/dbname" の各意味のドキュメントは
起動
./postgrest tutorial.conf