CentOS7上安装配置GitLab(一)

    虽然GitHub已经很好了,但是我们必须联上公网才可以使用并且如果不付费的话,你的代码在网上就是公开的!但是在企业环境中,我们公司的代码不希望被公开并且也不想付费给GitHub,这时怎么办呢?我们可以用GitLab搭建企业自己的Git服务器,而且由于是在局域网内传输速度也是可以保证的,让我们开始吧!

一、安装依赖包

虚拟机配置:2vCPU+2Gb(MEM)+2Gb(SWAP)

操作系统版本:CentOS7.2

# 安装依赖
yum install curl policycoreutils openssh-server openssh-clients policycoreutils-python
systemctl enable sshd 
systemctl start sshd
# 使用postfix发送邮件通知
yum install postfix 
systemctl enable postfix 
systemctl start postfix 
# 打开防火墙端口,如果需要
firewall-cmd --permanent --add-service=http 
systemctl reload firewalld


二、下载GitLab包

centos 6系统的下载地址:https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el6

centos 7系统的下载地址:https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7

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

Note:你也可以将上面URL配置成yum repo,直接通过yum安装更新GitLab


三、配置GitLab

扫描二维码关注公众号,回复: 1102654 查看本文章

GitLab的相关参数配置都存在/etc/gitlab/gitlab.rb文件中,每次配置完成之后需要执行“gitlab-ctl reconfigure”,进行重新配置才能生效。

# vim /etc/gitlab/gitlab.rb
external_url 'http://192.168.88.128' 

# gitlab-ctl reconfigure


四、通过HTTP访问GitLab


浏览器中打开URL: http://192.168.88.128第一次登陆会跳转到修改root用户密码页面,打开WEB页面之后的操作就跟GitHub没有什么区别了!


五、GitLab的常用命令

语法:

gitlab-ctl command (subcommand)

start	启动所有服务

stop	关闭所有服务

restart	重启所有服务

status	查看所有服务状态

tail	查看日志信息

service-list	列举所有启动服务

graceful-kill	平稳停止一个服务

help	        帮助

reconfigure	修改配置文件之后,需要重新加载下

show-config	查看所有服务配置文件信息

uninstall	卸载这个软件

cleanse	        删除gitlab数据,重新白手起家

示例:

gitlab-ctl start	#启动所有服务

gitlab-ctl start nginx	#启动单独一个服务

gitlab-ctl tail	        #查看日志,类似tail -f

gitlab-ctl tail nginx	#查看一个应用的日志

gitlab-ctl show-config	#显示所有服务配置文件

gitlab-ctl uninstall	#卸载gitlab


猜你喜欢

转载自blog.51cto.com/daibaiyang119/2121764