
文章目錄
- 一、下載下傳、安裝、配置依賴
- 1. 安裝配置需要的依賴
- 2. Gitlab下載下傳
- 3. 安裝Gitlab
- 4. 配置external_url
- 5. 重新加載配置檔案
- 6. 檢視服務狀态
- 7. 配置防火牆
- 8. 浏覽器驗證
- 9. 尋找密碼資訊
- 10. 檢視密碼
- 11. 重新登陸
- 12. 修改密碼
- 13. 重新登陸
- 14. Gitlab常用指令
聲明:Centos/Red Hat7/8.x 下載下傳、安裝、配置不通的地方我會進行特殊說明,未說明的屬于共有部分。
一、下載下傳、安裝、配置依賴
1. 安裝配置需要的依賴
https://about.gitlab.com/install/#centos-7
# On CentOS 7 (and RedHat/Oracle/Scientific Linux 7), the commands below will also open HTTP, HTTPS and SSH access in the system firewall. This is an optional step, and you can skip it if you intend to access GitLab only from your local network.
sudo yum install -y policycoreutils-python openssh-server perl
# Enable OpenSSH server daemon if not enabled: sudo systemctl status sshd
sudo systemctl enable sshd
sudo systemctl start sshd
# Check if opening the firewall is needed with: sudo systemctl status firewalld
sudo firewall-cmd --permanent --add-service=http
sudo firewall-cmd --permanent --add-service=https
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
2. Gitlab下載下傳
Centos/Red Hat7.x 下載下傳連結:
https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/
Centos/Red Hat8.x 下載下傳連結:
https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el8/
3. 安裝Gitlab
# Centos/Red Hat7.x 安裝方式
[root@localhost ~]# rpm -ivh gitlab-ce-14.2.3-ce.0.el7.x86_64.rpm
# Centos/Red Hat8.x 安裝方式
[root@localhost ~]# rpm -ivh gitlab-ce-14.2.3-ce.0.el8.x86_64.rpm
操作記錄:
[root@localhost ~]# rpm -ivh gitlab-ce-14.2.3-ce.0.el7.x86_64.rpm
警告:gitlab-ce-14.2.3-ce.0.el7.x86_64.rpm: 頭V4 RSA/SHA1 Signature, 密鑰 ID f27eab47: NOKEY
準備中... ################################# [100%]
正在更新/安裝...
1:gitlab-ce-14.2.3-ce.0.el7 ################################# [100%]
It looks like GitLab has not been configured yet; skipping the upgrade script.
*. *.
*** ***
***** *****
.****** *******
******** ********
,,,,,,,,,***********,,,,,,,,,
,,,,,,,,,,,*********,,,,,,,,,,,
.,,,,,,,,,,,*******,,,,,,,,,,,,
,,,,,,,,,*****,,,,,,,,,.
,,,,,,,****,,,,,,
.,,,***,,,,
,*,.
_______ __ __ __
/ ____(_) /_/ / ____ _/ /_
/ / __/ / __/ / / __ `/ __ \
/ /_/ / / /_/ /___/ /_/ / /_/ /
\____/_/\__/_____/\__,_/_.___/
Thank you for installing GitLab!
GitLab was unable to detect a valid hostname for your instance.
Please configure a URL for your GitLab instance by setting `external_url`
configuration in /etc/gitlab/gitlab.rb file.
Then, you can start your GitLab instance by running the following command:
sudo gitlab-ctl reconfigure
For a comprehensive list of configuration options please see the Omnibus GitLab readme
https://gitlab.com/gitlab-org/omnibus-gitlab/blob/master/README.md
Help us improve the installation experience, let us know how we did with a 1 minute survey:
https://gitlab.fra1.qualtrics.com/jfe/form/SV_6kVqZANThUQ1bZb?installation=omnibus&release=14-2
[root@localhost ~]#
4. 配置external_url
[root@localhost ~]# vim /etc/gitlab/gitlab.rb
将 #external_url 'http://gitlab.example.com'調整為http://+ip:端口的格式
external_url 'http://192.168.159.102:8000'
5. 重新加載配置檔案
[root@localhost ~]# sudo gitlab-ctl reconfigure
等着安裝完畢就好了
6. 檢視服務狀态
sudo
7. 配置防火牆
#開放端口(開放後需要要重新開機防火牆才生效)
firewall-cmd --zone=public --add-port=8000/tcp --permanent
# 重新啟動防火牆
8. 浏覽器驗證
# 格式:IP+端口号(預設8080)
這個Gitlab14.x版本,和以前有些不同,以前的第一次通路會讓你設定root使用者的密碼,但是這個版本,預設為你配置了密碼
9. 尋找密碼資訊
安裝完成後,最後會有以下資訊
Notes:
Default admin account has been configured with following details:
Username: root
Password: You didn't opt-in to print initial root password to STDOUT.
Password stored to /etc/gitlab/initial_root_password. This file will be cleaned up in first reconfigure run after 24 hours.
NOTE: Because these credentials might be present in your log files in plain text, it is highly recommended to reset the password following https://docs.gitlab.com/ee/security/reset_user_password.html#reset-your-root-password.
gitlab Reconfigured!
關鍵資訊說明:
預設管理者使用者名是root,root使用者的密碼存放到
/etc/gitlab/initial_root_password
檔案中了,請在24小時内修改密碼。
Username: root
Password: You didn't opt-in to print initial root password to STDOUT.
Password stored to /etc/gitlab/initial_root_password. This file will be cleaned up in first reconfigure run after 24
10. 檢視密碼
[root@localhost ~]# cat /etc/gitlab/initial_root_password
# WARNING: This value is valid only in the following conditions
# 1. If provided manually (either via `GITLAB_ROOT_PASSWORD` environment variable or via `gitlab_rails['initial_root_password']` setting in `gitlab.rb`, it was provided before database was seeded for the first time (usually, the first reconfigure run).
# 2. Password hasn't been changed manually, either via UI or via command line.
#
# If the password shown here doesn't work, you must reset the admin password following https://docs.gitlab.com/ee/security/reset_user_password.html#reset-your-root-password.
Password: oQIWkCNmUtrOeYebj8vVJ53CocII+ZlpWhzssaLUH5c=
# NOTE: This file will be automatically deleted in the first reconfigure run after 24 hours.
[root@localhost ~]#
11. 重新登陸
12. 修改密碼
13. 重新登陸

14. Gitlab常用指令
指令功能 | 執行指令 |
重新開機配置,并啟動gitlab服務 | sudo gitlab-ctl reconfigure |
啟動所有 gitlab | sudo gitlab-ctl start |
重新啟動GitLab | sudo gitlab-ctl restart |
停止所有 gitlab | sudo gitlab-ctl stop |
檢視服務狀态 | sudo gitlab-ctl status |
檢視Gitlab日志 | sudo gitlab-ctl tail |
修改預設的配置檔案 | sudo vim /etc/gitlab/gitlab.rb |
檢查gitlab | gitlab-rake gitlab:check SANITIZE=true --trace |
接下一篇:Centos/Red Hat7/8.x 安裝、配置、啟動Gitlab14.x (語言和主題配置
想學習更多前後端分離、微服務、分布式、MQ/緩存/引擎中間件、資料庫、項目重構技巧等系列技術