CentOS7上使用GitLab搭建私有git代码仓库(超详细)(上)

简介: CentOS7上使用GitLab搭建私有git代码仓库(超详细)(上)

本片文章讲解的是GitLab13版本的安装,GitLab同时也是非常常用的私有git代码仓库,重点是社区版 “免费”!!!GitLab官网:https://about.gitlab.com

配置要求

安装试验机的配置:

官方的配置要求:https://docs.gitlab.com/ee/install/requirements.html

安装包下载

(如果下载不可用了,可以私信我索要安装包)

下载地址:https://packages.gitlab.com/gitlab/gitlab-ce/packages/el/7/gitlab-ce-13.12.11-ce.0.el7.x86_64.rpm/download.rpm

下载界面:https://packages.gitlab.com/gitlab/gitlab-ce/packages/el/7/gitlab-ce-13.12.12-ce.0.el7.x86_64.rpm

也可以通过命令进行下载:

# 安装wget下载器
yum install -y wget
# 下载GitLab安装包
wget https://packages.gitlab.com/gitlab/gitlab-ce/packages/el/7/gitlab-ce-13.12.12-ce.0.el7.x86_64.rpm/download.rpm -O gitlab-ce-13.12.12-ce.0.el7.x86_64.rpm

下载完成之后:

最好校验一下文件:

[root@localhost src]# ll
total 884956
-rw-r--r--. 1 root root 906193007 Sep 22 17:23 gitlab-ce-13.12.12-ce.0.el7.x86_64.rpm
[root@localhost src]# md5sum gitlab-ce-13.12.12-ce.0.el7.x86_64.rpm 
952a9965c0b628bfac34b076630f4a57  gitlab-ce-13.12.12-ce.0.el7.x86_64.rpm
[root@localhost src]# sha256sum gitlab-ce-13.12.12-ce.0.el7.x86_64.rpm 
0d86311423993e811de9c7e4edc244890c94c133d2d199b36591dfca5dcc3165  gitlab-ce-13.12.12-ce.0.el7.x86_64.rpm
[root@localhost src]# sha512sum gitlab-ce-13.12.12-ce.0.el7.x86_64.rpm 
435af2b37d30fdb04ea1f49890400be71280f4a77fb3ea0ca381143f23419fdfe38b8c30055e2217e62e1473758f1b0ab8921917b03a774d1833784cf671153f  gitlab-ce-13.12.12-ce.0.el7.x86_64.rpm

当然你下载下来的13的版本不同,相对应的数值可能也不一样

依赖安装

执行如下代码进行安装(摘自官网):

# 安装一些依赖
sudo yum install -y curl policycoreutils-python openssh-server perl
# Enable OpenSSH server daemon if not enabled: sudo systemctl status sshd
sudo systemctl enable sshd
sudo systemctl start sshd
# Check if opening the firewall is needed with: sudo systemctl status firewalld
sudo firewall-cmd --permanent --add-service=http
sudo firewall-cmd --permanent --add-service=https
sudo systemctl reload firewalld
# 安装邮箱所需要的软件包
sudo yum install -y postfix
sudo systemctl enable postfix
sudo systemctl start postfix

软件安装

执行命令:

rpm -ivh gitlab-ce-13.12.12-ce.0.el7.x86_64.rpm

出现以下提示说明安装成功:

配置

修改 /etc/gitlab/gitlab.rb 文件,这一行如果有专门的域名那么就写域名,如果没有域名那么就写IP地址

更多配置,如邮箱、ssl(https)、redis、nginx、数据库等,可以参考官方文档,文档地址:

https://docs.gitlab.com/omnibus/settings/

执行以下命令使配置生效(可能时间有点长):

gitlab-ctl reconfigure

如果看到如下界面代表配置成功

启动

常用命令:

# 启动gitlab
gitlab-ctl start
# 停止gitlab
gitlab-ctl stop
# 重启gitlab
gitlab-ctl restart
# 查看gitlab状态
gitlab-ctl status
# 查看gitlab日志
gitlab-ctl tail

分别执行 gitlab-ctl start 和 gitla-ctl status 命令,可以看到启动成功

访问

直接访问服务器的80端口:

访问成功,重置root密码,然后用户名为root,密码为你刚刚设置的密码,点击登录即可来到控制台:

点击 头像->Edit profile 可以设置头像和邮箱

建议设置的地方:

绑定邮箱Git Lab会向你发邮件确认,点击图中位置可以绑定邮箱成功

绑定ssh key,可以不用登录密码的访问代码仓库。点击Edit profile

点击SSH Keys然后编写完成 ssh key 之后

SSH keys的生成(注意在git命令行中执行,然后生成的key在家目录下的 .ssh 目录下,id_rsa.pub 为公钥,也就是写在gitlab当中的内容,注意以文本方式打开)

# 配置个人信息(注意替换邮箱地址)
git config --global user.name "XiaoHH"
git config --global user.email "XXX@qq.com"
# 生成 SSH key(注意替换邮箱地址)
ssh-keygen -t rsa -C "XXX@qq.com"
# (之后连续几个回车即可生成SSH key)

点击 Add key 之后 Git Lab 还会发邮件通知你

相关文章
|
9天前
|
开发工具 git
git 拉取代码仓库代码报错(合并错误 refusing to merge unrelated histories)
git 拉取代码仓库代码报错(合并错误 refusing to merge unrelated histories)
18 0
|
6月前
|
开发工具 git
Git二多次上传代码到代码仓库
Git二多次上传代码到代码仓库
56 0
|
2月前
|
安全 Shell 网络安全
Git学习---Git快速入门、Git基础使用、Git进阶使用、Git服务器使用(IDEA集成GitHub、Gitee、GitLab)、GitHub Desktop客户端
Git学习---Git快速入门、Git基础使用、Git进阶使用、Git服务器使用(IDEA集成GitHub、Gitee、GitLab)、GitHub Desktop客户端
131 0
|
3月前
|
存储 安全 Linux
百度搜索:蓝易云【CentOS7环境:安装配置gitlab(适用于内网、外网环境)】
这些是在CentOS 7环境下安装和配置GitLab的基本步骤。根据您的需求和具体环境,可能还需要进行其他配置和调整。请确保在进行任何与网络连接和安全相关的操作之前,详细了解您的网络环境和安全需求,并采取适当的安全措施。
58 0
|
3月前
|
网络安全 开发工具 数据安全/隐私保护
Git - 记一次完整的新旧Gitlab迁移
Git - 记一次完整的新旧Gitlab迁移
165 0
|
4月前
|
开发工具 git
hbuilderX安装git插件→拉取线上gitlab项目
hbuilderX安装git插件→拉取线上gitlab项目
|
4月前
|
存储 Linux 网络安全
Git - Centos7下安装GitLab服务器
Git - Centos7下安装GitLab服务器
97 1
|
4月前
|
存储 Linux 开发工具
如何在CentOS 8上安装Git
如何在CentOS 8上安装Git
131 0
|
5月前
|
jenkins 网络安全 持续交付
微服务轮子项目(44) -GitLab代码仓库
微服务轮子项目(44) -GitLab代码仓库
61 0
|
3月前
|
缓存 数据安全/隐私保护 Docker
安装gitlab
安装gitlab
147 0

热门文章

最新文章