官方推荐部署服务器配置
GitLab推荐至少2核CPU,只有1核的话,可能会导致GitLab服务卡死,无法正常对外服务。
内存配置主要影响GitLab服务的并发用户数量,对于自己测试使用来说,感觉4GB完全够用了。
一、RPM包安装
1、下载GitLab
官方安装文档:https://about.gitlab.com/installation/
国内软件镜像站:https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/
wget https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/gitlab-ce-13.6.1-ce.0.el7.x86_64.rpm
2、安装GitLab
yum localinstall gitlab-ce-13.6.1-ce.0.el7.x86_64.rpm
注:
yum localinstall是用来安装本地rpm包的命令,首先rpm包要先下载到本地,然后在本地目录执行yum localinstall *.rpm,yum会自动搜寻依赖关系并安装。
yum install会去yum仓库查找相应的软件并安装,仓库中的软件都是解决了依赖关系的
二、YUM安装
1、配置镜像加速
vi /etc/yum.repos.d/gitlab_gitlab-ce.repo
[gitlab-ce]
name=Gitlab CE Repository
baseurl=https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el$releasever/
gpgcheck=0
enabled=1
2、安装GitLab
yum install gitlab-ce
三、配置并启动GitLab
1、修改配置文件
vim /etc/gitlab/gitlab.rb
2、重启GitLab
重新配置并启动
gitlab-ctl reconfigure
gitlab-ctl restart
可以通过 gitlab-ctl status
看服务运行状况
三、访问GitLab
浏览器访问刚才在gitlab.rb文件中external_url一行写的地址
会让先修改密码,8位数以上,修改后使用root用户登陆
四、GitLab常用命令
check-config | 检查在gitlab中是否有任何配置。在指定版本中删除的rb |
---|---|
deploy-page | 安装部署页面 |
diff-config | 将用户配置与包可用配置进行比较 |
remove-accounts | 删除所有用户和组 |
upgrade | 升级 |
service-list | 查看所有服务 |
once | 如果GitLab服务停止了就启动服务,如果已启动就不做任何操作 |
restart | 重启GitLab服务 |
start | 如果GitLab服务停止了就启动服务,如果已启动就重启服务 |
stop | 停止GitLab服务 |
status | 查看GitLab服务状态 |
reconfigure | reconfigure重新配置GitLab并启动 |
五、向GitLab中提交文件
1、在GitLab添加主机密钥
2、初始化本地Git
3、提交文件流程
git add .
git commit -m "Initial commit"
git push -u origin master