記一次搭建gitlab服務器的經歷(包括虛擬機創建及配置)
-
前期準備
類型 | 軟件名 |
---|---|
服務器 | CentOS7 |
安裝文件 | gitlab-ce-12.6.3-ce.0.el7.x86_64.rpm |
-
創建虛擬機
已經有linux系統的請直接略過
1.官網下載VMware,我們直接下載VMware Workstation Pro 最新版就可以了,后續激活碼網上很多。
2.VMware安裝CentOS7教程參考:http://www.lxweimin.com/p/ce08cdbc4ddb?utm_source=tuicool&utm_medium=referral
(上面博客的CentOS7系統鏡像下載鏈接失效了,這里提供下載鏈接。官網站點| |阿里站點)
(最好給root多分一點內存空間(root:20GB,2G內存)。雖然可以后續再加,但是個人覺得跟重裝系統一樣繁瑣了)
3.最后安裝完成如下圖:
image.png
image.png
-
安裝gitlab
提供兩種安裝方式 yum安裝、rmp安裝(個人比較喜歡第二種)
1.yum安裝
這里直接參考官網安裝教程
支持系統.png
安裝命令.png
打開linux系統終端,首先安裝gitlab必須的ssh,以及在系統防火墻中打開HTTP、HTTPS和SSH訪問。
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 firewall-cmd --permanent --add-service=https
sudo systemctl reload firewalld
然后是安裝發送郵件功能的postfix
sudo yum install postfix
sudo systemctl enable postfix
sudo systemctl start postfix
添加gitlab的包倉庫(ee改成ce)
curl https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.rpm.sh | sudo bash
安裝gitlab(EXTERNAL_URL指的是你的gitlab訪問地址,這里改為http://+你的linux系統ip)
sudo EXTERNAL_URL="https://gitlab.example.com" yum install -y gitlab-ce
2.自己下載rpm安裝
使用官網的安裝方式下載很慢(親測網上的阿里站點,清華站點也不是很快),這里教大家直接下載rmp安裝包手動安裝。
首先去官網安裝包倉庫下載我們所需的安裝包版本
image.png
下載完成之后將文件拷貝至你的linux服務器,同樣需要配置ssh、防火墻、postfix,
//安裝gitlab必須的ssh,以及在系統防火墻中打開HTTP、HTTPS和SSH訪問。
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 firewall-cmd --permanent --add-service=https
sudo systemctl reload firewalld
//安裝發送郵件功能的postfix
sudo yum install postfix
sudo systemctl enable postfix
sudo systemctl start postfix
然后cd進入你的安裝包路徑進行安裝
rpm -ivh example.rpm 安裝 example.rpm 包并在安裝過程中顯示正在安裝的文件信息及安裝進度
出現下圖即為安裝成功
image.png
這種方式需要我們手動進入配置文件中修改訪問地址
sudo vim /etc/gitlab/gitlab.rb
//修改文件中external_url 'http://你linux的ip'
然后瀏覽器上輸入你的訪問地址(第一次訪問會讓你輸入新密碼,用戶名默認為root)
image.png