GitLab是一个开源的版本管理系统,提供了类似于GitHub的源代码浏览,管理缺陷和注释等功能,你可以将代码免费托管到GitLab.com,而且不限项目数量和成员数; 最吸引人的一点是允许在自己的服务器上搭建GitLab CE(社区免费版)版本,方便内部团队协作开发和代码管理; 本文将介绍如何在Linux服务器上使用包管理器搭建GitLab CE版本,以及一些基本的配置;
GitLab官网: https://about.gitlab.com/installation/
Gmail: https://about.gitlab.com/installation/
配置国内的软件源,请详见 https://www.xiaocoder.com/2017/02/21/resource-1/ ; 需要配置CentOS Base源与epel源;
$ vim /etc/yum.repos.d/gitlab-ce.repo
[gitlab-ce]
name=Gitlab CE Repository
baseurl=https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el$releasever/
gpgcheck=0
enabled=1
$ yum makecache fast && yum update -y
$ yum install -y postfix
$ systemctl enable postfix
$ systemctl start postfix
GitLab自带了Web服务器(nginx),若需要使用服务器已有的Nginx,需要额外的配置;
$ yum install -y gitlab-ce
配置国内的软件源,请详见《CentOS/Ubuntu的国内软件源》;
在服务器上安装Docker CE,安装指南请参考《在Linux上安装Docker》;
官网资源: https://docs.gitlab.com/ce/install/docker.html
external_url 'http://ip_address:new-port'
Gmail
请自行更改smtp_user_name与smtp_password;
gitlab_rails['smtp_enable'] = true gitlab_rails['smtp_address'] = "smtp.gmail.com" gitlab_rails['smtp_port'] = 587 gitlab_rails['smtp_user_name'] = "smtp user" gitlab_rails['smtp_password'] = "smtp password" gitlab_rails['smtp_domain'] = "smtp.gmail.com" gitlab_rails['smtp_authentication'] = "login" gitlab_rails['smtp_enable_starttls_auto'] = true gitlab_rails['smtp_tls'] = false gitlab_rails['smtp_openssl_verify_mode'] = 'peer'
QQ exmail(腾讯企业邮箱)
请自行更改smtp_user_name、smtp_password与gitlab_email_from;
gitlab_rails['smtp_enable'] = true gitlab_rails['smtp_address'] = "smtp.exmail.qq.com" gitlab_rails['smtp_port'] = 465 gitlab_rails['smtp_user_name'] = "smtp user" gitlab_rails['smtp_password'] = "smtp password" gitlab_rails['smtp_domain'] = "smtp.exmail.qq.com" gitlab_rails['smtp_authentication'] = "login" gitlab_rails['smtp_enable_starttls_auto'] = true gitlab_rails['smtp_tls'] = true gitlab_rails['gitlab_email_from'] = 'smtp user'
Outlook
请自行更改smtp_user_name、smtp_password与gitlab_email_from;
gitlab_rails['smtp_enable'] = true gitlab_rails['smtp_address'] = "smtp-mail.outlook.com" gitlab_rails['smtp_port'] = 587 gitlab_rails['smtp_user_name'] = "smtp user" gitlab_rails['smtp_password'] = "smtp password" gitlab_rails['smtp_domain'] = "smtp-mail.outlook.com" gitlab_rails['smtp_authentication'] = "login" gitlab_rails['smtp_enable_starttls_auto'] = true gitlab_rails['smtp_openssl_verify_mode'] = 'peer' gitlab_rails['gitlab_email_from'] = 'smtp user'
其他邮件服务
其他邮件服务的设置,请参照官网: https://docs.gitlab.com/omnibus/settings/smtp.html ,此处就不再赘述了;
测试操作
$ gitlab-rails console
irb(main):001:0> Notify.test_email('ben_wyx@outlook.com', 'Hello', 'Hello, World').deliver_now
每一次修改配置文件,都要执行此操作;
$ gitlab-ctl reconfigure
首次访问,http://172.18.20.100,页面会提示设置管理员的密码; 管理员:root,密码: