如果没有现成的云服务器, 可以通过虚拟机VirtualBox安装CentOS7 体验本次安装过程
VirtualBox创建CentOS7虚拟机简洁教程 https://www.v2fy.com/p/2021-08-10-virtualbox-centos7-1628588525000
安装docker
sudo yum install -y yum-utils
sudo yum-config-manager \
--add-repo \
https://download.docker.com/linux/centos/docker-ce.repo
sudo yum remove docker \
docker-client \
docker-client-latest \
docker-common \
docker-latest \
docker-latest-logrotate \
docker-logrotate \
docker-engine
sudo yum install -y docker-ce-18.09.1 docker-ce-cli-18.09.1 containerd.io
测试docker是否安装成功
sudo systemctl start docker
sudo docker run hello-world

设置docker开机启动,
sudo systemctl enable docker

安装 docker-compose
sudo curl -L "https://github.com/docker/compose/releases/download/1.29.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
sudo ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose
设置gitlab 工作目录
mkdir -p /srv/gitlab
chmod 777 -R /srv
export GITLAB_HOME=/srv/gitlab
将配置信息写入docker-compose.yml
cat <<EOF >/opt/docker-compose.yml
web:
image: 'gitlab/gitlab-ce:14.0.7-ce.0'
restart: always
hostname: 'gitlab.example.com'
environment:
GITLAB_OMNIBUS_CONFIG: |
external_url 'http://gitlab.example.com:8929'
gitlab_rails['gitlab_shell_ssh_port'] = 2224
ports:
- '8929:8929'
- '2224:22'
volumes:
- '$GITLAB_HOME/config:/etc/gitlab'
- '$GITLAB_HOME/logs:/var/log/gitlab'
- '$GITLAB_HOME/data:/var/opt/gitlab'
EOF
这个配置文件里面的 gitlab.example.com
是一个示例, 可以替换为ip 或 拥有的域名, 如果是本地测试用, 可以往/etc/ hosts
内添加以下内容
192.168.56.101 gitlab.example.com
添加执行权限
sudo chmod 755 /opt/docker-compose.yml
启动
cd /opt
docker-compose pull
docker-compose up -d
这个启动过程比较漫长

等待期间,通过浏览器访问服务,会出现502的页面,多等一会儿就好了

喝完一杯咖啡,这个服务就启动好了!

在外部访问 http://192.168.56.101:8929/

开始使用
- 注册新用户

- 填写信息并注册

- 填写信息后,会自动跳转到登录页面

但现在是无法登陆的。
我们需要先登陆管理员用户, 进行授权
- 进入容器
docker exec -it 容器id bash

- 查看登录密码
cat /etc/gitlab/initial_root_password

root登录密码需要记下来,或者通过运行cp /etc/gitlab/initial_root_password /etc/gitlab/initial_root_password_backup
, 做个备份, 登录成功后, 这个initial_root_password文件会在24小时后自动删除
查看完成后, 可以使用 Ctrl + p + q
安全离开容器的bash
- 登录管理员用户

- 登录成功



- 此刻我们可以使用新用户 zhaoolee直接登陆了

- 将界面修改为中文

刷新页面, 发现大部分页面内容完成了汉化

新建项目

- 创建空白项目



到了这一步gitlab的各种操作和github的操作非常类似了。
小结
gitlab可以做为个人的知识库,所有github上可以玩的骚操作,都可以放到gitlab完成,功能完备,使用免费,且数据安全有保证。
网友评论