gitlab服务器的搭建、汉化,下载、上传的详细步骤

gitlab作为一个伪github,深受企业喜爱,明了的界面化显示,易于操作,也易于学习;

借此契机,我把我搭建,汉化gitlab,下载,上传gitlab库记录下来,方便参考;

 

安装gitlab前提:4G的内存+CentOS 7.4

80端口和8080端口未被占用;

gitlab-ce版本:11.5.3最新版本

 

1.首先,下载gitlab-ce至本地;

[root@slave2 ~]# wget https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/gitlab-ce-11.5.3-ce.0.el7.x86_64.rpm


 

2.安装gitlab,出现下图所示内容即可;

[root@slave2 ~]# yum -y install gitlab-ce-10.0.3-ce.0.el7.x86_64.rpm


image.png


3.安装gitlab 依赖关系;

[root@slave2 ~]# yum -y install policycoreutils openssh-server openssh-clients postfix
[root@slave2 ~]# systemctl enable postfix
[root@slave2 ~]# systemctl start postfix


 

4.更改访问地址:

将external_url 'http://172.16.4.74’本机IP默认80端口;

 

[root@slave2 ~]# vim /etc/gitlab/gitlab.rb
[root@slave2 ~]# head -n 20 /etc/gitlab/gitlab.rb 
## GitLab configuration settings
##! This file is generated during initial installation and **is not** modified
##! during upgrades.
##! Check out the latest version of this file to know about the different
##! settings that can be configured by this file, which may be found at:
##! https://gitlab.com/gitlab-org/omnibus-gitlab/raw/master/files/gitlab-config-template/gitlab.rb.template
 
 
## GitLab URL
##! URL on which GitLab will be reachable.
##! For more details on configuring external_url see:
##! https://docs.gitlab.com/omnibus/settings/configuration.html#configuring-the-external-url-for-gitlab
external_url 'http://172.16.4.74'
 
## Roles for multi-instance GitLab
##! The default is to have no roles enabled, which results in GitLab running as an all-in-one instance.
##! Options:
##!   redis_sentinel_role redis_master_role redis_slave_role geo_primary_role geo_secondary_role
##! For more details on each role, see:
##! https://docs.gitlab.com/omnibus/roles/README.html#roles


 

5.gitlab重新读取配置信息,然后我们先停止gitlab,把gitlab汉化;

[root@slave2 ~]# gitlab-ctl reconfigure
[root@slave2 ~]# gitlab-ctl stop


 

6.下载汉化包,这个东西他给限速了,默认是最新版本的gitlab汉化版,因为我用的gitlab就是最新的,所以直接下载就好;

    还有一种方式是用tar包,我实验完立马添加上;

[root@slave2 ~]# git clone http://gitlab.com/xhang/gitlab.git


 

7.查看本地gitlab VERSION和汉化包的VERSION是否一致,不一致的话,会让gitlab崩溃

[root@slave2 ~]# cat gitlab/VERSION 
11.5.3
[root@slave2 ~]# cat /opt/gitlab/embedded/service/gitlab-rails/VERSION 
11.5.3


 

8.进入我们下载的汉化包中,进行git diff打包;

[root@slave2 ~]# cd gitlab/
[root@slave2 ~]# git diff v11.5.3 v11.5.3-zh > /tmp/11.5.3-zh.diff


 

9.将diff包patch进本地gitlab中;

[root@slave2 ~]# patch -d /opt/gitlab/embedded/service/gitlab-rails -p1 < /tmp/11.5.3-zh.diff


 

10.gitlab重读配置信息并重启;

[root@slave2 ~]# gitlab-ctl reconfigure
[root@slave2 ~]# gitlab-ctl restart


 

11.进入浏览器访问http://HOST_IP(默认80端口,所以不用改);

会让你注册一个8Password;然后登陆进去即可;

image.png

12.更改默认语言设置简体中文然后提交; 

image.png

image.png

image.png

13.然后点回主界面,即为汉化版;

image.png

14.添加访问客户的SSH.key,使其可以免密下载;

ssh免密通信步骤可以移步至此,我们只需要生成密钥即可不用传至主机端;

[root@master ~]# cat /root/.ssh/id_rsa.pub 
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCq4LhWeHNqq34B7j2uL4Ss4EJWyZkWeNHrgsN/2IkaVPatLEJliDHGnPVnKQEejUmApjRofTzJ6eHryzr/7NYNYVoYY08gpVYer2Tct0EWp7V6IA+8OUrMYZYGXLVEBaj/SsTlp23sPZKYUfshGW4wFMBsTGtSNspsSl2MyBnNbO/VDNZUtkx18UwBocBdOLM0ogaT1Taa+/XOtTYs5tP1LWfZA/Wcbwih+9mZFZD55wsyUgIGEgQd9M88lhbHKzjTU9bVUPBOLwQVdcnsd5o/KduNidwY3+Pd+75hDXwE6o4xh5M0+pd6M+KyDMQLN8ZD51P1+91IDvp2W9uEQDCf [email protected]


image.png

我们把.ssh/id_rsa.pub中的内容复制进去;

image.png

image.png

15.我们创建一个Project,从而在客户端进行下载和上传;

image.png

image.png

image.png

image.png

下拉是clone命令描述和push命令描述;

image.png

按照命令一步一步在客户机上操作即可;

 

16.下载gitlab库;

[root@master ~]# git config --global user.name ljy
[root@master ~]# git config --global user.email [email protected]
[root@master ~]# 
[root@master ~]# git clone [email protected]:/root/testProject
正克隆到 'testProject'...
warning: 您似乎克隆了一个空版本库。
[root@master ~]# cd testProject/
[root@master testProject]# ls .git/
branches  config  description  HEAD  hooks  info  objects  refs


17.新建内容,并push到gitlab服务器;

[root@master testProject]# echo "This Is Test Project" > README
[root@master testProject]# 
[root@master testProject]# 
[root@master testProject]# git add README
[root@master testProject]# git commit -m "v0.1" 
[master(根提交) b50abf0] v0.1
 1 file changed, 1 insertion(+)
 create mode 100644 README
[root@master testProject]# git push -u origin master 
Counting objects: 3, done.
Writing objects: 100% (3/3), 217 bytes | 0 bytes/s, done.
Total 3 (delta 0), reused 0 (delta 0)
To [email protected]:/root/testProject
 * [new branch]      master -> master
分支 master 设置为跟踪来自 origin 的远程分支 master。


18.在gitlab服务器上查看内容;

image.png

至此,gitlab服务器的搭建、汉化、下载库、上传库已基本完成,作为一个企业专用的git库来说,是一个相当便捷,易上手的git工具,而且其可视化的内容,更简化了我们的操作;


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章