一、在Centos7上安装Gitlab
之前尝试过直接yum安装,但服务器从该yum源下载实在太慢,故手动下载rpm包安装。
1.先安装相关依赖
yum -y install policycoreutils openssh-server openssh-clients postfix
2.启动postfix,并设置开机自启动
目的:支持gitlab邮件发送
systemctl enable postfix && systemctl start postfix
如果报错:Job for postfix.service failed because the control process exited with error code. See "systemctl status postfix.service" and "journalctl -xe" for details.
修改 /etc/postfix/main.cf的设置 即可
inet_protocols = ipv4
inet_interfaces = all
3.下载并安装Gitlab社区版RPM包
我的下载路径如下:gitlab-ce-10.5.2-ce.0.el7.x86_64.rpm
注意根据自己的linux系统选择合适的包
再输入:rpm -ivh gitlab-ce-10.5.2-ce.0.el7.x86_64.rpm 安装完毕
如果报错:
warning: gitlab-ce-10.1.0-ce.0.el7.x86_64.rpm: Header V4 RSA/SHA1 Signature, key ID f27eab47: NOKEY
error: Failed dependencies:
policycoreutils-python is needed by gitlab-ce-10.1.0-ce.0.el7.x86_64
安装gitlab依赖 后重新安装
yum install policycoreutils-python
4.修改Gitlab访问URL配置
cd /opt/gitlab/embedded/service/gitlab-rails/config
修改gitlab.yml文件
[root@localhost config]# vim gitlab.yml
gitLab:
host:11.11.11.11
port:80
5.重置并启动Gitlab
重置:gitlab-ctl reconfigure
注:第一次预计需要几分钟 
启动:gitlab-ctl restart 
6.浏览器访问Gitlab
直接通过域名端口访问:http://10.3.1.12:8082
我在此处出现问题:
1.502错误
排查过程:
首先保证Gitlab可用运行内存大于4G,端口未被占用
再赋予权限:chmod -R 755 /var/log/gitlab
再重置重启
访问后仍然可能遇到502,不过我刷新2次就一切ok了。。
2.进去后会提醒你重新设置密码,此处报错
用户名默认为root,密码自己设置
无论怎么样修改密码都报这个错
然后我重置重启,结果ok了。。
二、在Gitlab里配置项目
先本地Git导入项目到Gitlab,再通过IDEA导入GItlab上的项目
1.配置Gitlab用户邮箱
在User Settings - Emails 中添加邮箱并confirm
2.添加开发电脑的key到Gitlab上
先确保你的开发电脑上已安装Git,并做好基本准备,这个不再多说
打开Git Bash生成key:
在bash中输入ssh-keygen -t rsa -C “yourEmail@example.com” 即可,后面输入自己的邮箱
再在 ~/.ssh/id_rsa.pub中复制其中所有内容,在User Settings - SSH Keys中添加复制内容

3.将开发电脑上已存在的项目导入到Gitlab上
先在Gitlab上创建一个空项目-test 
再打开本地Git Bash,配置全局的 user.name 和 user.email:
-
git config --global user.name "root" -
git config --global user.email "yuanjie@397.com"
- 1
- 2
首先cd到你需要导入的项目目录下,再执行导入命令:
-
git init -
git remote add origin git@10.3.1.12:root/test.git -
git add . -
git commit -m "测试-test" -
git push -u origin master
- 1
- 2
- 3
- 4
- 5
至此,可以到浏览器刷新test项目,发现导入成功 
4.在IDEA上clone项目
根据图示依次操作即可:

至此,Gitlab搭建及初步测试完成!

本文详细介绍了在CentOS7上手动安装GitLab的过程,包括安装依赖、配置URL、解决常见问题等步骤,并提供了如何在GitLab中配置项目的具体指导。
2万+

被折叠的 条评论
为什么被折叠?



