电光石火-穿越时空电光石火-穿越时空


CentOS 7下安装指定版本的GitLab

一、添加镜像地址

添加镜像地址的目的是为了提高国内用户软件下载的速度,编辑(新建)文件gitlab-ce.repo,指令:

vi /etc/yum.repos.d/gitlab-ce.repo

输入:

[gitlab-ce]
name=gitlab-ce
# 清华大学的镜像源
baseurl=http://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7
repo_gpgcheck=0
gpgcheck=0
enabled=1
gpgkey=https://packages.gitlab.com/gpg.key

二、安装依赖

依次输入以下指令

# 安装和配置openssh
sudo yum install curl policycoreutils-python openssh-server openssh-clients
sudo systemctl enable sshd
sudo systemctl start sshd
# 安装和配置邮件服务
sudo yum install postfix
sudo systemctl enable postfix
sudo systemctl start postfix

注意 如果无法启动postfix,可以尝试以下操作:
输入以下指令编辑main.cf文件:

vim /etc/postfix/main.cf

找到如下内容并进行如下修改:

inet_protocols = ipv4
inet_interfaces = all

三、安装防火墙[可选操作]

需要开启防火墙的,执行以下操作

# 安装和配置防火墙
sudo yum install firewalld
sudo systemctl start firewalld
sudo firewall-cmd --add-service=http --permanent
sudo firewall-cmd --reload

四、下载安装GitLab

1.安装最新版
执行以下指令安装最新版的GitLab

yum install gitlab-ce

2.安装指定版
GitLab10.0.0下载:

curl -LJO https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/gitlab-ce-10.0.0-ce.0.el7.x86_64.rpm

安装:

rpm -i gitlab-ce-10.0.0-ce.0.el7.x86_64.rpm

五、配置GitLab

运行以下指令,类似于初始化操作:

sudo gitlab-ctl reconfigure

[可选操作] 配置防火墙,放行端口(8091为例):

sudo firewall-cmd --permanent --zone=public --add-port=8091/tcp
sudo firewall-cmd --add-service=http --permanent
sudo firewall-cmd --reload

[可选操作] 关闭防火墙

# 查看防火墙状态
firewall-cmd --state
# 关闭防火墙
systemctl stop firewalld.service
# 关闭防火墙自启动
systemctl disable firewalld.service 

vim的搜索指令提示:
打开文件后,在命令模式,就是按下ESC后的模式,输入以下内容,点击进行搜索,按下N搜索下一个,按下Shift+N搜索前一个:

#"/"后面添加需要搜索的内容
/external_url

更改GitLab端口,编辑文件gitlab.rb:

vim /etc/gitlab/gitlab.rb

修改以下内容(IP以 47.110.230.147 为例):

external_url 'http://47.110.230.147:8091'
nginx['listen_port'] = 8091
nginx['listen_https'] = false

更改nigx端口,编辑文件gitlab-http.conf:

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

查找如下内容并修改:

server {
listen *:8091;
server_name 47.110.230.147;
...
if ($http_host = "") {
   set $http_host_with_default "47.110.230.147:8091";
}
}

保存修改,执行以下指令:

gitlab-ctl reconfigure

六、启动并访问

启动GitLab:

gitlab-ctl restart

访问GitLab,访问地址:http://47.110.230.147:8091,默认用户为 root,首次打开网站会要求输入root账户的密码。

本博客所有文章如无特别注明均为原创。作者:似水的流年
版权所有:《电光石火-穿越时空》 => CentOS 7下安装指定版本的GitLab
本文地址:http://www.ilkhome.cn/index.php/archives/566/
欢迎转载!复制或转载请以超链接形式注明,文章为 似水的流年 原创,并注明原文地址 CentOS 7下安装指定版本的GitLab,谢谢。

评论