安装依赖
yum -y install git screen wget
创建git用户
useradd git
下载压缩包
su - git
wget https://github.com/gogs/gogs/releases/download/v0.11.91/linux_amd64.tar.gz
tar zxf linux_amd64.tar.gz
绑定22端口权限
exit
setcap CAP_NET_BIND_SERVICE=+eip /home/git/gogs/gogs
gogs install
/home/git/gogs/gogs web
创建服务
cp /home/git/gogs/scripts/systemd/gogs.service /etc/systemd/system
sed -i 's/PrivateDevices/#PrivateDevices/g' /etc/systemd/system/gogs.service
sed -i 's/NoNewPrivileges/#NoNewPrivileges/g' /etc/systemd/system/gogs.service
systemctl daemon-reload
chkconfig gogs on
service gogs start && sleep 5
service gogs status
反向代理
yum -y install epel-release
yum -y install nginx
service nginx start
chkconfig nginx on
echo '# Gogs Service
server {
    listen       80;
    server_name  git.srotz.com;

    location / {
        proxy_pass  http://127.0.0.1:3000;
    }
}
' > /etc/nginx/conf.d/gogs.conf
nginx -s reload
HTTPS
curl https://get.acme.sh | sh
alias acme.sh=~/.acme.sh/acme.sh
acme.sh --issue -d git.srotz.com --nginx
mkdir -p /etc/nginx/ssl
acme.sh --installcert -d git.srotz.com \
        --key-file /etc/nginx/ssl/git.srotz.com.key \
        --fullchain-file /etc/nginx/ssl/fullchain.cer \
        --reloadcmd "service nginx force-reload"
echo '
server {
    listen       443 ssl;
    server_name  git.srotz.com;

    ssl_certificate "/etc/nginx/ssl/fullchain.cer";
    ssl_certificate_key "/etc/nginx/ssl/git.srotz.com.key";
    ssl_session_cache shared:SSL:1m;
    ssl_session_timeout  10m;
    ssl_ciphers HIGH:!aNULL:!MD5;
    ssl_prefer_server_ciphers on;

    location / {
        proxy_pass  http://127.0.0.1:3000;
    }
}
' >> /etc/nginx/conf.d/gogs.conf
nginx -s reload
如果觉得我的文章对你有用,请随意赞赏