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
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端口,所以不用改);
會讓你註冊一個8位Password;然後登陸進去即可;
12.更改默認語言設置爲簡體中文然後提交;
13.然後點回主界面,即爲漢化版;
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]
我們把.ssh/id_rsa.pub中的內容複製進去;
15.我們創建一個Project,從而在客戶端進行下載和上傳;
下拉是clone命令描述和push命令描述;
按照命令一步一步在客戶機上操作即可;
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服務器上查看內容;
至此,gitlab服務器的搭建、漢化、下載庫、上傳庫已基本完成,作爲一個企業專用的git庫來說,是一個相當便捷,易上手的git工具,而且其可視化的內容,更簡化了我們的操作;