安裝 Antimatter

使用現成的 compose 檔案、發行版的 .deb 或 .rpm 套件,或發行版檔案安裝 Antimatter。然後建立第一個管理員帳號。

使用 Docker Compose 安裝

這是建議的方式。一個 compose 檔案即可執行 Antimatter、PostgreSQL、檔案儲存空間以及 GIF 服務。您需要一台配備 Docker Engine 及其 Compose 外掛程式(docker compose)、2 個 CPU 核心以及 4 GB 以上記憶體的 Linux 伺服器。

1. 下載 compose 檔案

mkdir antimatter && cd antimatter
curl -fsSLO https://antimatter.chat/compose.yaml

2. 建立 .env 檔案

compose 檔案會從同一目錄下的 .env 檔案讀取設定。請使用隨機產生的金鑰建立該檔案:

cat > .env <<EOF
SITE_URL=http://localhost:8065
POSTGRES_PASSWORD=$(openssl rand -hex 24)
S3_SECRET_KEY=$(openssl rand -hex 24)
GIFS_API_KEY=$(openssl rand -hex 24)
AM_AI_ENCRYPTION_KEY=$(openssl rand -base64 32)
EOF
chmod 600 .env

將 SITE_URL 設為使用者會在瀏覽器輸入的地址,例如區域網路上的 http://192.168.1.20:8065,或搭配網域的 https://chat.example.com。保留 .env 檔案:資料庫和儲存空間使用首次啟動時的這些密碼,AI 模型連線的 API 金鑰使用 AM_AI_ENCRYPTION_KEY 加密,且還原備份時也需要同一個檔案。

3. 啟動

docker compose up -d
docker compose ps

首次啟動可能需要一分鐘左右:PostgreSQL 會建立資料庫,一次性的 bucket 服務會建立儲存空間,一次性的 gifs-stickers 服務會匯入初始貼紙包,而 Antimatter 會建立其資料表。您可以使用 docker compose logs -f antimatter 追蹤進度。

若要一開始就使用網域名稱與 HTTPS,請參閱 網域與 HTTPS:使用 compose 檔案時,只需在 .env 中多兩行設定並加上 https 設定檔即可。

.env 變數

變數預設值功能說明
SITE_URL必要Antimatter 的公開地址(ServiceSettings.SiteURL)。
POSTGRES_PASSWORD必要antimatter 資料庫使用者的密碼。
S3_SECRET_KEY必要檔案儲存空間的金鑰。
GIFS_API_KEY必要Antimatter 呼叫 GIF 服務時使用的金鑰。
AM_AI_ENCRYPTION_KEY留空用於加密 AI 模型連線 API 金鑰的金鑰(openssl rand -base64 32)。留空時,伺服器會在 data 磁碟區中建立金鑰檔案。請參閱加密金鑰。
GIFS_UPLOAD_KEY留空讓使用者能從選擇器新增自己的 GIF 和貼紙,並刪除它們。留空則停用上傳功能。
DOMAIN留空您的網域名稱,用於 https 設定檔。
HTTP_PORT8065Antimatter 網頁伺服器的主機埠號。
CALLS_PORT8443通話音訊與影片的 UDP 和 TCP 埠號。
EDGE_SUBNET172.29.71.0/28Caddy 與 Antimatter 之間網路的子網。若與您現有的網路重疊,請予以變更。
TZUTC容器使用的時區。
ANTIMATTER_IMAGEghcr.io/antimatterchat/antimatter-next:latest要執行的 Antimatter 映像檔(詳見下方)。

執行內容

服務映像檔角色
antimatterghcr.io/antimatterchat/antimatter-next伺服器、網頁應用程式和內建應用程式。公開 HTTP_PORT 和 CALLS_PORT。其資料目錄為 data 磁碟區。
postgrespostgres:17-alpine資料庫,位於 postgres 磁碟區中。
filesrustfs/rustfs用於上傳檔案與已安裝應用程式的 S3 相容儲存空間,位於 files 卷中。
bucketamazon/aws-cli建立 antimatter 儲存桶後結束。
gifsghcr.io/antimatterchat/gifs-serverGIF 與貼圖服務,位於 gifs 卷中。
gifs-stickersghcr.io/antimatterchat/gifs-server首次執行時匯入初始貼圖包,然後結束。
httpscaddy:2-alpine僅限 https 設定檔:在 80 和 443 埠上啟用 HTTPS。

PostgreSQL、儲存空間與 GIF 服務位於一個沒有網際網路存取權限的內部網路(private)上,只有 Antimatter 會加入該網路。這些服務均未發布任何埠。

Antimatter 容器不在磁碟上保留任何內容:其設定位於資料庫中(AM_CONFIG 指向該資料庫),檔案和應用程式位於儲存服務中。您可以隨時移除並重新建立容器。其 data 磁碟區僅存放 AI 加密金鑰檔案,當 AM_AI_ENCRYPTION_KEY 為空時由伺服器建立。所有需要備份的內容都在 postgres、files、gifs 和 data 磁碟區中,以及您的 .env 檔案。

選擇映像檔

已發布兩個 Antimatter 映像檔,均支援 linux/amd64 和 linux/arm64,且皆從每個儲存庫的 main 分支建置:

映像檔內建應用程式標籤
ghcr.io/antimatterchat/antimatter代理程式、通話、GitHub、GitLab、Jira、Kanban、指標與操作手冊。latest、用於發布版本的 X.Y.Z,以及 sha-<commit>
ghcr.io/antimatterchat/antimatter-next與前者相同,另加上語音頻道、投票、郵件、行事曆、筆記、白板、GIF、待辦事項與迷因。每晚重新建置。latest, nightly, nightly-<YYYYMMDD>, sha-<commit>

本網站的 compose 檔案使用 antimatter-next,因為 GIF 服務和本網站描述的大多數應用程式僅包含在該映像檔中。若要變更映像檔,請在 .env 中設定 ANTIMATTER_IMAGE,然後執行 docker compose up -d。

latest 的內容會隨時變動。在生產環境中,請固定使用特定標籤,例如 nightly-20261015 或 sha-<commit>,並僅在升級時有意變更它。伺服器啟動時會升級其資料庫,因此若未還原升級前備份的備份,您無法回退到較舊的映像檔,或從 antimatter-next 切換回 antimatter。請參閱備份與升級。

映像檔內部

  • 伺服器位於 /antimatter,二進位檔 antimatter 和 amctl 位於 /antimatter/bin(在 PATH 中)。
  • 它以非特權使用者 antimatter(uid 2000)執行,基於精簡的 distroless 基礎映像檔,且沒有 shell。
  • 埠:8065(網頁與 API)、8067(指標)、8074(叢集)、8443 UDP 和 TCP(通話)。
  • 本機模式(ServiceSettings.EnableLocalMode)已開啟,因此 amctl --local 可在容器內使用。健康檢查會執行 amctl system status --local。
  • 內建應用程式位於 /antimatter/prepackaged_plugins,並使用 Antimatter 應用程式簽章金鑰進行簽章。
  • 已包含文字提取工具(pdftotext、wvText、unrtf、tidy),因此可以搜尋已上傳文件中的內容。

其他 compose 檔案

antimatter-docker 儲存庫在 deploy/compose/ 中提供生產環境設定:包含 nginx(使用您自己的憑證或 Let's Encrypt (certbot))、PostgreSQL、可選的 GIF 服務(設定檔 gifs),以及用於伺服器設定、資料和日誌的命名卷,相關說明詳見其 README。預設使用穩定版映像檔,並將檔案儲存在本機卷而非 S3 儲存空間。如果您偏好使用 nginx 而非 Caddy,或已有憑證,可使用此設定。

建立第一位管理員

在瀏覽器中開啟 SITE_URL 並建立帳戶。在新伺服器上建立的第一個帳戶將成為系統管理員,接著設定流程會引導您建立第一個社群(Antimatter 對團隊或工作區的稱呼)。

請在首次啟動後立即執行:在此之前,任何先連接到伺服器的人都會成為其管理員。若要改用命令列建立帳戶,請在伺服器可從外部存取之前執行:

docker compose exec antimatter amctl --local user create --system-admin --email-verified \
    --email admin@example.com --username admin --password 'a-long-password'
docker compose exec antimatter amctl --local team create --name main --display-name "Main"
docker compose exec antimatter amctl --local team users add main admin

然後在 SITE_URL 登入。在指令前加一個空格,以避免密碼進入 shell 歷史記錄(需設定 HISTCONTROL=ignorespace),或在登入後變更密碼。

進入系統後的下一步:

  1. 對於公司或組織,請將新社群類型設為工作場所,並在設定中變更已建立社群的類型:工作場所或社群。
  2. 決定誰可以建立帳戶:登入與帳戶。
  3. 設定電子郵件,以便邀請和密碼重設功能正常運作:電子郵件與推送通知。
  4. 在防火牆中開啟通話埠:通話與語音。
  5. 檢查哪些應用程式已啟用:內建應用程式。

下載發行版

若不使用 Docker,請從 GitHub 上的發行版檔案安裝 Antimatter:github.com/AntimatterChat/antimatter/releases。每個發行版都有版本號碼(例如 0.9.0),其標籤為在前面加上 v 的相同數字(v0.9.0)。

Antimatter 目前處於測試階段:其版本號為 0.9.0 系列。若版本號在連字號後帶有後綴,例如 0.9.0-rc.1,則會在 GitHub 上標記為 Pre-release。這是測試版本,於正式發布前釋出。

每個發布版本都包含以下檔案,適用於 amd64 和 arm64 伺服器:

檔案說明
antimatter_<version>-1_amd64.deb, antimatter_<version>-1_arm64.deb適用於 Debian、Ubuntu 及基於它們的發行版的套件。
antimatter-<version>-1.x86_64.rpm, antimatter-<version>-1.aarch64.rpm適用於 Fedora、RHEL 及與 RHEL 相容的發行版的套件。
antimatter-<version>-linux-amd64.tar.gz, antimatter-<version>-linux-arm64.tar.gz發布檔案,適用於任何 Linux 發行版,需手動設定。
SHA256SUMS發布版本中所有檔案的 SHA-256 校驗和。

套件與檔案包含相同的程式:伺服器(antimatter)、命令列工具(amctl)、兩個 Web 應用程式(預設介面與經典介面)、內建應用程式、電子郵件範本以及翻譯。套件額外提供了 systemd 服務和設定檔,因此每個套件都是一體化的安裝:您只需新增一個 PostgreSQL 資料庫。沒有獨立的二進位下載:二進位檔案位於檔案的 antimatter/bin/ 目錄中。它們是靜態編譯的,因此可在其架構的任何 Linux 發行版上執行。

在套件名稱中,預發布版本的連字號會變為波浪號,以便套件管理器將預發布版本排在正式發布版本之前:版本 0.9.0-rc.1 對應 antimatter_0.9.0~rc.1-1_amd64.deb 和 antimatter-0.9.0~rc.1-1.x86_64.rpm。檔案保留連字號。

antimatter version 會將發布版本印出為 組建編號,並將其建置所用的提交印出為 組建雜湊值。其 版本 行是 Antimatter 所基於的 Mattermost 系列的版本。

檢查下載

將您需要的檔案和 SHA256SUMS 下載到同一目錄中,可從發布頁面或使用 curl 下載,然後檢查檔案:

curl -fLO https://github.com/AntimatterChat/antimatter/releases/download/v<version>/antimatter_<version>-1_amd64.deb
curl -fLO https://github.com/AntimatterChat/antimatter/releases/download/v<version>/SHA256SUMS
sha256sum --check --ignore-missing SHA256SUMS

您下載的每個檔案都必須列出並顯示 OK。任何其他結果都表示檔案損毀或不完整:請重新下載,並不要安裝它。SHA256SUMS 未簽名:它僅檢測損毀的下載,其證明力不超過從 GitHub 透過 HTTPS 下載。

安裝 .deb 或 .rpm 套件

該套件將 Antimatter 安裝為 systemd 服務,啟動時僅需要一個資料庫。請在具有 systemd 的 64 位元 Debian、Ubuntu、Fedora 或與 RHEL 相容的伺服器上使用。

套件安裝的內容

路徑內容
/opt/antimatter程式本體:bin/antimatter、bin/amctl、Web 應用程式(client/、client-fusion/)、內建應用程式(prepackaged_plugins/)、範本、翻譯檔與字型。每次升級都會取代這些檔案。
/etc/antimatter/antimatter.env服務設定,以 AM_ 變數形式存在:資料庫、網站 URL、GIF 服務。僅 root 使用者可讀取。升級時會保留這些設定。
/etc/antimatter/config/config.json設定檔,伺服器會在此儲存於系統控制台中所變更的設定。此檔案會在首次安裝時從 /opt/antimatter/defaults/config.json 建立,之後絕不會被取代。
/var/lib/antimatter上傳的檔案(data/)與已安裝的應用程式(plugins/、client-plugins/)。
/var/log/antimatter日誌檔案(若啟用檔案記錄功能)。預設為停用:日誌會輸出至系統日誌(journal)。
/usr/lib/systemd/system/antimatter.service服務。
/usr/bin/amctl指向 /opt/antimatter/bin/amctl 的連結。

伺服器在 /opt/antimatter 中寫入的目錄(config、data、plugins、client/plugins 與 logs)皆是連結,分別指向 /etc/antimatter、/var/lib/antimatter 與 /var/log/antimatter。因此,升級時雖然會取代 /opt/antimatter,但絕不會影響您的資料。套件也會建立系統使用者 antimatter,由其執行伺服器並擁有這些目錄。

此套件依賴 ca-certificates。建議安裝 PostgreSQL(Debian 與 Ubuntu 為 postgresql,Fedora 與 RHEL 為 postgresql-server)、media-types(.rpm 為 mailcap)以及 gifs-server(GIF 服務,有獨立的發行版本,詳見下方)。apt 與 dnf 在找到建議套件時會自動安裝。另建議安裝 poppler-utils、wv、unrtf 與 tidy(.rpm 不含 wv):這些工具可提取上傳文件中的文字,讓搜尋功能能找到文件內部的內容。若需要此功能,請自行安裝。

1. 安裝套件

下載對應您系統架構的 Antimatter 套件與 GIF 服務套件,依上方所示進行驗證,並使用單一指令安裝兩者,以滿足 gifs-server 的建議依賴(該套件不在發行版的套件庫中):

# Debian, Ubuntu
sudo apt install ./antimatter_<version>-1_amd64.deb ./gifs-server_*_amd64.deb
# Fedora, RHEL
sudo dnf install ./antimatter-<version>-1.x86_64.rpm ./gifs-server-*.x86_64.rpm

保留 ./:它告訴 apt 和 dnf 要安裝的是本地檔案。若要安裝但不包含 GIF 服務,請略過該套件。該套件會啟用 antimatter 服務,但不會啟動它,並會顯示後續步驟。

2. 建立資料庫

Antimatter 需要 PostgreSQL 15 或更新版本,可安裝在此伺服器或另一台伺服器上。使用 psql --version 檢查您發行版的 PostgreSQL 版本。如果版本較舊,請從 PostgreSQL 專案的官方套件庫安裝較新版本,或使用另一台伺服器上的資料庫。在 Debian 和 Ubuntu 上,postgresql 套件會啟動資料庫。在 Fedora 和 RHEL 上,請先建立並啟動它:

sudo postgresql-setup --initdb
sudo systemctl enable --now postgresql

然後為 Antimatter 建立使用者和資料庫:

sudo -u postgres psql -c "CREATE USER antimatter WITH PASSWORD 'a-long-password'"
sudo -u postgres psql -c "CREATE DATABASE antimatter OWNER antimatter"

PostgreSQL 必須接受來自 127.0.0.1 的密碼連線:在 pg_hba.conf 檔案的 host 行中,使用 scram-sha-256 方法。

3. 設定資料庫和網站網址

編輯 /etc/antimatter/antimatter.env(sudoedit /etc/antimatter/antimatter.env)。移除您使用的那些行前面的 #,並設定資料庫以及人們將要開啟的網址:

AM_SQLSETTINGS_DRIVERNAME=postgres
AM_SQLSETTINGS_DATASOURCE=postgres://antimatter:a-long-password@localhost:5432/antimatter?sslmode=disable&connect_timeout=10
AM_SERVICESETTINGS_SITEURL=https://chat.example.com

任何設定都可以寫入此檔案,格式為 AM_<SECTION>_<SETTING>:例如,SqlSettings.DataSource 對應 AM_SQLSETTINGS_DATASOURCE。在此設定的項目無法在系統控制台中修改。請參閱設定。每次變更後請重新啟動伺服器:sudo systemctl restart antimatter。

該服務也會設定一些預設值,這些值可被 antimatter.env 中的行覆蓋:記錄到檔案的功能是關閉的(AM_LOGSETTINGS_ENABLEFILE=false、AM_NOTIFICATIONLOGSETTINGS_ENABLEFILE=false),本地模式是開啟的(AM_SERVICESETTINGS_ENABLELOCALMODE=true),以便 amctl --local 能在伺服器上運作。

4. 啟動

sudo systemctl start antimatter
journalctl -u antimatter -f
sudo -u antimatter amctl --local system status

首次啟動時,伺服器會建立資料表,然後監聽 8065 埠。開啟 http://<server>:8065,或在設定反向代理後開啟您的網域(請參閱 網域與 HTTPS),並立即建立第一個帳號:該帳號將成為系統管理員。若要改用命令列建立,請使用 建立第一位管理員 中的 amctl 指令,並以 sudo -u antimatter amctl --local 取代 docker compose exec antimatter amctl --local。

5. 啟用 GIFs

GIFs 應用程式已隨附並處於啟用狀態,且 antimatter.env 已將其指向同一伺服器上的 GIF 服務(AM_GIFS_SERVICE_URL=http://127.0.0.1:8080/v2)。但仍需要該服務的 API 金鑰。gifs-server 套件在安裝時已生成了一個金鑰:

sudo systemctl start gifs-server-stickers    # imports the sticker pack, about a minute and a half
sudo systemctl start gifs-server
sudo grep -v '^#' /etc/gifs-server/api-keys

將金鑰填入 antimatter.env 中的 AM_GIFS_API_KEY=<key> 並重新啟動 Antimatter,或在 系統控制台 › 擴充程式 › GIFs 中輸入 API 金鑰。如果 GIF 服務運行在其他伺服器上,請將 AM_GIFS_SERVICE_URL 設定為該伺服器的位址。若要讓使用者新增自己的 GIFs 和貼紙,請參閱 GIFs。

服務

  • 它以 antimatter 使用者身分運行,位於 /opt/antimatter,並讀取 /etc/antimatter/antimatter.env。systemd 會在伺服器退出時重新啟動它,並給予最多一小時的啟動時間,因為新版本的資料庫遷移可能需要較長時間。
  • 其日誌位於 journal 中:journalctl -u antimatter。
  • 它已進行強化:/usr 和 /etc 對伺服器而言為唯讀,但 /etc/antimatter/config 除外,且它無法看到 /home、/root 或 /run/user。如果您移動檔案儲存位置(FileSettings.Directory),請選擇這些目錄之外、且由 antimatter 擁有的目錄。
  • 升級會取代服務檔案。若要修改它,請使用 sudo systemctl edit antimatter,這會將您的變更保留在單獨的檔案中。

升級套件

  1. 先進行備份(請參閱 備份與升級)。
  2. 下載新的套件和 SHA256SUMS,並進行驗證。
  3. 停止伺服器,在舊套件上安裝新套件,然後再次啟動:
    sudo systemctl stop antimatter
    sudo apt install ./antimatter_<new version>-1_amd64.deb     # or: sudo dnf install ./antimatter-<new version>-1.x86_64.rpm
    sudo systemctl start antimatter
    journalctl -u antimatter -f

套件本身不會重新啟動伺服器。升級完成後,系統會顯示 Antimatter was upgraded; restart it to run the new version: sudo systemctl restart antimatter:如果您先前未停止伺服器,請立即重新啟動。升級過程會取代 /opt/antimatter 與服務檔案,但會保留 antimatter.env、config.json、/var/lib/antimatter 以及日誌。伺服器啟動時,會升級資料庫並安裝隨附應用程式的較新版本。

如果新版本變更了預設的 antimatter.env,apt 會詢問您是否要保留目前的版本:請選擇保留。dnf 會保留您的版本,並將新版本儲存為 /etc/antimatter/antimatter.env.rpmnew。升級只能向前進行:請勿在較新版本上安裝較舊的版本。

移除套件

sudo apt remove antimatter 或 sudo dnf remove antimatter 會停止並停用服務,並移除程式。此操作會保留資料(/var/lib/antimatter)、設定(/etc/antimatter)、資料庫以及 antimatter 使用者:若要完全移除 Antimatter,請自行刪除這些項目。

套件與檔案庫中的應用程式

套件與檔案庫包含這些應用程式的最新簽名發行版,位於 prepackaged_plugins/ 中:Agents、Calls、GIFs、Memes、Notes、Polls、Todo、Voice Channels 和 Whiteboard。若伺服器發行版建置時某應用程式尚無發行版,則不會包含在內:執行 ls /opt/antimatter/prepackaged_plugins 即可查看您的發行版包含哪些應用程式。Memes 和 Todo 已包含但未啟用:Bundled apps 說明如何安裝並啟用它們。

Docker 映像檔中的其他應用程式未包含在套件或檔案庫中:Kanban、Playbooks、Mail、Calendar、GitHub、GitLab、Jira 和 Metrics。請從各自的發行版安裝每個應用程式:

應用程式發行版應用程式 ID
Kanbanantimatter-plugin-boardsfocalboard
Playbooksantimatter-plugin-playbooksplaybooks
Mailantimatter-plugin-mailcom.antimatterchat.mail
Calendarantimatter-plugin-calendarcom.antimatterchat.calendar
GitHubantimatter-plugin-githubgithub
GitLabantimatter-plugin-gitlabcom.github.manland.mattermost-plugin-gitlab
Jiraantimatter-plugin-jirajira
指標Antimatter-plugin-metricscom.mattermost.mattermost-plugin-metrics

每個應用程式版本都包含應用程式的捆綁包(.tar.gz 檔案)、其簽章(同名加上 .sig)以及 SHA256SUMS 檔案。若要安裝應用程式,請先允許上傳,然後使用 amctl 新增捆綁包:

# 1. In /etc/antimatter/antimatter.env, add this line, then restart Antimatter
AM_PLUGINSETTINGS_ENABLEUPLOADS=true
sudo systemctl restart antimatter
# 2. Download the bundle where the antimatter user can read it, and install it
cd /tmp
curl -fLO https://github.com/AntimatterChat/antimatter-plugin-boards/releases/download/v<version>/<bundle>.tar.gz
sudo -u antimatter amctl --local plugin add <bundle>.tar.gz
sudo -u antimatter amctl --local plugin enable focalboard

若要升級以此方式安裝的應用程式,請使用 plugin add --force 新增新的捆綁包:套件升級只會升級捆綁的應用程式。之後您可以再次移除 AM_PLUGINSETTINGS_ENABLEUPLOADS 這一行。其他安裝應用程式的方式,請參閱安裝其他應用程式。

應用程式簽章

應用程式捆綁包使用 Antimatter 應用程式簽章金鑰進行簽章:每個 .tar.gz.sig 檔案都是其捆綁包的獨立 GPG 簽章。伺服器在安裝捆綁應用程式之前會檢查這些簽章。若要自行檢查捆綁包:

curl -fsSLO https://raw.githubusercontent.com/AntimatterChat/antimatter-docker/main/keys/antimatter-plugin-signing.asc
gpg --import antimatter-plugin-signing.asc
gpg --verify <bundle>.tar.gz.sig <bundle>.tar.gz

gpg 必須報告來自 Antimatter Plugin Signing 的有效簽章,指紋為 06C8 1032 4677 0F08 BBA7 78B9 E69B 05C3 92A6 9A45。它也會警告該金鑰未以受信任的簽章認證:對於您未自行簽章的金鑰來說,這是正常的。沒有 .sig 檔案的應用程式版本為未簽章,其發行說明也會如此註明。

從發行版檔案安裝

壓縮檔 antimatter-<version>-linux-<arch>.tar.gz(例如 antimatter-0.9.0-linux-amd64.tar.gz)適用於沒有 .deb 或 .rpm 套件的發行版,或您自訂的佈局。它包含一個 antimatter/ 目錄,其中有 bin/antimatter、bin/amctl、config/config.json、Web 應用程式(client/ 和 client-fusion/)、捆綁的應用程式(prepackaged_plugins/,請參閱上方)、電子郵件範本以及翻譯。

1. 準備 PostgreSQL

Antimatter 僅支援 PostgreSQL 15 或更新版本(較舊的版本會啟動,但日誌中會出現錯誤)。請建立使用者和資料庫:

sudo -u postgres psql <<'EOF'
CREATE USER antimatter WITH PASSWORD 'a-long-password';
CREATE DATABASE antimatter OWNER antimatter;
EOF

2. 解壓縮並設定

sudo tar -xzf antimatter-<version>-linux-amd64.tar.gz -C /opt
sudo useradd --system --user-group antimatter
sudo mkdir -p /opt/antimatter/data
sudo chown -R antimatter:antimatter /opt/antimatter

透過 /opt/antimatter/config/config.json(SqlSettings.DataSource)或環境變數,將伺服器指向資料庫,並設定網站 URL:

AM_SQLSETTINGS_DRIVERNAME=postgres
AM_SQLSETTINGS_DATASOURCE=postgres://antimatter:a-long-password@localhost:5432/antimatter?sslmode=disable&connect_timeout=10
AM_SERVICESETTINGS_SITEURL=https://chat.example.com

檔案包中的 config.json 是完整的預設設定:您在系統控制台中變更的設定會儲存回該檔案。若要改為將設定儲存在資料庫中,請參閱設定。

3. 作為服務執行

systemd 單元,位於 /etc/systemd/system/antimatter.service:

[Unit]
Description=Antimatter
After=network.target postgresql.service

[Service]
Type=notify
User=antimatter
Group=antimatter
WorkingDirectory=/opt/antimatter
ExecStart=/opt/antimatter/bin/antimatter
EnvironmentFile=-/etc/antimatter.env
TimeoutStartSec=3600
Restart=always
RestartSec=10
LimitNOFILE=49152

[Install]
WantedBy=multi-user.target

將您的 AM_ 變數放入 /etc/antimatter.env(僅 root 可讀),然後執行:

sudo systemctl daemon-reload
sudo systemctl enable --now antimatter
journalctl -u antimatter -f

伺服器監聽 8065 埠。開啟 http://<server>:8065,或在設定反向代理後開啟您的網域(請參閱網域與 HTTPS),並建立第一個帳戶:該帳戶將成為系統管理員。

bin/amctl 可從命令列管理執行中的伺服器。在伺服器本機上,它可透過本機模式運作而無需登入:設定 AM_SERVICESETTINGS_ENABLELOCALMODE=true,然後執行 sudo -u antimatter /opt/antimatter/bin/amctl --local system status。

若要使用 GIF,請安裝 GIF 服務(見下方),並依照套件步驟 5設定 AM_GIFS_SERVICE_URL 和 AM_GIFS_API_KEY。

GIF 服務與推送代理套件

GIF 服務與推送代理程式有各自的版本發布,規則與伺服器相同:包含 .tar.gz 壓縮檔、適用於 amd64 和 arm64 的 .deb 與 .rpm 套件,以及 SHA256SUMS 檔案。帶有連字號的版本為預發布版本。如同伺服器,請使用 sha256sum --check --ignore-missing SHA256SUMS 來驗證下載檔案。

GIF 服務 (gifs-server)

版本發布:github.com/AntimatterChat/gifs-server/releases。壓縮檔命名為 gifs-server-<version>-linux-<arch>.tar.gz;套件命名為 gifs-server。

sudo apt install ./gifs-server_*_amd64.deb      # Debian, Ubuntu
sudo dnf install ./gifs-server-*.x86_64.rpm     # Fedora, RHEL

套件會安裝:

  • /usr/bin/gifs-server,以及 gifs-server 服務,該服務以 gifs-server 使用者身分執行,並將目錄儲存在 /var/lib/gifs-server;
  • gifs-server-stickers 服務,在您啟動它時會匯入或更新 /usr/share/gifs-server/stickers 中的貼紙包,然後停止;
  • 其設定檔 /etc/gifs-server/gifs-server.env(包含 AM_GIFS_ 變數,升級時會保留)以及 /etc/gifs-server/api-keys,每行一個 API 金鑰,首次安裝時會產生隨機金鑰。

它監聽 127.0.0.1:8080,因此只有同一台伺服器上的 Antimatter 才能存取。如果 Antimatter 執行在其他地方,請在 gifs-server.env 中設定 AM_GIFS_LISTEN=:8080,並使用防火牆限制對該端口的存取。該檔案列出了其他設定:AM_GIFS_UPLOAD_KEYS(允許新增 GIF 和貼紙,以及刪除使用這些金鑰新增項目的金鑰)、AM_GIFS_PUBLIC_URL、AM_GIFS_TRUST_PROXY 和 AM_GIFS_LOG_LEVEL。套件建議安裝 ffmpeg、gifsicle、librsvg2-bin(.rpm 為 librsvg2-tools)以及 DejaVu 字型:服務在匯入或接收檔案時使用它們來製作 GIF、影片和貼紙格式,若未安裝這些工具,服務仍可執行。

與伺服器相同,服務在安裝時已啟用但未啟動。請依照套件步驟 5所示啟動它。升級後請重新啟動:sudo systemctl restart gifs-server。移除套件時,/var/lib/gifs-server 中的目錄會保留。

推送代理程式

發行版本:github.com/AntimatterChat/push-proxy/releases。檔案庫為 antimatter-push-proxy-<version>-linux-<arch>.tar.gz;套件名稱為 antimatter-push-proxy。該套件會安裝 /usr/bin/antimatter-push-proxy 與 antimatter-push-proxy 服務,該服務以 antimatter-push-proxy 使用者身分執行,並讀取 /etc/antimatter-push-proxy/antimatter-push-proxy.json(升級時會保留)。Apple 與 Firebase 憑證請存放於 /etc/antimatter-push-proxy/certs:推播通知 說明這些憑證的來源。

sudo apt install ./antimatter-push-proxy_*_amd64.deb      # or: sudo dnf install ./antimatter-push-proxy-*.x86_64.rpm
sudo install -o root -g antimatter-push-proxy -m 0640 \
    AuthKey_ABCDE12345.p8 firebase-service-account.json /etc/antimatter-push-proxy/certs/
sudoedit /etc/antimatter-push-proxy/antimatter-push-proxy.json
sudo systemctl start antimatter-push-proxy
journalctl -u antimatter-push-proxy -f

在設定檔中,路徑相對於 /etc/antimatter-push-proxy:例如 "AppleAuthKeyFile": "./certs/AuthKey_ABCDE12345.p8" 與 "ServiceFileLocation": "./certs/firebase-service-account.json"。接著在 Antimatter 中將 推播通知伺服器 設為 http://<proxy host>:8066。升級後請重新啟動:sudo systemctl restart antimatter-push-proxy。

推播代理程式會監聽所有位址上的 8066 埠,且不檢查呼叫者身分。請將該埠保留在私人網路中,或置於限制存取的反向代理程式之後。

其他伺服器指令

除了執行伺服器(antimatter 或 antimatter server)外,該二進位檔還包含幾個維護指令。它們讀取的設定與伺服器相同。

指令功能說明
antimatter version顯示版本、建置編號、建置日期和建置雜湊值。
antimatter db ping檢查資料庫是否可連線。
antimatter db init在資料庫中建立設定(需將 AM_CONFIG 設定為 postgres:// URL)。
antimatter db migrate在啟動伺服器前套用資料庫遷移。
antimatter db version顯示已套用到資料庫的最後一個遷移。
antimatter import bulk, antimatter export bulk以批量格式匯入或匯出資料(請參閱備份與升級)。