mirror of
https://gitea.com/gitea/docs.git
synced 2026-07-21 18:27:41 +00:00
--------- Co-authored-by: silverwind <me@silverwind.io> Co-authored-by: silverwind <2021+silverwind@noreply.gitea.com> Reviewed-on: https://gitea.com/gitea/docs/pulls/455 Reviewed-by: silverwind <2021+silverwind@noreply.gitea.com>
1.8 KiB
1.8 KiB
date, slug, sidebar_position, aliases
| date | slug | sidebar_position | aliases | |
|---|---|---|---|---|
| 2017-07-21T12:00:00+02:00 | linux-service | 40 |
|
作為 Linux 服務運行
您可以使用 systemd 或 supervisor 將 Gitea 作為 Linux 服務運行。以下步驟在 Ubuntu 16.04 上測試,但應該適用於任何 Linux 發行版(稍作修改)。
使用 systemd
將範例 gitea.service 複製到 /etc/systemd/system/gitea.service,然後使用您喜歡的編輯器編輯該文件。
取消註釋需要在此主機上啟用的任何服務,例如 MySQL。
更改使用者、主目錄和其他所需的啟動值。如果使用預設端口,請更改 PORT 或刪除 -p 標誌。
在啟動時啟用並啟動 Gitea:
sudo systemctl enable gitea
sudo systemctl start gitea
如果您擁有 systemd 版本 220 或更高版本,您可以一次性啟用並立即啟動 Gitea:
sudo systemctl enable gitea --now
使用 supervisor
通過在終端中運行以下命令安裝 supervisor:
sudo apt install supervisor
為 supervisor 日誌建立一個日誌目錄:
# 假設 Gitea 安裝在 /home/git/gitea/
mkdir /home/git/gitea/log/supervisor
將範例中的設定附加到 /etc/supervisor/supervisord.conf
supervisord 設定。
使用您喜歡的編輯器,更改使用者 (git) 和主目錄 (/home/git) 設定以匹配部署環境。如果使用預設端口,請更改 PORT 或刪除 -p 標誌。
最後在啟動時啟用並啟動 supervisor:
sudo systemctl enable supervisor
sudo systemctl start supervisor
如果您擁有 systemd 版本 220 或更高版本,您可以一次性啟用並立即啟動 supervisor:
sudo systemctl enable supervisor --now