效果图
前言
gitlab全球出名,包含免费的社区版CE、收费的企业版EE,在国内安装速度一般;
gitlab极狐版是中国特供版,用起来就跟CE一样,推荐国内使用~
实现步骤 - 安装&配置
- 先准备好gitlab服务对外的访问地址,例如:
http://3.3.3.3:65432
http://your-domain-name/
- 安装依赖
sudo yum install -y curl policycoreutils-python openssh-server perl sudo systemctl enable sshd sudo systemctl start sshd sudo firewall-cmd --permanent --add-service=http sudo firewall-cmd --permanent --add-service=https sudo systemctl reload firewalld
- 安装gitlab极狐版
安装完成效果图:curl -fsSL https://packages.gitlab.cn/repository/raw/scripts/setup.sh | /bin/bash sudo EXTERNAL_URL="https://gitlab.example.com" yum install -y gitlab-jh
- 安装完毕,提示默认root密码保存在/etc/gitlab/initial_root_password,先不急着改密码
- 开始配置gitLab (此时gitlab未启动)
我们假设服务器地址+端口号是 http://3.3.3.3:65432
1)修改文件/etc/gitlab/gitlab.rb
external_url 'http://3.3.3.3:65432'
2)修改文件/opt/gitlab/embedded/service/gitlab-rails/config/gitlab.yml## GitLab settings gitlab: ## Web server settings (note: host is the FQDN, do not include http://) host: 3.3.3.3 port: 65432 https: false
3)配置完毕
- 开始重新启动gitlab服务:
sudo gitlab-ctl reconfigure sudo gitlab-ctl restart
- 打开浏览器,输入“http://3.3.3.3:65432”即可进入gitlab登录页
- 默认账户root,默认密码存放在/etc/gitlab/initial_root_password,登录root
- (必须)修改root密码
- 修改语言为中文:
- 空运载情况下,内存也是占满。。。接近。。。
实现步骤 - 创建用户 & 创建Repo & 推推拉拉
- 安装git
sudo yum install git
- 假设公司有两个部门,技术部(dept_tech) + 运营部(dept_oper)
- 使用root登录gitlab,创建两个组
- 然后点击群组“技术部”,左边的“群组信息” 》 成员
- 邀请成员 进入此群组:
逐个邀请
- 邀请已发,实际上,没有安装email服务的话,是发不了邮件的
- 用户收到邀请后,回到我们的gitlab的登录页,
选择注册,注册成功但无法直接登录,
报错“Your account is pending approval from your GitLab administrator and hence blocked. Please contact your GitLab administrator if you think this is an error.”,
解决方案:
root用户主动接受 用户的注册请求
用户新建完毕
- 普通用户账号已新建,已知登录名+登陆密码
- 设置git的全局设置:
git config --global user.name "dev_rudon" git config --global user.email "dev1@xx.com"
- 在普通用户dev_rudon的机子上生成公钥密钥,并提交到gitlab,否则无法拉取仓库:
ssh-keygen -t rsa -C "你的邮箱"
然后获取公钥内容,提交到gitlab:cat ~/.ssh/id_rsa.pub
- 开始登录普通用户,创建Repo
- Repo已创建,先尝试拉取
git clone git@localhost:dept_dev/my_app_test.git
cd my_app_test/
git switch -c main
touch README.md
git add README.md
git commit -m "add README"
- 推送
git push
相关链接
GitLab 在全球范围内有三个版本:社区版(CE)、企业版(EE)、极狐版 (JH) https://gitlab.cn/is-it-any-good/
GitLab下载安装_GitLab最新中文免费版下载安装-极狐GitLab极狐GitLab中文官方网站提供GitLab最新中文版官方下载渠道,下载安装即可免费试用30天。Linux安装包已捆绑了运行极狐GitLab所需的所有服务与工具。https://gitlab.cn/install/