兩種方式搭建gitlab服務(wù)
通過docker鏡像來搭建服務(wù)
1. 獲取國內(nèi)鏡像
docker pull registry.cn-hangzhou.aliyuncs.com/lab99/gitlab-ce-zh
2. 創(chuàng)建需要的文件夾
mkdir -p /home/software/gitlab/etc
mkdir -p /home/software/gitlab/logs
mkdir -p /home/software/gitlab/data
3. 生成容器
docker run --detach --publish 8443:443 --publish 8090:80 --publish 8022:22 --name gitlab --restart always --hostname 192.168.1.1 -v /home/software/gitlab/etc:/etc/gitlab -v /home/software/gitlab/logs:/var/log/gitlab -v /home/software/gitlab/data:/var/opt/gitlab -v /etc/localtime:/etc/localtime:ro --privileged=true registry.cn-hangzhou.aliyuncs.com/lab99/gitlab-ce-zh
4.參數(shù)描述
docker run \
--detach \
--publish 8443:443 \ # 映射https端口, 不過本文中沒有用到
--publish 8090:80 \ # 映射宿主機(jī)8090端口到容器中80端口
--publish 8022:22 \ # 映射22端口, 可不配
--name gitlab \
--restart always \
--hostname 192.168.1.1 \ # 局域網(wǎng)宿主機(jī)的ip, 如果是公網(wǎng)主機(jī)可以寫域名
-v /home/software/gitlab/etc:/etc/gitlab \ # 掛載gitlab的配置文件
-v /home/software/gitlab/logs:/var/log/gitlab \ # 掛載gitlab的日志文件
-v /home/software/gitlab/data:/var/opt/gitlab \ # 掛載gitlab的數(shù)據(jù)
-v /etc/localtime:/etc/localtime:ro \ # 保持宿主機(jī)和容器時(shí)間同步
--privileged=true registry.cn-hangzhou.aliyuncs.com/lab99/gitlab-ce-zh # 在容器中能以root身份執(zhí)行操作
5.查看狀態(tài)
docker ps
6.在瀏覽器訪問gitlab
- 像例子中的話就可以訪問192.168.1.1:8090,如果頁面出現(xiàn)502錯(cuò)誤,就多等待會(huì)荠列,啟動(dòng)比較慢昔馋,然后啟動(dòng)起來后双泪,第一次訪問使用root賬號訪問,會(huì)讓你設(shè)置密碼万哪,設(shè)置后馅扣,能正常登陸就搭建成功了。
通過rpm安裝包來在lunix系統(tǒng)上搭建gitlab服務(wù)
1.下載安裝包废菱,并上傳到lunix服務(wù)器上
2.安裝軟件
#gitlab-ce-10.0.0-ce.0.el7.x86_64.rpm 為某一個(gè)具體版本的gitlab安裝包
rpm -i gitlab-ce-10.0.0-ce.0.el7.x86_64.rpm
- 看到下面的貓頭就是安裝成功了
[root@stupidTrump ~]# rpm -ivh download.rpm
warning: download.rpm: Header V4 RSA/SHA1 Signature, key ID f27eab47: NOKEY
Preparing... ################################# [100%]
Updating / installing...
1:gitlab-ce-11.3.13-ce.0.el7 ################################# [100%]
It looks like GitLab has not been configured yet; skipping the upgrade script.
*. *.
*** ***
***** *****
.****** *******
******** ********
,,,,,,,,,***********,,,,,,,,,
,,,,,,,,,,,*********,,,,,,,,,,,
.,,,,,,,,,,,*******,,,,,,,,,,,,
,,,,,,,,,*****,,,,,,,,,.
,,,,,,,****,,,,,,
.,,,***,,,,
,*,.
_______ __ __ __
/ ____(_) /_/ / ____ _/ /_
/ / __/ / __/ / / __ `/ __ \
/ /_/ / / /_/ /___/ /_/ / /_/ /
\____/_/\__/_____/\__,_/_.___/
Thank you for installing GitLab!
GitLab was unable to detect a valid hostname for your instance.
Please configure a URL for your GitLab instance by setting `external_url`
configuration in /etc/gitlab/gitlab.rb file.
Then, you can start your GitLab instance by running the following command:
sudo gitlab-ctl reconfigure
For a comprehensive list of configuration options please see the Omnibus GitLab readme
https://gitlab.com/gitlab-org/omnibus-gitlab/blob/master/README.md
3.修改配置
##修改gitlab的配置文件
[root@stupidTrump ~]# vim /etc/gitlab/gitlab.rb
- 修改external_url的值
external_url 'http:當(dāng)前l(fā)unix服務(wù)器的ip:端口'
- 端口默認(rèn)是8080也可配置為其他的,如果開啟防火墻需要把對應(yīng)端口開放
4.重置配置
gitlab-ctl reconfigure
5.啟動(dòng)服務(wù)
- 重置配置的時(shí)間比較久抖誉,等配置重置后啟動(dòng)服務(wù)
gitlab-ctl start
6.在瀏覽器訪問剛才配置的ip:端口
- 例如訪問192.168.1.1:8090,如果頁面出現(xiàn)502錯(cuò)誤殊轴,就多等待會(huì),啟動(dòng)比較慢袒炉,然后啟動(dòng)起來后旁理,第一次訪問使用root賬號訪問,會(huì)讓你設(shè)置密碼我磁,設(shè)置后孽文,能正常登陸就搭建成功了驻襟。