From 5be7e9d73865b9bd203f172616ba02e45ccac52d Mon Sep 17 00:00:00 2001 From: qilinz Date: Mon, 24 Jul 2023 13:39:49 +0200 Subject: [PATCH] add more doc for install.md --- doc/install.md | 44 ++++++++++++++++++++++++++++++++++++++------ 1 file changed, 38 insertions(+), 6 deletions(-) diff --git a/doc/install.md b/doc/install.md index bfc73151..e6c91fde 100644 --- a/doc/install.md +++ b/doc/install.md @@ -2,10 +2,24 @@ NiceDB / NeoDB - Getting Start ============================== This is a very basic guide with limited detail, contributions welcomed -Install +## Table of Contents +- [1 Install](#1-install) + * [1.1 Database](#11-database) + * [1.2 Configuration](#12-configuration) + * [1.3 Packages & Build](#13-packages---build) +- [2 Start services](#2-start-services) +- [3 Migrate from an earlier version](#3-migrate-from-an-earlier-version) +- [4 Add Cron Jobs (optional)](#4-add-cron-jobs--optional-) +- [5 Index and Search (optional)](#5-index-and-search--optional-) +- [6 Other maintenance tasks (optional)](#6-other-maintenance-tasks--optional-) +- [7 Frequently Asked Questions](#7-frequently-asked-questions) + + +1 Install ------- Install PostgreSQL, Redis and Python (3.10 or above) if not yet +### 1.1 Database Setup database ``` CREATE DATABASE neodb ENCODING 'UTF8' LC_COLLATE='en_US.UTF-8' LC_CTYPE='en_US.UTF-8' TEMPLATE template0; @@ -14,6 +28,7 @@ CREATE ROLE neodb with LOGIN ENCRYPTED PASSWORD 'abadface'; GRANT ALL ON DATABASE neodb TO neodb; ``` +### 1.2 Configuration Create and edit your own configuration file (optional but very much recommended) ``` mkdir mysite && cp boofilsic/settings.py mysite/ @@ -25,8 +40,15 @@ from boofilsic.settings import * SECRET_KEY = "my_key" ``` + +The most important configurations to setup are: + +- `MASTODON_ALLOW_ANY_SITE` set to `True` so that user can login via any Mastodon API compatible sites (e.g. Mastodon/Pleroma) +- `REDIRECT_URIS` should be `SITE_INFO["site_url"] + "/account/login/oauth"`. If you want to run **on local**, `SITE_INFO["site_url"]` should be set to `"http://localhost/"` + More details on `settings.py` in [configuration.md](configuration.md) +### 1.3 Packages & Build Create and use `venv` as you normally would, then install packages ``` python3 -m pip install -r requirements.txt @@ -50,7 +72,7 @@ python3 manage.py collectstatic ``` -Start services +2 Start services -------------- Make sure PostgreSQL and Redis are running @@ -68,7 +90,7 @@ python3 manage.py runserver It should be ready to serve from here, to run web server for production, consider `gunicorn -w 8 boofilsic.wsgi` in systemd or sth similar -Migrate from an earlier version +3 Migrate from an earlier version ------------------------------- Update database ``` @@ -81,11 +103,11 @@ python3 manage.py compilescss python3 manage.py collectstatic ``` -Add Cron Jobs +4 Add Cron Jobs (optional) ------------- add `python manage.py refresh_mastodon` to crontab to run hourly, it will refresh cached users' follow/mute/block from mastodon -Index and Search +5 Index and Search (optional) ---------------- Install TypeSense or Meilisearch, change `SEARCH_BACKEND` and coniguration for search server in `settings.py` @@ -95,7 +117,7 @@ python3 manage.py index --init python3 manage.py index --reindex ``` -Other maintenance tasks +6 Other maintenance tasks (optional) ----------------------- Requeue failed import jobs ``` @@ -118,3 +140,13 @@ Enable Developer Console ``` python3 manage.py createapplication --client-id NEODB_DEVELOPER_CONSOLE --skip-authorization --name 'NeoDB Developer Console' --redirect-uris 'https://example.org/lol' confidential authorization-code ``` + +7 Frequently Asked Questions +------ + +### I got Error: “无效的登录回调地址”. + +Check `REDIRECT_URIS` in `settings.py`, the final value should be `"http://localhost/" + "/account/login/oauth"`. If you are specifying a port, add the port to the localhost address. Please also delete the app record in the database: +``` +delete from mastodon_mastodonapplication where domain_name = 'your_domain_name'; +```