參考博客:RHEL7/CentOS7 在線和離線安裝 GitLab 配置使用實踐
在線安裝gitlab
- 依賴安裝
yum install curl policycoreutils openssh-server openssh-clients -y
systemctl enable sshd
systemctl start sshd
yum install postfix
systemctl enable postfix
# 檢查修改郵件下面 2 項配置,不配置可以跳過
vim /etc/postfix/main.cf
inet_interfaces = all
inet_protocols = ipv4
systemctl start postfix
- 在線安裝 gitlab-ce
# 安裝必要的依賴包,如果不需要可以考慮跳過
yum install pygpgme yum-utils
# On CentOS 7 (and RedHat/Oracle/Scientific Linux 7), the commands below will also open HTTP and SSH access in the system firewall.
sudo yum install -y curl policycoreutils-python openssh-server
sudo systemctl enable sshd
sudo systemctl start sshd
sudo firewall-cmd --permanent --add-service=http
sudo systemctl reload firewalld
# Next, install Postfix to send notification emails. If you want to use another solution to send emails please skip this step and configure an external SMTP server after GitLab has been installed.
sudo yum install postfix
sudo systemctl enable postfix
sudo systemctl start postfix
# 使用阿里雲作加速
cd /etc/yum.repos.d/ && rm -f *.repo
wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
# 添加 GitLab 鏡像源並安裝,建議切換國內資源加速訪問
curl https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.rpm.sh | sudo bash
# 創建 gitlab-ce 的 repo,使用清華大學加速
vim /etc/yum.repos.d/gitlab_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
# 配置並啟動 GitLab
gitlab-ctl reconfigure
離線安裝gitlab
# 使用阿里雲作加速
cd /etc/yum.repos.d/ && rm -f *.repo
wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
# 添加 GitLab 鏡像源並安裝,建議切換國內資源加速訪問
curl https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.rpm.sh | sudo bash
# 創建 gitlab-ce 的 repo,使用清華大學加速
vim /etc/yum.repos.d/gitlab_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
# 安裝 yum-plugin-downloadonly 插件
yum install -y yum-plugin-downloadonly
# 下載 gitlab-ce 相關 rpm 到指定目錄
mkdir -p /tmp/repo/gitlab-ce/
yum install --downloadonly --downloaddir=/tmp/repo/gitlab-ce/ gitlab-ce
# 拷貝文件至內網離線安裝
rpm -ivh /tmp/repo/gitlab-ce/*
# 配置並啟動 GitLab
gitlab-ctl reconfigure
# 第一次訪問 GitLab,系統會重定向頁面到重定向到重置密碼頁面,你需要輸入初始化管理員賬號的密碼,管理員的用戶名為 root,重置密碼后新密碼即為剛輸入的密碼。
0.0.0.0:80