使用 Gogs 搭建自己的 Git 服务器

1. 下载二进制安装包并解压到相关目录

Github:https://github.com/gogits/gogs/releases
官网:https://gogs.io/docs/installation/install_from_binary.html

2. 安装

执行命令 ./gogs web 开启临时服务器,默认开启 127.0.0.1:3000。
或者添加参数修改默认监听的端口 ./gogs web -port 3001

3. 配置 Nginx

location / {
    proxy_pass http://127.0.0.1:3000/;
}

配置子路径

location /gogs/ {
    proxy_pass http://127.0.0.1:3000/;
}

4. 安装

访问域名进行安装,配置网站信息、数据库信息、SMTP 邮件信息和其他信息。

5. 添加系统服务

以 Centos 为例,复制 ./scripts/init/centos 下的 gogs 文件到 /etc/init.d/ 目录下,然后赋予执行权限。

cp ./scripts/init/centos/gogs /etc/init.d/
chmod +x /etc/init.d/gogs

不要忘了将 29 行的 GOGS_HOME 的路径修改为安装目录。

之后就可以使用 service gogs {start|stop|status|restart} 管理 gogs 服务。

猜你喜欢

转载自www.cnblogs.com/StarUDream/p/9045455.html