栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 系统运维 > 运维 > Linux

centos7.5部署Gitlab

Linux 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

centos7.5部署Gitlab

一、部署Gitlab 1、基本概念 1.Gitlib概述

        Gitlab是一个利用Ruby on Rails 开发的开源应用程序,实现一个自托管的Git项目仓库,可通过Web界面进行访问公开的或者私人项目,部分程序已使用Go语音重写。

        GitLab版本:

                - GitLab企业版

                - GitLab CE社区版

        部署方式:

                - 软件包方式

                - 容器方式 

2.部署GitLab服务器(基础环境自行搭建不在赘述)

       ①. GitLab镜像地址:

                链接:https://pan.baidu.com/s/1Ed4v3IAJcunf7JV27t8scg 
                提取码:8888  

        ②. podman介绍:

centos7.5安装podman容器、基础使用、容器共享卷及管理_*_花非人陌_*的博客-CSDN博客_centos podman
 下载安装_极狐GitLab - 极狐GitLab 官方网站centos7.5安装podman容器、基础使用、容器共享卷及管理_*_花非人陌_*的博客-CSDN博客_centos podman

#关闭防火墙、SELinux等
[root@develop ~]# sed -i "/Port /s/.*/Port 2022/" /etc/ssh/sshd_config #修改sshd默认端口(防止端口冲突)
[root@develop ~]# systemctl restart sshd         #重启服务
[root@develop ~]# yum -y install podman          #安装podman
[root@develop ~]# podman load < ./gitlab_zh.tar  #导入镜像
[root@develop ~]# podman images                  #查看镜像
REPOSITORY            TAG      IMAGE ID       CREATED       SIZE
localhost/gitlab_zh   latest   1f71f185271a   4 years ago   1.73 GB
3、启动容器、配置Systemd
[root@develop ~]# mkdir -p /srv/gitlab/{config,logs,data}  #创建数据目录
[root@develop ~]# podman run -d -h gitlib --name gitlab -p 443:443 -p 80:80 -p 22:22 --restart always -v /srv/gitlab/config:/etc/gitlab -v /srv/gitlab/logs:/var/log/gitlab -v /srv/gitlab/data:/var/opt/gitlab gitlab_zh
[root@develop ~]# podman ps   #查看已启动的容器
CONTAINER ID  IMAGE                       COMMAND          CREATED        STATUS            PORTS               NAMES
1a441e786848  localhost/gitlab_zh:latest  /assets/wrapper  3 minutes ago  Up 2 minutes ago  0.0.0.0:22->22/tcp  gitlab
[root@develop ~]# cd /etc/systemd/system/
[root@develop system]# podman generate systemd -n gitlab --files  #生成service文件
/root/container-gitlab.service
[root@develop ~]# systemctl enable /root/container-gitlab.service #设置开启自启动
4. 初始化

使用浏览器访问:http://服务器IP地址(报错500更换浏览器,谷歌可以)

2、配置Gitlab 1.创建用户

2. 创建组

3. 项目
 

3、仓库管理 1.基于密码认证

客户端使用密码登录服务器

[root@git-client ~]# git clone --global user.name "Adminstrator"
[root@git-client ~]# git clone --global user.email "admin@example.com"
[root@git-client ~]# git clone http://192.168.5.111/devops/myproject.git
Cloning into 'myproject'...
warning: You appear to have cloned an empty repository.
[root@git-client ~]# cd myproject/
[root@git-client myproject]# touch README.md
[root@git-client myproject]# git add README.md
[root@git-client myproject]# git commit -m "add README"
[master (root-commit) 87478d5] add README
 1 file changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 README.md
[root@git-client myproject]# git remote -v       #查询连接方式已经改为ssh方式
origin	git@192.168.5.111:devops/myproject.git (fetch)
origin	git@192.168.5.111:devops/myproject.git (push)
服务器名     服务器连接
[root@git-client myproject]# git push -u origin master #推送至主分支
Username for 'http://192.168.5.111': alice
Password for 'http://alice@192.168.5.111': 
Counting objects: 3, done.
Writing objects: 100% (3/3), 216 bytes | 0 bytes/s, done.
Total 3 (delta 0), reused 0 (delta 0)
To http://192.168.5.111/devops/myproject.git
 * [new branch]      master -> master
Branch master set up to track remote branch master from origin.
2. 基于秘钥验证

①.生成秘钥

[root@git-client ~]# ssh-keygen -t rsa -f ~/.ssh/id_rsa -N '' #生成秘钥
[root@git-client ~]# cat .ssh/id_rsa.pub  #查看公钥,并拷贝全部内容

②.登录GitLab网页控制台(以alice用户登录服务器,加载公钥)

③. 使用秘钥管理仓库

        由于刚刚秘钥认证是用http方式访问的仓库,需要将之前的http服务器信息删除,再添加ssh协议访问服务器

[root@git-client myproject]# git remote remove origin  #删除原有连接方式
[root@git-client myproject]# git remote add origin git@192.168.5.111:devops/myproject.git #添加ssh连接方式 
[root@git-client myproject]# git remote -v       #查询连接方式已经改为ssh方式
origin	git@192.168.5.111:devops/myproject.git (fetch)
origin	git@192.168.5.111:devops/myproject.git (push)
[root@git-client myproject]# echo "HELLO WORLD" >> README.md  #修改文件
[root@git-client myproject]# git add .                        #添加修改至缓存区
[root@git-client myproject]# git commit -m "modify readme"    #提交修改到本地仓库
[root@git-client myproject]# git push -u origin master        #推送至master分支

无需密码即可反复推送

③. 上传Web静态网页代码

链接:https://pan.baidu.com/s/180JMFTci1AV89Eje4FKdiA    (静态网页代码下载地址)
提取码:8888 

[root@git-client ~]# yum -y install unzip #安装解压软件包
[root@git-client myproject]# cd /opt/
[root@git-client opt]# unzip www_template.zip
[root@git-client opt]# cd /root/myproject/ #进入仓库目录
[root@git-client myproject]# cp -r /opt/www_template/* ./
[root@git-client myproject]# git add .
[root@git-client myproject]# git commit -m "web site"
[root@git-client myproject]# git push -u origin master
[root@git-client myproject]# git tag v1 #添加标签
[root@git-client myproject]# git push -u origin master v1 #上传标签
转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/963489.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号