Centos7.4使用Gitlab搭建Git服务器

在Centos7上安装Gitlab

直接使用yum安装gitlab时,需要联网下载几百兆的安装文件,非常耗时,所以本文采用手动下载rpm包安装

1、下载gitlib安装包,下载地址:https://packages.gitlab.com/gitlab/gitlab-ce


可以根据自己的需要选择一款安装包,我下载的是gitlab-ce-11.0.3-ce.0.el7.x86_64.rpm

2、将下载好的安装包使用Xftp工具上传到CentOs上去,我这里放到了/home/upload目录下


3、将gitlab安装包移动到/opt目录下,mv gitlab-ce-11.0.3-ce.0.el7.x86_64.rpm /opt


4、安装(官方安装说明:https://www.gitlab.com.cn/installation/)


我的虚拟机是CentOS 7,所以我选择的是CentOs 7上的安装方法

以下是官方安装说明:


上面的命令安装的是ee版,我们安装的是ce版,所以需要将命令中的gitlab-ee换成gitlab-ce。最终整理的安装命令如下:

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
curl https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.rpm.sh | sudo bash
sudo EXTERNAL_URL="http://gitlab.example.com" yum install -y gitlab-ce

因为我们采用的是rpm包安装,所以后面2条命令可以替换为sudo rpm -ivh /opt/gitlab-ce-11.0.3-ce.0.el7.x86_64.rpm

最终安装命令如下:

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.0.3-ce.0.el7.x86_64.rpm
为了省去我们一条一条命令的执行,我们新建一个可执行的安装脚本文件install.sh,并将上述安装命令复制粘贴到脚本文件里。



修改文件install.sh文件的权限,让它可以执行:chmod 755 install.sh


执行安装脚本:./install.sh


安装过程可能需要点时间,耐心等候。。。,当出现如下提示时说明安装成功。


安装完成后,重启

5、配置和启动GitLab

初始化配置GitLab:gitlab-ctl reconfigure

注:第一次预计需要几分钟,耐心等候。。。


6、浏览器访问:http://192.168.0.100


初次登录时需要为gitlab的root用户设置密码,然后就可以用新密码登录了


登录成功


7、常用的几个Gitlab命令

重新应用gitlab的配置:gitlab-ctl reconfigure
启动GitLab服务:gitlab-ctl start
停止GitLab服务:gitlab-ctl stop
重启gitlab服务:gitlab-ctl restart
查看gitlab运行状态:gitlab-ctl status
查看gitlab运行日志:gitlab-ctl tail


参考:http://www.cnblogs.com/kevingrace/p/5985918.html

猜你喜欢

转载自blog.csdn.net/qq_32786873/article/details/80975880