CentOS7 + 宝塔环境搭建 Gogs 私人Git 仓库

samool 发布暂无评论8707 阅读

AI摘要

本文介绍了在CentOS7环境下,使用宝塔面板搭建Gogs私人Git仓库的详细步骤。包括安装宝塔面板、Git、创建git用户组和用户、下载和解压Gogs安装包、启动安装程序、配置域名访问等。同时提供了gogs.service服务配置文件的示例,以便实现Gogs的开机自启。
安装文档 https://gogs.io/docs/installation

我这里的安装环境:

CentOS7 + 宝塔面板 + Nginx + Mysql5.7

git 版本 1.8.3.1

Gogs 版本 0.11.66 @ 2018-09-16

安装包下载地址列表:

官方:

https://gogs.io/docs/installation/install_from_binary.html

github

https://github.com/gogs/gogs/releases

找到 Linux amd64 的下载地址

https://dl.gogs.io/0.11.66/gogs_0.11.66_linux_amd64.zip

安装宝塔面板

**

yum install -y wget && wget -O install.sh http://download.bt.cn/install/install.sh && sh install.sh

我这里选择的环境是

Mysql5.7 + PHP7.2 + Nginx 1.14.0 + phpmyadmin4.x + Pure-Ftpd 1.0.47

安装Git (已经安装的跳过)

**

yum install -y git

查看Git版本

**

git --version

创建一个git用户组

**

groupadd git

创建一个git用户并添加到git用户组

**

useradd -g git git

修改git用户的密码

**

passwd git

创建好了之后, 切换到Git身份

**

su git

这时候已经是git用户了, 进入git的home目录

**

cd ~

下载gogs安装压缩包, 双引号里的下载地址替换为官方最新版本的下载地址

**

wget -c "https://dl.gogs.io/0.11.66/gogs_0.11.66_linux_amd64.zip" -O gogs.zip

解压安装包

**

unzip gogs.zip

进入gogs目录

**

cd gogs

启动安装程序

**

./gogs web
在宝塔面板->安全-> 添加3000端口, 允许访问

回到桌面, 用浏览器打开安装向导页面, 根据自己情况设置

**

http://192.168.1.101:3000

安装完成后, 回到终端, 退出当前的git用户

**

exit

为gogs添加服务,开机启动

**

# 创建服务配置文件
vim /lib/systemd/system/gogs.service

加入以下内容, 保存退出:

**

[Unit]
Description=Gogs
After=syslog.target
After=network.target
After=mysqld.service

[Service]
# Modify these two values and uncomment them if you have
# repos with lots of files and get an HTTP error 500 because
# of that
###
#LimitMEMLOCK=infinity
#LimitNOFILE=65535
Type=simple
User=git
Group=git
WorkingDirectory=/home/git/gogs
ExecStart=/home/git/gogs/gogs web
Restart=always
Environment=USER=git HOME=/home/git

[Install]
WantedBy=multi-user.target

设置开机启动

**

systemctl enable gogs.service

并手动启动服务

**

systemctl start gogs

查看服务状态

**

systemctl status gogs

在宝塔面板上配置域名访问(反向代理)

这个时候就可以通过域名访问了, https证书在宝塔界面配置部署即可, 不用改gogs配置

使用域名访问搭建好的gogs

代理 · 浏览器 · 目录 · 来源 · 服务 · 桌面 · 内容 · 文件 · 访问 · 密码 · 程序 · 链接 · c · 列表 · 安装 · 界面 · 域名 · web · 环境 · get · cd · error · 商业 · 端口 · 宝塔 · 组 · 用户 · git · gogs · home
  1. 01Golang 汇编入门知识总结2020-09-27
  2. 02Centos7 完全卸载mysql2020-12-16
  3. 03视频防盗链技术方案研究与讲解2020-09-15
  4. 04Centos7 下安装Golang2020-09-01
  5. 05远程桌面连接报【由于CredSSP 加密数据库修正】错误解决办法2020-09-16
  6. 06SQL Server 2008 评估期已过的解决办法2020-10-26
  7. 07【Redis持久化】服务器突然挂了!Redis缓存都在内存中啊2020-09-27
  8. 08未在本地计算机上注册“microsoft.ACE.oledb.12.0”提供程序2020-09-22
  9. 09自建php仿新浪短网址服务2020-11-18
  10. 10关于px、em、rem、rpx、upx的知识2020-09-30
COMMENTS / 一纸留言

读者留言 0 条

一纸留言,便是山水间的一次相逢。

还没有留言,欢迎写下第一段交流。

WRITE A COMMENT

写下你的留言