在CentOS-7中安裝Gitlab

安裝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
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
  • 序言:七十年代末泪喊,一起剝皮案震驚了整個(gè)濱河市棕硫,隨后出現(xiàn)的幾起案子,更是在濱河造成了極大的恐慌袒啼,老刑警劉巖哈扮,帶你破解...
    沈念sama閱讀 218,941評(píng)論 6 508
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件,死亡現(xiàn)場離奇詭異蚓再,居然都是意外死亡滑肉,警方通過查閱死者的電腦和手機(jī),發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 93,397評(píng)論 3 395
  • 文/潘曉璐 我一進(jìn)店門摘仅,熙熙樓的掌柜王于貴愁眉苦臉地迎上來靶庙,“玉大人,你說我怎么就攤上這事娃属×模” “怎么了护姆?”我有些...
    開封第一講書人閱讀 165,345評(píng)論 0 356
  • 文/不壞的土叔 我叫張陵,是天一觀的道長掏击。 經(jīng)常有香客問我卵皂,道長,這世上最難降的妖魔是什么砚亭? 我笑而不...
    開封第一講書人閱讀 58,851評(píng)論 1 295
  • 正文 為了忘掉前任灯变,我火速辦了婚禮,結(jié)果婚禮上钠惩,老公的妹妹穿的比我還像新娘柒凉。我一直安慰自己,他們只是感情好篓跛,可當(dāng)我...
    茶點(diǎn)故事閱讀 67,868評(píng)論 6 392
  • 文/花漫 我一把揭開白布膝捞。 她就那樣靜靜地躺著,像睡著了一般愧沟。 火紅的嫁衣襯著肌膚如雪蔬咬。 梳的紋絲不亂的頭發(fā)上,一...
    開封第一講書人閱讀 51,688評(píng)論 1 305
  • 那天沐寺,我揣著相機(jī)與錄音林艘,去河邊找鬼。 笑死混坞,一個(gè)胖子當(dāng)著我的面吹牛狐援,可吹牛的內(nèi)容都是我干的。 我是一名探鬼主播究孕,決...
    沈念sama閱讀 40,414評(píng)論 3 418
  • 文/蒼蘭香墨 我猛地睜開眼啥酱,長吁一口氣:“原來是場噩夢啊……” “哼!你這毒婦竟也來了厨诸?” 一聲冷哼從身側(cè)響起镶殷,我...
    開封第一講書人閱讀 39,319評(píng)論 0 276
  • 序言:老撾萬榮一對(duì)情侶失蹤,失蹤者是張志新(化名)和其女友劉穎微酬,沒想到半個(gè)月后绘趋,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體,經(jīng)...
    沈念sama閱讀 45,775評(píng)論 1 315
  • 正文 獨(dú)居荒郊野嶺守林人離奇死亡颗管,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點(diǎn)故事閱讀 37,945評(píng)論 3 336
  • 正文 我和宋清朗相戀三年陷遮,在試婚紗的時(shí)候發(fā)現(xiàn)自己被綠了。 大學(xué)時(shí)的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片垦江。...
    茶點(diǎn)故事閱讀 40,096評(píng)論 1 350
  • 序言:一個(gè)原本活蹦亂跳的男人離奇死亡拷呆,死狀恐怖,靈堂內(nèi)的尸體忽然破棺而出,到底是詐尸還是另有隱情茬斧,我是刑警寧澤,帶...
    沈念sama閱讀 35,789評(píng)論 5 346
  • 正文 年R本政府宣布梗逮,位于F島的核電站项秉,受9級(jí)特大地震影響,放射性物質(zhì)發(fā)生泄漏慷彤。R本人自食惡果不足惜娄蔼,卻給世界環(huán)境...
    茶點(diǎn)故事閱讀 41,437評(píng)論 3 331
  • 文/蒙蒙 一、第九天 我趴在偏房一處隱蔽的房頂上張望底哗。 院中可真熱鬧岁诉,春花似錦、人聲如沸跋选。這莊子的主人今日做“春日...
    開封第一講書人閱讀 31,993評(píng)論 0 22
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽前标。三九已至坠韩,卻和暖如春,著一層夾襖步出監(jiān)牢的瞬間炼列,已是汗流浹背只搁。 一陣腳步聲響...
    開封第一講書人閱讀 33,107評(píng)論 1 271
  • 我被黑心中介騙來泰國打工, 沒想到剛下飛機(jī)就差點(diǎn)兒被人妖公主榨干…… 1. 我叫王不留俭尖,地道東北人氢惋。 一個(gè)月前我還...
    沈念sama閱讀 48,308評(píng)論 3 372
  • 正文 我出身青樓,卻偏偏與公主長得像稽犁,于是被迫代替她去往敵國和親焰望。 傳聞我的和親對(duì)象是個(gè)殘疾皇子,可洞房花燭夜當(dāng)晚...
    茶點(diǎn)故事閱讀 45,037評(píng)論 2 355

推薦閱讀更多精彩內(nèi)容

  • 以下內(nèi)容出自得到app缭付,最近幾年一直在說顛覆式創(chuàng)新柿估,在說人工智能,在說阿法狗陷猫,所以有了以下內(nèi)容秫舌,繼續(xù)深度剖析顛覆式...
    芷榮說閱讀 567評(píng)論 0 0
  • 內(nèi)存區(qū)域劃分(1)代碼區(qū):代碼的二進(jìn)制數(shù)據(jù)(2)數(shù)據(jù)區(qū):全局變量、常量绣檬、靜態(tài)static變量(3)堆區(qū):動(dòng)態(tài)申請(qǐng)的...
    大白_帕克閱讀 867評(píng)論 0 0
  • 我現(xiàn)在在車上娇未,向著熟悉的東方前進(jìn)著墨缘,而我,此時(shí)此刻,心情卻完全沒有我臆想的那般輕松愉快镊讼,甚至有些惱火宽涌。 火車,我內(nèi)...
    念舊的人閱讀 282評(píng)論 0 0
  • 大家看過《筆仙》嗎蝶棋?我剛看完兩部卸亮。說實(shí)話 雖然是鬼片,但我一點(diǎn)不害怕玩裙。 記得大學(xué)和室友一起看鬼片兼贸,她害怕的要死,把...
    怪咖小雪雪閱讀 121評(píng)論 0 0