Skip to content
This repository was archived by the owner on Apr 1, 2025. It is now read-only.

Latest commit

 

History

History
127 lines (88 loc) · 3.58 KB

File metadata and controls

127 lines (88 loc) · 3.58 KB

install Persona

install go

install package

persona targeted go version more than 1.12.

  • ArchLinux: $ sudo pacman -S go

  • Debian: $ sudo apt install golang-go

set environment value

  1. set $GOPATH and write ~/.bash_profile. ex) export GOPATH=~/go

  2. set $PATH again, and write ~/.bash_profile. ex) export PATH=$PATH:$GOPATH/src

clone this repo

  1. run $ cd /opt.

  2. run $ sudo git clone https://github.com/persona-dev/persona-server.

build persona

  1. run cd Persona-Server.

  2. run go mod download.

  3. run go build.

install PostgreSQL(optional)

  1. download and install PostgreSQL.

    1. ex) $ sudo pacman -S postgresql etc.

  2. create user.

    • ex) persona

  3. create database.

    • ex) persona

database setting

  1. install sql-migrate

  2. create dbconfig.yml like sample_dbconfig.yml

  3. migrate database

    1. if you use PostgreSQL, run sql-migrate up -env="production" -config=dbconfig.yml.

    2. if you use SQLite3, run sql-migrate up -env="development" -config=dbconfig.yml.

Note
if you rewrite dbconfig.yml, you should refer to this link: https://github.com/rubenv/sql-migrate#as-a-standalone-tool

Security setting

Persona uses RSA key for JWT Authorization.

  1. generate RSA key.

    1. run openssl genrsa 2048 -out private-key.pem.

    2. run openssl rsa -in private_key.pem -pubout -out public_key.pem.

create persona-server.service file (optional)

if you create persona-server.service file, you can use journalctl and systemctl.

  1. run sudo groupadd persona

  2. if you use useradd, run sudo useradd -r -b /opt/Persona-Server -M -s /usr/bin/nologin -g persona persona

  3. if you use adduser, run sudo adduser -r -b /opt/Persona-Server -M -s /usr/bin/nologin --disable-password -G persona persona

    • parameter is examples. maybe you should change parameters.

  4. create persona-server.service file like [persona-server.service].

persona-server.service
link:persona-server.service[role=include]
Note
if you use SQLite3 as database, you should rewrite persona-server.service line 7, like [persona-server-sqlite3.service].
Note
Persona defalt use port localhost:3000. if you use different port, you should set environment value PORT, like [persona-server-port.service]. If you want to change database parameters, change environment variable DATABASE_URL in the same way
persona-server-sqlite3.service
ExecStart=/opt/Persona-Server/persona-server
persona-server-port.service
Environment=DATABASE_URL=postgres://persona:@localhost/persona?sslmode=disable PORT=4000

setup reverse-proxy

you should use mozilla SSL Configuration Generator etc…​…​

nginx

And, add to file end like [persona.nginx].

persona.nginx
location / {
    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection "upgrade";
    proxy_set_header Host $http_host;
    proxy_pass http://127.0.0.1:3000;
    client_max_body_size 16m;
}

Other software(Apache, Caddy, etc.)

Please make settings equivalent to [persona.nginx].

run persona-server

from systemctl

if you create persona-server.service, you can use systemctl.

  1. run systemctl start persona.

  2. run systemctl enable persona.

directly

  1. if you don’t stay /opt/persona-server, enter cd /opt/persona-server.

  2. if you use SQLite3 as database, run ./persona-server

  3. if you use PostgreSQL as database, run ./persona-server