在部署完 Sharkey 后我又看到了 Pleroma 的一个分支 ——Akkoma,看起来比 Sharkey 更加轻量化。
(Mastodon 我就不指望了,毕竟小微型服务器)
所以蠢蠢欲动之下又开始了部署之旅
本文分享的方法是通过 1panel 进行傻瓜式的安装,测试系统 Debian 12。
欢迎大伙加入联邦宇宙。
准备工作#
在部署前你需要准备一个域名、一个系统纯净的 VPS,本文使用的是 Debian 12 系统,如果你是其他系统,请根据官方文档自己查找相关代码。
设置 Swap#
(或在 1panel 面板中的 工具箱 - 快速设置 - Swap 中找到)
wget https://www.moerats.com/usr/shell/swap.sh && bash swap.sh
正式部署#
安装 curl#
apt install curl
安装 1Panel#
1panel 官方文档:https://1panel.cn/docs/installation/online_installation/
在安装 1Panel 的过程中同时会安装 Docker 和 Docker-Compose
我使用的 Debian
curl -sSL https://resource.fit2cloud.com/1panel/package/quick_start.sh -o quick_start.sh && bash quick_start.sh
创建名为 akkoma 的用户#
sudo useradd -r -s /bin/false -m -d /var/lib/akkoma -U akkoma
为 akkoma 添加 Docker 权限#
sudo usermod -aG docker akkoma
新建一个 Shell 窗口,使用 akkoma 登录#
su -l akkoma -s $SHELL
回到原来的 root 窗口,给予 akkoma 文件夹权限,并拉取资源#
sudo mkdir -p /opt/akkoma
sudo chown -R akkoma:akkoma /opt/akkoma
sudo -Hu akkoma git clone https://akkoma.dev/AkkomaGang/akkoma.git -b stable /opt/akkoma
回到 akkoma 窗口,进入下载目录#
cd /opt/akkoma
修改 docker-composed.yml 文件#
version: "3.7"
services:
db:
image: akkoma-db:latest
build: ./docker-resources/database
restart: unless-stopped
user: ${DOCKER_USER}
environment: {
# This might seem insecure but is usually not a problem.
# You should leave this at the "akkoma" default.
# The DB is only reachable by containers in the same docker network,
# and is not exposed to the open internet.
#
# If you do change this, remember to update "config.exs".
POSTGRES_DB: akkoma,
POSTGRES_USER: akkoma,
POSTGRES_PASSWORD: akkoma,
}
env_file:
- .env
volumes:
- type: bind
source: ./pgdata
target: /var/lib/postgresql/data
akkoma:
image: akkoma:latest
build: .
restart: unless-stopped
env_file:
- .env
links:
- db
ports: [
# Uncomment/Change port mappings below as needed.
# The left side is your host machine, the right one is the akkoma container.
# You can prefix the left side with an ip.
# Webserver (for reverse-proxies outside of docker)
# If you use a dockerized proxy, you can leave this commented
# and use a container link instead.
"0.0.0.0:4000:4000",
]
volumes:
- .:/opt/akkoma
# Uncomment the following if you want to use a reverse proxy
#proxy:
# image: caddy:2-alpine
# restart: unless-stopped
# links:
# - akkoma
# ports: [
# "443:443",
# "80:80"
# ]
# volumes:
# - ./docker-resources/Caddyfile:/etc/caddy/Caddyfile
# - ./caddy-data:/data
# - ./caddy-config:/config
我作出的更改:
akkoma 部署 ip从 127.0.0.1 改为 0.0.0.0。
开始按照官方文档进行部署#
cp docker-resources/env.example .env
echo "DOCKER_USER=$(id -u):$(id -g)" >> .env
构建容器#
./docker-resources/build.sh
生成实例#
mkdir pgdata
./docker-resources/manage.sh mix deps.get
./docker-resources/manage.sh mix compile
./docker-resources/manage.sh mix pleroma.instance gen
在输入完最后一行代码时,它会问你几个问题
数据库主机名是 db,数据库密码是 akkoma(不要回车自动生成),你需要将 IP 设置为 0.0.0.0。
输入参数#
What domain will your instance use?
(e.g akkoma.example.com) [] #输入自己的实例域名
What is the name of your instance?
(e.g. The Corndog Emporium) [kaixin.meme] #站点名称
What is your admin email address? [] #管理员邮箱
What email address do you want to use for sending email notifications? [[email protected]] #用于发送邮件的邮箱
Do you want search engines to index your site? (y/n) [y] #是否启用搜索功能
Do you want to store the configuration in the database (allows controlling it from admin-fe)? (y/n) [n] #是否允许管理员面板修改数据库内容,建议开启
What is the hostname of your database? [localhost] #数据库的地址,如果使用docker,填db
# 这三项都填akkoma
# ——————————————————
What is the name of your database? [akkoma]
What is the user used to connect to your database? [akkoma]
What is the password used to connect to your database? [autogenerated] akkoma
# ——————————————————
Would you like to use RUM indices? [n] #因为不清楚是用于什么的,我没有开启(诶嘿,小白
What port will the app listen to (leave it if you are using the default setup with nginx)? [4000] #端口号
What ip will the app listen to (leave it if you are using the default setup with nginx)? [127.0.0.1] 0.0.0.0 #我用1panel,所以写0.0.0.0
#下面两项我都没有改
# ————————————————
What directory should media uploads go in (when using the local uploader)? [uploads]
What directory should custom public files be read from (custom emojis, frontend bundle overrides, robots.txt, etc.)? [instance/static/]
# ————————————————
Do you want to strip location (GPS) data from uploaded images? This requires exiftool, it was detected as installed. (y/n) [y] n #是否从上传的照片获取GPS信息,我没开启
Do you want to anonymize the filenames of uploads? (y/n) [n] y #匿名化文件名,我开了
Do you want to deduplicate uploaded files? (y/n) [n] y
#去除重复的已上传文件,我选是
如果 email 之类的输错了也没有关系,在 /config/generated_config.exs 文件下也可以进行修改
或者添加 --force 参数重新部署
继续部署#
cp config/generated_config.exs config/prod.secret.exs
初始化数据库#
docker compose run --rm --user akkoma -d db
# Note down the name it gives here, it will be something like akkoma_db_run,可以登陆1panel-容器进行查看
docker compose run --rm akkoma psql -h db -U akkoma -f config/setup_db.psql
docker stop akkoma_db_run # Replace with the name you noted down,修改为你的容器名
运行迁移#
./docker-resources/manage.sh mix ecto.migrate
启动服务并在后台运行#
docker compose up -d
检查在 IP 地址:4000 上是否有服务,如果没有,可以看看之前是不是哪里还留着 127.0.0.1
如果一切顺利,那么可以继续创建账号了。
创建账号#
./docker-resources/manage.sh mix pleroma.user new MY_USERNAME MY_EMAIL@SOMEWHERE --admin
将 MY_USERNAME 改为你的用户名。
MY_EMAIL@SOMEWHERE 改为你的邮箱。
在运行完后会生成一个网址,用于设置初始账号密码,记得保存下来,在反代设置完 https 之后要用。
安装前端#
./docker-resources/manage.sh mix pleroma.frontend install pleroma-fe --ref stable
./docker-resources/manage.sh mix pleroma.frontend install admin-fe --ref stable
1Panel 操作部分#
1. 申请证书
2. 反代网页
3. 安装 meilisearch
4. 后期维护备份
申请证书#
首先进入网站 - 证书
创建 DNS 账户#
我用的是 Cloudflare,其他的可以自行百度如何获取 apikey。
目前 CloudFlare 需要使用 API Token
创建 Acme 账户#
点击 申请证书,等待完成
反代网站#
输入主域名,为你的网站地址
代理地址填写你的服务器 ip: 服务端口号
进入配置
选择之前创建的 Acme 账户与证书,保存
不要忘了在 DNS 服务商处添加记录!#
至此你的网站已经搭建完毕,输入创建账户时,服务器生成的指令进行密码设置,就可以开始使用了。
配置中文搜索#
使用数据库插件的方法个人认为太过复杂(诶嘿),所以选用Meilisearch
1Panel 中搜索 MeiliSearch,并安装
查看参数
打开你的站点,查看右上角,点击进入控制面板
点击 Settings-Search
选择 Meilisearch
Url:回到 1Panel,点击容器
在此可以看到 ip 地址,端口和 Key,安装之前看到的参数填写。
右下角 Submit 提交。
回到首页进行测试
完成
如果本文对你有帮助,欢迎光临 / 关注 @[email protected]