搭建步骤
环境:阿里云主机(CPU: 1核 内存:2 GB (I/O优化) 1Mbps),系统:centos7.4。
-
下载gitlib安装包,下载地址:https://packages.gitlab.com/gitlab/gitlab-ce
也可以使用curl下载(几百兆下下来太慢,放弃) :
curl -s https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.rpm.sh | sudo bash -
下载完成后使用ftp工具上传到服务器;
我使用的是filezilla(下载地址:https://filezilla-project.org/),直接上传到了云主机opt目录 -
安装gitlab;
命令:
sudo yum install -y curl policycoreutils-python openssh-server
sudo systemctl enable sshd
sudo systemctl start sshd
sudo firewall-cmd --permanent --add-service=http
sudo systemctl reload firewalld
sudo yum install postfix
sudo systemctl enable postfix
sudo systemctl start postfix
sudo rpm -ivh /opt/gitlab-ce-11.3.12-ce.0.el7.x86_64.rpm
结果图:
安装完成后,重启 -
初始化配置;
命令:
gitlab-ctl reconfigure
结果图:
-
开启gitlab;
命令:
gitlab-ctl start
结果图:
-
修改端口;
cd var/opt/gitlab/nginx/conf
vim gitlab-http.conf
我把80端口修改成8084 因为80端口已经占用
同时阿里云控制台网络安全组开放8084端口
完毕后浏览器访问ip:port应该可以进入gitlab登陆页面
遇到的问题
访问出现502错误,有两种可能性
1:建议查看8080端口是否被占用!
如果是被占用:
在etc/gitlab/gitlab.rb文件下加入unicorn[‘port’] =8088 ,我的8088这个端口号没被占用
保存退出!
2:原因是gitlab占用内存太多,导致服务器崩溃(我才2g的内存)
解决方案:
使用swap分区(https://yq.aliyun.com/articles/52098)
gitlab常见错误解决办法
1 fail: gitlab-workhorse: runsv not running
systemctl start gitlab-runsvdir.service
systemctl status gitlab-runsvdir.service
gitlab-ctl start
2 Whoops, GitLab is taking too much time to respond.
内存小了,内存至少要2G才行。
3 刚刚安装的gitlab的管理员账户是admin@example.com
第一次设置的密码就是这个账户的密码。
4 服务器ip修改后,project页面的ip做相应修改的方法
cd /opt/gitlab/embedded/service/gitlab-rails/config
gitlab.yml
gitlab-ctl restart
</div>