安裝Gitlab社區(qū)版栏赴,即Gitlab-ce
1首先第一步安裝和配置必要的依賴,參考官網(wǎng) https://about.gitlab.com/install/#centos-7
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
效果如下
[root@double double]# sudo yum install -y curl policycoreutils-python openssh-server
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
* base: mirrors.163.com
* extras: mirrors.163.com
* updates: mirrors.163.com
base | 3.6 kB 00:00
extras | 3.4 kB 00:00
updates | 3.4 kB 00:00
Package curl-7.29.0-51.el7.x86_64 already installed and latest version
Package openssh-server-7.4p1-16.el7.x86_64 already installed and latest version
Resolving Dependencies
--> Running transaction check
---> Package policycoreutils-python.x86_64 0:2.5-29.el7 will be updated
---> Package policycoreutils-python.x86_64 0:2.5-29.el7_6.1 will be an update
--> Processing Dependency: policycoreutils = 2.5-29.el7_6.1 for package: policycoreutils-python-2.5-29.el7_6.1.x86_64
--> Running transaction check
---> Package policycoreutils.x86_64 0:2.5-29.el7 will be updated
---> Package policycoreutils.x86_64 0:2.5-29.el7_6.1 will be an update
--> Finished Dependency Resolution
Dependencies Resolved
================================================================================
Package Arch Version Repository Size
================================================================================
Updating:
policycoreutils-python x86_64 2.5-29.el7_6.1 updates 456 k
Updating for dependencies:
policycoreutils x86_64 2.5-29.el7_6.1 updates 916 k
Transaction Summary
================================================================================
Upgrade 1 Package (+1 Dependent package)
Total size: 1.3 M
Downloading packages:
warning: /var/cache/yum/x86_64/7/updates/packages/policycoreutils-2.5-29.el7_6.1.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY
Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
Importing GPG key 0xF4A80EB5:
Userid : "CentOS-7 Key (CentOS 7 Official Signing Key) <security@centos.org>"
Fingerprint: 6341 ab27 53d7 8a78 a7c2 7bb1 24c6 a8a7 f4a8 0eb5
Package : centos-release-7-6.1810.2.el7.centos.x86_64 (@anaconda)
From : /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Updating : policycoreutils-2.5-29.el7_6.1.x86_64 1/4
Updating : policycoreutils-python-2.5-29.el7_6.1.x86_64 2/4
Cleanup : policycoreutils-python-2.5-29.el7.x86_64 3/4
Cleanup : policycoreutils-2.5-29.el7.x86_64 4/4
Verifying : policycoreutils-2.5-29.el7_6.1.x86_64 1/4
Verifying : policycoreutils-python-2.5-29.el7_6.1.x86_64 2/4
Verifying : policycoreutils-2.5-29.el7.x86_64 3/4
Verifying : policycoreutils-python-2.5-29.el7.x86_64 4/4
Updated:
policycoreutils-python.x86_64 0:2.5-29.el7_6.1
Dependency Updated:
policycoreutils.x86_64 0:2.5-29.el7_6.1
Complete!
[root@double double]# sudo systemctl enable sshd
[root@double double]# sudo systemctl start sshd
[root@double double]# sudo firewall-cmd --permanent --add-service=http
success
[root@double double]# sudo systemctl reload firewalld
然后安裝Postfix去發(fā)送郵件。如果需要通過其他途徑發(fā)送郵件的話岗钩,可以跳過這個(gè)步驟女坑,等Gitlab安裝完成之后再配置外部的SMTP服務(wù)器,參考
https://docs.gitlab.com/omnibus/settings/smtp.html
sudo yum install postfix
sudo systemctl enable postfix
sudo systemctl start postfix
During Postfix installation a configuration screen may appear. Select 'Internet Site' and press enter. Use your server's external DNS for 'mail name' and press enter. If additional screens appear, continue to press enter to accept the defaults.
2配置GitLab的倉庫地址并下載安裝包
2.1添加倉庫地址
curl https://packages.gitlab.com/install/repositories/gitlab/gitlab-ee/script.rpm.sh | sudo bash
這里配置yum時(shí)引用的是官方的庫可能速度有影響偷办,可以切換到國內(nèi)鏡像源
配置yum源
vim /etc/yum.repos.d/gitlab-ce.repo
復(fù)制以下內(nèi)容
[gitlab-ce]
name=gitlab-ce
baseurl=http://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/
Repo_gpgcheck=0
Enabled=1
Gpgkey=https://packages.gitlab.com/gpg.key
2.2更新本地yum緩存
sudo yum makecache
[root@double double]# sudo yum makecache
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
* base: mirrors.163.com
* extras: mirrors.163.com
* updates: mirrors.163.com
base | 3.6 kB 00:00
extras | 3.4 kB 00:00
gitlab-ce | 2.9 kB 00:00
updates | 3.4 kB 00:00
(1/8): extras/7/x86_64/other_db | 127 kB 00:00
(2/8): extras/7/x86_64/prestodelta | 65 kB 00:00
(3/8): extras/7/x86_64/filelists_db | 246 kB 00:00
(4/8): gitlab-ce/other_db | 28 kB 00:00
(5/8): base/7/x86_64/other_db | 2.6 MB 00:00
(6/8): base/7/x86_64/filelists_db | 7.1 MB 00:01
(7/8): updates/7/x86_64/filelists_db | 4.4 MB 00:01
(8/8): gitlab-ce/filelists_db | 243 MB 00:23
Metadata Cache Created
2.3安裝GitLab社區(qū)版
sudo EXTERNAL_URL="https://gitlab.example.com" yum install -y gitlab-ce
這里EXTERNAL_URL="http://gitlab.example.com"
如果不需要https方式的話可以只用http
服務(wù)器地址可以設(shè)置成本機(jī)IP
端口默認(rèn)是80艰额,可以設(shè)置任意未占用的其他端口
例如 EXTERNAL_URL="http://192.168.1.10:8899"。
[root@double double]# sudo EXTERNAL_URL="http://192.168.1.10:10086" yum install -y gitlab-ce
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
* base: mirrors.163.com
* extras: mirrors.163.com
* updates: mirrors.163.com
Resolving Dependencies
--> Running transaction check
---> Package gitlab-ce.x86_64 0:12.0.2-ce.0.el7 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
================================================================================
Package Arch Version Repository Size
================================================================================
Installing:
gitlab-ce x86_64 12.0.2-ce.0.el7 gitlab-ce 611 M
Transaction Summary
================================================================================
Install 1 Package
Total download size: 611 M
Installed size: 611 M
Downloading packages:
warning: /var/cache/yum/x86_64/7/gitlab-ce/packages/gitlab-ce-12.0.2-ce.0.el7.x86_64.rpm: Header V4 RSA/SHA1 Signature, key ID f27eab47: NOKEY
Public key for gitlab-ce-12.0.2-ce.0.el7.x86_64.rpm is not installed
gitlab-ce-12.0.2-ce.0.el7.x86_64.rpm | 611 MB 00:00:58
Retrieving key from https://packages.gitlab.com/gpg.key
Importing GPG key 0xE15E78F4:
Userid : "GitLab B.V. (package repository signing key) <packages@gitlab.com>"
Fingerprint: 1a4c 919d b987 d435 9396 38b9 1421 9a96 e15e 78f4
From : https://packages.gitlab.com/gpg.key
Public key for gitlab-ce-12.0.2-ce.0.el7.x86_64.rpm is not installed
Failing package is: gitlab-ce-12.0.2-ce.0.el7.x86_64
GPG Keys are configured as: https://packages.gitlab.com/gpg.key
這里可以看見有一段錯(cuò)誤
Public key for gitlab-ce-12.0.2-ce.0.el7.x86_64.rpm is not installed
可能是由于該鏡像不是從官方下載導(dǎo)致的爽篷,可以在安裝命令后面加--nogpgcheck
sudo EXTERNAL_URL="http://192.168.1.10:8899" yum install -y gitlab-ce --nogpgcheck
效果如下
*
*
*
以上一大段省略.........
Running handlers:
Running handlers complete
Chef Client finished, 513/1343 resources updated in 04 minutes 09 seconds
gitlab Reconfigured!
*. *.
*** ***
***** *****
.****** *******
******** ********
,,,,,,,,,***********,,,,,,,,,
,,,,,,,,,,,*********,,,,,,,,,,,
.,,,,,,,,,,,*******,,,,,,,,,,,,
,,,,,,,,,*****,,,,,,,,,.
,,,,,,,****,,,,,,
.,,,***,,,,
,*,.
_______ __ __ __
/ ____(_) /_/ / ____ _/ /_
/ / __/ / __/ / / __ `/ __ \
/ /_/ / / /_/ /___/ /_/ / /_/ /
\____/_/\__/_____/\__,_/_.___/
Thank you for installing GitLab!
GitLab should be available at http://192.168.1.10:10086
For a comprehensive list of configuration options please see the Omnibus GitLab readme
https://gitlab.com/gitlab-org/omnibus-gitlab/blob/master/README.md
Verifying : gitlab-ce-12.0.2-ce.0.el7.x86_64 1/1
Installed:
gitlab-ce.x86_64 0:12.0.2-ce.0.el7
Complete!
3配置郵件
前面提到等Gitlab安裝完成之后再配置外部的SMTP服務(wù)器悴晰,參考
https://docs.gitlab.com/omnibus/settings/smtp.html
編輯gitlab.rb文件
vi /etc/gitlab/gitlab.rb
找到郵件配置區(qū)域,這里配置的是126郵箱逐工,如下
### Email Settings
# gitlab_rails['gitlab_email_enabled'] = true
# gitlab_rails['gitlab_email_from'] = 'example@example.com'
# gitlab_rails['gitlab_email_display_name'] = 'Example'
# gitlab_rails['gitlab_email_reply_to'] = 'noreply@example.com'
# gitlab_rails['gitlab_email_subject_suffix'] = ''
gitlab_rails['smtp_enable'] = true
gitlab_rails['smtp_address'] = "smtp.126.com"
gitlab_rails['smtp_port'] = 25
gitlab_rails['smtp_user_name'] = "用戶名@126.com"
gitlab_rails['smtp_password'] = "網(wǎng)易提供的客戶端授權(quán)碼,非郵箱密碼"
gitlab_rails['smtp_domain'] = "126.com"
gitlab_rails['smtp_authentication'] = "login"
gitlab_rails['smtp_enable_starttls_auto'] = true
gitlab_rails['smtp_tls'] = false
gitlab_rails['gitlab_email_from'] = "用戶名@126.com"
gitlab_rails['gitlab_email_reply_to'] = "用戶名@126.com"
user["git_user_email"] = "用戶名@126.com"
然后更新配置
gitlab-ctl reconfigure
如果更新后還是不行铡溪,可以重啟一下試試
gitlab-ctl restart
4故障點(diǎn)
4.1主機(jī)訪問虛擬機(jī)出現(xiàn)502
我這里面是在VM14里面的CentOS-7安裝的gitlab-ce,便于測試需要,直接關(guān)閉了防火墻
[root@double double]# systemctl disable firewalld
Removed symlink /etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
[root@double double]# systemctl stop firewalld