Clone
4
7.4 OpenCode
jsc-wiki edited this page 2026-10-14 06:27:29 +00:00

OpenCode

第7章 AI 工具 · 來源:JSC 知識庫

簡介

步驟

1. 下載 OpenCode

curl -fsSL https://opencode.ai/install | bash

2. 建立 OpenCode 服務

設定使用者名稱與密碼

echo "export OPENCODE_SERVER_USERNAME='jiantw83'" >> ~/.bashrc
echo "export OPENCODE_SERVER_PASSWORD='<密碼>'" >> ~/.bashrc

以 systemd 管理服務,可開機自動啟動、崩潰時自動重啟。先建立服務設定檔。

nano /etc/systemd/system/opencode.service

服務檔內容如下:

[Unit]
Description=OpenCode

[Service]
Environment=HOME=/root
Type=simple
WorkingDirectory=/root
ExecStart=/root/.opencode/bin/opencode serve --hostname 0.0.0.0 --mdns true --mdns-domain opencode.jsc.idv.me
Restart=always
User=root

[Install]
WantedBy=multi-user.target

3. 啟動服務

重新載入 systemd 設定、設為開機自動啟動、啟動服務並檢視狀態。

systemctl daemon-reload && systemctl enable opencode.service && systemctl start opencode.service && systemctl status opencode.service

← 7.3 OpenClaw · 本章目錄 · 全書目錄 · 7.5 PicoClaw →