前言
GitLab 是一个用于仓库管理系统的开源项目,使用Git作为代码管理工具,并在此基础上搭建起来的 web服务。 GitLab和GitHub一样属于第三方基于Git开发的作品,免费且开源(基于MIT协议),与Github类似, 可以注册用户,任意提交你的代码,添加SSHKey等等。不同的是,GitLab是可以部署到自己的服务器 上,数据库等一切信息都掌握在自己手上,适合团队内部协作开发,你总不可能把团队内部的智慧总放 在别人的服务器上吧?简单来说可把GitLab看作个人版的GitHub。
gitlab安装
// 安装相关依赖
yum -y install policycoreutils openssh-server openssh-clients postfix
// 启动ssh服务&设置为开机启动
systemctl enable sshd && sudo systemctl start sshd
// 设置postfix开机自启,并启动,postfix支持gitlab发信功能
systemctl enable postfix && systemctl start postfix
// 开放ssh以及http服务,然后重新加载防火墙列表
firewall-cmd --add-service=ssh --permanent
firewall-cmd --add-service=http --permanent
firewall-cmd --reload
// 如果关闭防火墙就不需要做以上配置
systemctl stop firewalld.service // 关闭
systemctl status firewalld.service // 查看状态
systemctl disable firewalld.service // 开机不启动
// 下载gitlab包,并且安装
// 在线下载安装包:
wget https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el6/gitlab-ce-12.4.2-ce.0.el6.x
86_64.rpm
// 安装:
rpm -i gitlab-ce-12.4.2-ce.0.el6.x86_64.rpm
修改配置文件
// 修改gitlab配置
vi /etc/gitlab/gitlab.rb
sed -i "s@external_url 'http://gitlab.example.com'@external_url 'http://192.168.31.202'@" /etc/gitlab/gitlab.rb
# nginx['listen_port'] = nil
sed -i "s/# nginx.*nil/nginx['listen_port'] = 80/"
gitlab-ctl reconfifigure
gitlab-ctl restart
偷懒专业户脚本来干活
gitlab.sh
// 使用之前先给它加上权限
chmod 777 gilab.sh
./gitlab.sh 或者 sh gitlab.sh
// 执行脚本传入参数,等待完成gitlab就安装完成
// 脚本运行需要gitlab-ce-12.4.2-ce.0.el6.x86_64.rpm 安装包在当前目录下
./gitlab.sh 192.168.31.202 80
gitlab.sh
yum -y install policycoreutils openssh-server openssh-clients postfix
systemctl enable sshd && sudo systemctl start sshd
systemctl enable postfix && systemctl start postfix
systemctl stop firewalld.service
rpm -i gitlab-ce-12.4.2-ce.0.el6.x86_64.rpm
sed -i "s@external_url 'http://gitlab.example.com'@external_url 'http://$1'@" /etc/gitlab/gitlab.rb
sed -i "s/# nginx.*nil/nginx['listen_port'] = $2/" /etc/gitlab/gitlab.rb
sudo gitlab-ctl reconfigure
sudo gitlab-ctl restart