gitlab

1.什么是gitlab

gitlab是一个开源分布式版本控制系统

开发语言为ruby

功能:管理项目代码,版本控制,代码复用与查找

2.gitlab和github的不同

1.github分布在线代码托管仓库,个人版本可直接在线免费使用,企业版本收费且需要服务器安装

2.gitlab分布式在线代码托管软件,分社区免费版本与企业收费版本,都需要服务器安装

3.gitlab的优势和应用场景

1.开源免费,适合中小型公司将代码放置在该系统
2.差异化的版本管理,离线同步以及强大分支管理功能
3.便捷的GUI操作界面以及强大账户权限管理功能
4.集成度很高,能够集成绝大多数的开发工具
5.支持内置HA,保证在高并发下仍旧实现高可用性

4.gitlab的主要服务构成

1.nginx静态web服务器
2.gitlab-workhorse轻量级的反向代理服务器
3.gitlab-shell用于处理git命令和修改authorized keys列表
4.logrotate日志文件管理工具
5.postgresql数据库
6.redis缓存服务器

5.gitlab安装管理配置

<1>.安装gitlab前系统预配置准备工作
A.关闭firewalld防火墙
    systemctl stop firewalld
    systemctl disable firewalld

B.关闭selinux并重启系统
   vim /etc/sysconfig/selinux

   SELINUX=disabled

   reboot


<2>.安装Omnibus gitlab-ce package
A.安装gitlab组件
yum -y install curl policycoreutils openssh-server openssh-clients postfix 

B.配置yum仓库
curl -sS https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.rpm.sh | sudo bash

C.启动postfix邮件服务器
systemctl start postfix && systemctl enable postfix

D.安装gitlab-ce社区版本
yum install -y gitlab-ce

<3>.omnibus gitlab等相关配置初始化并完成安装 A.证书创建与配置加载 B.nginx ssl代理服务配置 C.初始化gitlab相关服务并完成安装

 6.具体步骤

1.关闭防火墙

systemctl stop firewalld

systemctl disable firewalld 


2.关闭selinux
vim /etc/selinux/config 

SELINUX=disabled  #修改为这样

3.安装Omnibus gitlab-ce package
yum install curl policycoreutils openssh-server openssh-clients postfixs -y


4.配置yum仓库
curl -sS https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.rpm.sh | sudo bash

5.
启动postfix邮件服务器
systemctl start postfix && systemctl enable postfix


6.
安装gitlab-ce社区版本
yum install -y gitlab-ce

7.
证书创建与配置加载
mkdir -p /etc/gitlab/ssl

8. 证书创建与配置加载
openssl genrsa -out "/etc/gitlab/ssl/gitlab.example.com.key" 2048

req -new -key "/etc/gitlab/ssl/gitlab.example.com.key" -out "/etc/gitlab/ssl/gitlab.example.com.csr"

You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----
Country Name (2 letter code) [XX]:cn
State or Province Name (full name) []:bj
Locality Name (eg, city) [Default City]:bj
Organization Name (eg, company) [Default Company Ltd]:
Organizational Unit Name (eg, section) []:
Common Name (eg, your name or your server's hostname) []:gitlab.example.com
Email Address []:admin@example.com

Please enter the following 'extra' attributes
to be sent with your certificate request
A challenge password []:123456
An optional company name []:

此时在查看生成了证书

root@yanglin7 ~]# ll /etc/gitlab/ssl/
总用量 8
-rw-r--r-- 1 root root 1074 3月 3 18:31 gitlab.example.com.csr
-rw-r--r-- 1 root root 1679 3月 3 18:25 gitlab.example.com.key

 

openssl x509 -req -days 365 -in "/etc/gitlab/ssl/gitlab.example.com.csr" -signkey "/etc/gitlab/ssl/gitlab.example.com.key" -out "/etc/gitlab/ssl/gitlab.example.com.crt"

 

openssl dhparam -out /etc/gitlab/ssl/dhparams.pem 2048

 

[root@yanglin7 ~]# cd /etc/gitlab/ssl/
[root@yanglin7 ssl]# ll
总用量 16
-rw-r--r-- 1 root root 424 3月 3 21:17 dhparams.pem
-rw-r--r-- 1 root root 1281 3月 3 21:01 gitlab.example.com.crt
-rw-r--r-- 1 root root 1074 3月 3 18:31 gitlab.example.com.csr
-rw-r--r-- 1 root root 1679 3月 3 18:25 gitlab.example.com.key

 

[root@yanglin7 ssl]# chmod 600 *
[root@yanglin7 ssl]# ll
总用量 16
-rw------- 1 root root 424 3月 3 21:17 dhparams.pem
-rw------- 1 root root 1281 3月 3 21:01 gitlab.example.com.crt
-rw------- 1 root root 1074 3月 3 18:31 gitlab.example.com.csr
-rw------- 1 root root 1679 3月 3 18:25 gitlab.example.com.key

 

vim /etc/gitlab/gitlab.rb

改以下五行

external_url 'https://gitlab.example.com'

nginx['redirect_http_to_https'] = true   #改为true并去掉#号

# nginx['ssl_certificate'] = "/etc/gitlab/ssl/gitlab.example.com.crt"  #改后面的crt名字

# nginx['ssl_certificate_key'] = "/etc/gitlab/ssl/gitlab.example.com.key"  #改后面的key名字

# nginx['ssl_dhparam'] = /etc/gitlab/ssl/dhparams.pem    #改后面的pem名字

 

 

gitlab-ctl reconfigure    #执行此命令

 

vim /var/opt/gitlab/nginx/conf/gitlab-http.conf 

rewrite ^(.*)$ https://$host$1 permanent;  #添加此行,如下

server {
listen *:80;

server_name gitlab.example.com;
rewrite ^(.*)$ https://$host$1 permanent;
server_tokens off; ## Don't show the nginx version number, a security best practice

 

gitlab-ctl restart

 

更改本地hosts文件

192.168.1.7  gitlab.example.com

登陆 gitlab.example.com,更改默认管理员密码,登陆,创建一个项目

 




 

posted @ 2019-03-03 15:42  从此重新定义啦  阅读(628)  评论(0编辑  收藏  举报