如果没有安CentOS7请看上一篇文章https://www.cnblogs.com/yuanzipeng/p/14386558.html

一、Gitlab是什么

GitLab 是一个用于仓库管理系统的开源项目,使用Git作为代码管理工具,并在此基础上搭建起来的web服务。

可以认为GitLab是免费版的Github,主要功能都差不多。非付费用户在Github上只能创建开源项目,如创建私有项目则需付费,费用也比较昂贵。GitLab有社区版和企业版,社区版是免费,对绝大部分公司来说功能是足够用了 ,在企业内部搭建,可以创建私有项目,老板再也不用担心代码存在别人家的服务器上了。

 

二、在CentOS7上安装Gitlab

服务器要求4G内存,其他不要求,如果内存不足4G访问Gitlab页面可能会出现502错误

1、安装wget:

yum -y install wget

2、下载镜像:

wget https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/gitlab-ce-13.1.2-ce.0.el7.x86_64.rpm

如果报错就用下面这个下载镜像

加上--no-check-certificate

wget --no-check-certificate https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/gitlab-ce-13.1.2-ce.0.el7.x86_64.rpm

三、安装和配置必要的依赖项

1、安装防火墙

yum install firewalld systemd -y

2、开启防火墙

service firewalld  start

3、安装SSH协议

yum install -y curl policycoreutils-python openssh-server

4、设置SSH服务开机自启动

systemctl enable sshd

5、启动SSH服务

systemctl start sshd

6、添加HTTP服务和HTTPS服务到firewalld

firewall-cmd --permanent --add-service=http
firewall-cmd --permanent --add-service=https

7、重启防火墙

systemctl reload firewalld

8、安装Postfix以发送通知邮件

yum install postfix

9、将postfix服务设置成开机自启动

systemctl enable postfix

10、启动postfix

systemctl start postfix

11、安装vim编辑器

yum install vim -y

 

四、安装GitLab

1、安装rpm包

rpm -ivh gitlab-ce-13.1.2-ce.0.el7.x86_64.rpm

 

 

2、修改配置文件

#编辑配置文件
vim  /etc/gitlab/gitlab.rb
#修改访问URL
#格式:external_url 'http://ip:端口'
external_url 'http://192.168.1.1:8080'
#配置时区
gitlab_rails['time_zone'] = 'Asia/Shanghai'

 

3、防火墙开放端口,开放8080端口

firewall-cmd --zone=public --add-port=8080/tcp --permanent

 

4、重启防火墙

firewall-cmd --reload

 

5、查看端口号是否开启

firewall-cmd --query-port=8080/tcp

 

6、重置Gitlab

gitlab-ctl reconfigure

7、启动Gitlab

gitlab-ctl restart

 

8、访问gitlab:

 

 注:首次访问时,会自动进入管理员密码设置页面,管理员默认账户为root。

登录后可进行语言设置:

Settings -> Preferences -> Localization -> Language -> 简体中文

 

Gitlab常用命令

gitlab-ctl start # 启动所有 gitlab 组件;
gitlab-ctl stop # 停止所有 gitlab 组件;
gitlab-ctl restart # 重启所有 gitlab 组件;
gitlab-ctl status # 查看服务状态;
gitlab-ctl reconfigure # 启动服务;
vim /etc/gitlab/gitlab.rb # 修改默认的配置文件;
gitlab-rake gitlab:check SANITIZE=true --trace # 检查gitlab;
gitlab-ctl tail # 查看日志;

 

完全卸载删除gitlab

1、停止gitlab

gitlab-ctl stop


2、卸载gitlab(注意这里写的是gitlab-ce)

rpm -e gitlab-ce


3、查看gitlab进程

ps aux | grep gitlab


4、杀掉第一个进程(就是带有好多.............的进程)

kill -9 18777


杀掉后,在ps aux | grep gitlab确认一遍,还有没有gitlab的进程

5、删除所有包含gitlab文件

find / -name gitlab | xargs rm -rf
posted on 2021-02-09 16:49  袁子弹  阅读(1172)  评论(0编辑  收藏  举报