1 环境准备
1.1 机器环境
环境要求:内存至少4G+
操作系统:Centos7
hostname | host | IP | 作用 |
---|---|---|---|
code | code.local.com | 192.168.8.181 | 代码版本管理 |
1.2 hostname
[root@base ~]# hostnamectl set-hostname code --static
[root@base ~]# echo "192.168.8.181 code.local.com" >> /etc/hosts
1.3 网络设置
[root@base1 ~]# vi /etc/sysconfig/network-scripts/ifcfg-ens33
BOOTPROTO="static" #dhcp改为static
ONBOOT="yes" #开机启用本配置
IPADDR=192.168.8.181 #静态IP
GATEWAY=192.168.8.2 #默认网关
NETMASK=255.255.255.0 #子网掩码
DNS1=114.114.114.114 #DNS 配置
DNS2=8.8.8.8 #DNS 配置
$# reboot
1.4 安装并配置必要的依赖关系
在CentOS系统上,打开系统防火墙HTTP和SSH的访问
[root@code ~]# yum install -y curl policycoreutils-python openssh-server
[root@code ~]# systemctl enable sshd
[root@code ~]# systemctl start sshd
[root@code ~]# firewall-cmd --permanent --add-service=http
[root@code ~]# systemctl reload firewalld
安装Postfix,用来发送邮件,在安装Postfix的过程中选择'Internet Site'
[root@code ~]# yum install postfix
[root@code ~]# systemctl enable postfix
[root@code ~]# systemctl start postfix
2 添加GitLab镜像仓库并安装
2.1 使用官方镜像安装
$ curl https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.rpm.sh | sudo bash
$ EXTERNAL_URL="http://code.local.com" yum install -y gitlab-ce
2.2 安装完以后/opt/gitlab/目录结构
/opt/gitlab/
.
├── bin
│ ├── gitlab-backup
│ ├── gitlab-ctl
│ ├── gitlab-healthcheck
│ ├── gitlab-psql
│ ├── gitlab-rails
│ ├── gitlab-rake
│ └── gitlab-redis-cli
├── dependency_licenses.json
3 配置并启动 GitLab
启动命令
gitlab-ctl reconfigure # 首次启动也要用此命令。重新加载配置并启动
gitlab-ctl start # 启动
gitlab-ctl stop # 停止
/etc/gitlab/ 目录结构:
├── gitlab.rb
├── gitlab-secrets.json
└── trusted-certs
gitLab 基本配置集中在 /etc/gitlab/gitlab.rb 文件,每个参数的作用和配置
配置参数:
vim /etc/gitlab/gitlab.rb
...
nginx['listen_port'] = 80
external_url 'http://code.local.com'
...
启动数据库和gitLab
gitlab-ctl stop
gitlab-ctl restart postgresql
gitlab-ctl reconfigure
gitlab-ctl start
4 访问
系统默认的管理员账号为root,第一次访问 GitLab,会要求初始化管理员账号的密码
gitlab 后台切换中文显示1.进入gitlab后台点击右上角个人头像->settings->profile->Preferred language 2.默认是english,选择简体中文。
网友评论