MENU

gitea部署踩坑-centos7

February 8, 2021 • linux相关

安装

  • 先安装最新版 git: https://mirrors.edge.kernel.org/pub/software/scm/git/
  • 从官网下载对应版本的 gitea-xxx-linux-amd64
  • 添加 gitea 用户/组:

    sudo useradd -d /home/gitea -m -r -s /bin/bash gitea
    sudo -u gitea mkdir -p /home/gitea/{custom,data,log}
    sudo chmod -R 750 /home/gitea/

配置 gitea 用户环境变量

su gitea
vim ~/.bash_profile

内容:

# Get the aliases and functions
if [ -f ~/.bashrc ]; then
        . ~/.bashrc
fi

# User specific environment and startup programs

PATH=/usr/local/git/bin:/usr/local/openresty/bin:/usr/local/openresty/nginx/sbin:$PATH
export PATH

添加开机启动服务

#> vim /usr/lib/systemd/system/gitea.service
[Unit]
Description=Gitea-2021
After=syslog.target
After=network.target

[Service]
User=gitea
Group=gitea
Environment=USER=gitea HOME=/home/gitea GITEA_WORK_DIR=/home/gitea PATH=/usr/local/git/bin:/usr/local/openresty/bin:/usr/local/openresty/nginx/sbin:/usr/local/openresty/bin:/usr/local/openresty/nginx/sbin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin:/usr/local/git/bin:/root/bin
WorkingDirectory=/home/gitea/
ExecStart=/home/gitea/gitea web --config /home/gitea/custom/conf/app.ini
Restart=always
RestartSec=2s

[Install]
WantedBy=multi-user.target
systemctl enable gitea
systemctl start gitea
systemctl status gitea

查看运行日志

journalctl -b 0 -u gitea
Last Modified: July 31, 2021