Centos7搭建Gitlab服务器

GitLab介绍

GitLab 是一个用于仓库管理系统的开源项目,使用Git作为代码管理工具,并在此基础上搭建起来的Web服务。

官方网站:https://about.gitlab.com/

安装配置需求:2.5GB的存储空间(SSD更好),推荐4核CPU(自测或使用人不多,2核即可),最小内存4G(必需)

详见官方文档:https://docs.gitlab.cn/jh/install/requirements.html

两种常见安装方式:shell命令安装和在docker下安装

shell命令安装

1 安装依赖

sudo yum install -y curl policycoreutils-python openssh-server perl
sudo systemctl enable sshd
sudo systemctl start sshd

2 配置镜像

curl -fsSL https://packages.gitlab.cn/repository/raw/scripts/setup.sh | /bin/bash

3 开始安装

sudo EXTERNAL_URL="http://192.168.3.101" yum install -y gitlab-jh

ip改成你自己的。

4 登录使用

访问 http://192.168.3.101

用户名:root
密码存在下面文件中,登录后需要改密码,不然24小时之后密码失效

cat /etc/gitlab/initial_root_password

gitlab常用命令

gitlab-ctl start                  # 启动所有 gitlab 组件;
gitlab-ctl stop                   # 停止所有 gitlab 组件;
gitlab-ctl restart                # 重启所有 gitlab 组件;
gitlab-ctl status                 # 查看服务状态;
gitlab-ctl reconfigure            # 启动服务;
vi /etc/gitlab/gitlab.rb         # 修改默认的配置文件;
gitlab-ctl tail                   # 查看日志;

在docker下安装

1 安装docker (已安装请忽略)

docker要求系统内核至少在3.10以上

uname -r 命令可查看系统内核版本

[root@localhost ~]# uname -r
3.10.0-957.el7.x86_64

1.1 更新yum源(生产环境慎重使用)

yum update

1.2 安装依赖

yum install -y yum-utils device-mapper-persistent-data lvm2

1.3 添加镜像

//国外镜像
yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
//阿里镜像(推荐)
yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo

1.4 查看源中可使用版本

yum list docker-ce --showduplicates | sort -r

1.5 安装(不指定版本默认最新)

yum install docker

1.6 配置开机启动

systemctl start docker
systemctl enable docker

2 使用docker安装gitlab

2.1 拉取镜像

docker pull gitlab/gitlab-ce

2.2 启动容器

docker run -d \
	-p 443:443 -p 80:80 \
	--name gitlab \
	--restart always \
	-v /usr/local/gitlab/config:/etc/gitlab \
	-v /usr/local/gitlab/logs:/var/log/gitlab \
	-v /usr/local/gitlab/data:/var/opt/gitlab \
	--shm-size 256m \
	gitlab/gitlab-ce

GitLab产品将分为三个发行版:CE(社区版),EE(企业版)和JH(JiHu版)。CE发行版将继续在全球范围内提供。EE发行版仅在中国境外出售。JH发行版仅在中国销售。

2.3 查看已存在的容器

docker ps -a

2.4 访问自建gitlab

http://192.168.3.101 (ip改成你自己的。)

首次运行,可能出现502,不要慌

  1. 确认虚拟机内存不少于4G
  2. 稍微再等等,启动需要一段时间,等会刷新一下就好了

用户名:root

密码存在容器内下面文件中,登录后需要改密码,不然24小时之后密码失效

cat /etc/gitlab/initial_root_password

2.5 修改密码

如果忘记了密码,可以进入容器内docker exec -it gitlab bash,依次执行下面即可

gitlab-rails console -e production
user = User.where(id: 1).first
user.password = '123456'
user.password_confirmation = '123456'
user.save!
exit
posted @   淘气小饼干  阅读(396)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 分享4款.NET开源、免费、实用的商城系统
· 全程不用写代码,我用AI程序员写了一个飞机大战
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
· 上周热点回顾(2.24-3.2)
点击右上角即可分享
微信分享提示