CentOS7 搭建gitlab服務器


  本文介紹如何在CentOS7.2上搭建Gitlab服務器,並簡單介紹如何使用。

Preface

  使用的是CentOS7.2的操作系統,安裝當前最新版Gitlab服務器,下載地址:清華大學開源軟件鏡像站

gitlab-ce-12.0.2-ce.0.el7.x86_64.rpm    610.5 MiB    2019-06-27 05:58

  下載軟件包。

# cat /etc/redhat-release 
CentOS Linux release 7.2.1511 (Core) 
# git --version
git version 1.8.3.1
# wget https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/gitlab-ce-12.0.2-ce.0.el7.x86_64.rpm
# ls
gitlab-ce-12.0.2-ce.0.el7.x86_64.rpm

安裝依賴

  gitlab依賴policycoreutils-python,需要先安裝相關依賴。

# yum install -y policycoreutils-python

安裝Gitlab服務器

  使用rpm -i 可直接安裝相關軟件包。

# rpm -i gitlab-ce-12.0.2-ce.0.el7.x86_64.rpm
warning: gitlab-ce-12.0.2-ce.0.el7.x86_64.rpm: Header V4 RSA/SHA1 Signature, key ID f27eab47: NOKEY
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

  gitlab默認占用8080端口,因為我們這是臨時測試使用,為了不被錯殺,建議修改為其它非Web-like端口,如10101等其它端口。

修改端口

  修改gitlab配置文件。

# vim /etc/gitlab/gitlab.rb
...
external_url 'http://xx.xx.xx.xx:10101'    # ip:port的形式

重新配置

  修改配置文件之后,需重新配置,執行如下命令。

# gitlab-ctl reconfigure
...
Running handlers:
Running handlers complete
Chef Client finished, 30/712 resources updated in 50 seconds
gitlab Reconfigured!

啟動服務

  配置完成之后,啟動服務。

# gitlab-ctl restart
ok: run: alertmanager: (pid 3687) 0s
ok: run: gitaly: (pid 3697) 0s
ok: run: gitlab-monitor: (pid 3714) 0s
ok: run: gitlab-workhorse: (pid 3716) 1s
ok: run: grafana: (pid 3723) 0s
ok: run: logrotate: (pid 3742) 1s
ok: run: nginx: (pid 3750) 0s
ok: run: node-exporter: (pid 3756) 1s
ok: run: postgres-exporter: (pid 3765) 0s
ok: run: postgresql: (pid 3774) 1s
ok: run: prometheus: (pid 3777) 0s
ok: run: redis: (pid 3792) 0s
ok: run: redis-exporter: (pid 3816) 0s
ok: run: sidekiq: (pid 3904) 0s
ok: run: unicorn: (pid 3915) 0s

訪問界面

  訪問剛才在配置文件中設置的http://xx.xx.xx.xx:10101

設置管理員密碼

  如下界面,設置管理員密碼。

  可以選擇登錄或注冊,使用root和剛才設置的管理員口令進行登錄。

 

     目前空空如也。

  可以創建項目、組、添加用戶和進行相關配置,這樣Gitlab服務器便安裝完成。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM