两种方式搭建gitlab服务
通过docker镜像来搭建服务
1. 获取国内镜像
docker pull registry.cn-hangzhou.aliyuncs.com/lab99/gitlab-ce-zh
2. 创建需要的文件夹
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.参数描述
docker run \
--detach \
--publish 8443:443 \ # 映射https端口, 不过本文中没有用到
--publish 8090:80 \ # 映射宿主机8090端口到容器中80端口
--publish 8022:22 \ # 映射22端口, 可不配
--name gitlab \
--restart always \
--hostname 192.168.1.1 \ # 局域网宿主机的ip, 如果是公网主机可以写域名
-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的数据
-v /etc/localtime:/etc/localtime:ro \ # 保持宿主机和容器时间同步
--privileged=true registry.cn-hangzhou.aliyuncs.com/lab99/gitlab-ce-zh # 在容器中能以root身份执行操作
5.查看状态
docker ps
6.在浏览器访问gitlab
- 像例子中的话就可以访问192.168.1.1:8090,如果页面出现502错误,就多等待会,启动比较慢,然后启动起来后,第一次访问使用root账号访问,会让你设置密码,设置后,能正常登陆就搭建成功了。
通过rpm安装包来在lunix系统上搭建gitlab服务
1.下载安装包,并上传到lunix服务器上
2.安装软件
#gitlab-ce-10.0.0-ce.0.el7.x86_64.rpm 为某一个具体版本的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:当前lunix服务器的ip:端口'
- 端口默认是8080也可配置为其他的,如果开启防火墙需要把对应端口开放
4.重置配置
gitlab-ctl reconfigure
5.启动服务
- 重置配置的时间比较久,等配置重置后启动服务
gitlab-ctl start
6.在浏览器访问刚才配置的ip:端口
- 例如访问192.168.1.1:8090,如果页面出现502错误,就多等待会,启动比较慢,然后启动起来后,第一次访问使用root账号访问,会让你设置密码,设置后,能正常登陆就搭建成功了。