banner
 Aeris

Aerisの小宇宙

使用1Panel部署Akkoma

在部署完 Sharkey 後我又看到了 Pleroma 的一個分支 ——Akkoma,看起來比 Sharkey 更加輕量化。

(Mastodon 我就不指望了,畢竟小微型伺服器)

所以蠢蠢欲動之下又開始了部署之旅

本文分享的方法是通過 1panel 進行傻瓜式的安裝,測試系統 Debian 12。

歡迎大夥加入聯邦宇宙。

官方庫:https://akkoma.dev/AkkomaGang/akkoma/

官方文檔:https://docs.akkoma.dev/stable/

準備工作#

在部署前你需要準備一個域名、一個系統純淨的 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. 後期維護備份

申請證書#

首先進入 網站 - 證書

image

創建 DNS 賬戶#

我用的是 Cloudflare,其他的可以自行百度如何獲取 apikey。

image-20240208201948972

目前 CloudFlare 需要使用 API Token

創建 Acme 賬戶#

image

點擊 申請證書,等待完成

反代網站#

image

輸入主域名,為你的 網站地址

代理地址填寫 你的伺服器 ip: 服務端口號

進入 配置

image

image

選擇之前創建的 Acme 賬戶與證書,保存

不要忘了在 DNS 服務商處添加記錄!#

image

至此你的网站已经搭建完毕,输入创建账户时,服务器生成的指令进行密码设置,就可以开始使用了。

配置中文搜索#

使用資料庫插件的方法個人認為太過複雜(誒嘿),所以選用 Meilisearch

1Panel 中搜索 MeiliSearch,並安裝

image

查看參數

image

打開你的站點,查看右上角,點擊進入控制面板

image

點擊 Settings-Search

image

選擇 Meilisearch

Url:回到 1Panel,點擊容器

image

在此可以看到 ip 地址,端口和 Key,安裝之前看到的參數填寫。

右下角 Submit 提交。

回到首頁進行測試

image

完成


如果本文對你有幫助,歡迎光臨 / 關注 @[email protected]

載入中......
此文章數據所有權由區塊鏈加密技術和智能合約保障僅歸創作者所有。