安装前准备
- VMWare虚拟机
- 版本推荐CentOS7(我当前使用的版本是CentOS7)
- 配置好Linux的IP地址
- 保证Gitlab可用运行内存大于4G(否则虚拟机会变得非常消耗磁盘读写)
- 安装依赖软件
1 | yum -y install policycoreutils openssh-server openssh-clients postfix |
设置postfix开机自启,并启动,postfix支持gitlab发信功能
1 | systemctl enable postfix && systemctl start postfix |
安装GitLab
下载GitLab安装包
国内GitLab安装包地址:https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/
- /el6/ CentOS 6系统目录
- /el7/ CentOS 7系统目录
- /el8/ CentOS 8系统目录
我下载的是 11.3.3 版本,大家可以根据自己需求选择下载。
进入/usr/local/src/
目录下载GitLab安装包
1 | [root@localhost src]# wget https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/gitlab-ce-11.3.3-ce.0.el7.x86_64.rpm |
安装GitLab安装包
1 | [root@localhost src]# rpm -i gitlab-ce-11.3.3-ce.0.el7.x86_64.rpm |
修改GitLab配置文件
- 修改GitLab配置文件指定服务器ip和自定义端口
1 | vim /etc/gitlab/gitlab.rb |
修改成如下(IP地址+端口号):
1 | external_url 'http://192.168.100.14:8801' |
1 | ## GitLab configuration settings |
- 重置并重启GitLab
重置
注:第一次预计需要几分钟
1 | # gitlab-ctl reconfigure |
居然用了11分钟…
1 | Running handlers: |
重启
1 | # gitlab-ctl restart |
访问GitLab页面
如果没有开启8801端口,是无法访问滴
1 | /sbin/iptables -I INPUT -p tcp --dport 8801 -j ACCEPT |
浏览器输入 http://192.168.100.14:8801
如果访问的时候报502错误,修改权限
1 | chmod -R 755 /var/log/gitlab |
修改root密码
第一次访问时,会自动跳转到修改root密码的界面,填写好密码确认即可。愉快地开始管理你的项目吧!