Centos7安装GitLab搭建私有代码仓库

发布时间:2024年01月17日

Centos7安装GitLab搭建私有代码仓库

官网安装说明: https://about.gitlab.com/install/

1. Centos7中安装GitLab官网教程

1. Install and configure the necessary dependencies

On CentOS 7 (and RedHat/Oracle/Scientific Linux 7), the commands below will also open HTTP, HTTPS 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 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 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. Add the GitLab package repository and install the package

Add the GitLab package repository.

curl https://packages.gitlab.com/install/repositories/gitlab/gitlab-ee/script.rpm.sh | sudo bash

Next, install the GitLab package. Change https://gitlab.example.com to the URL at which you want to access your GitLab instance. Installation will automatically configure and start GitLab at that URL.

For https:// URLs GitLab will automatically request a certificate with Let’s Encrypt, which requires inbound HTTP access and a valid hostname. You can also use your own certificate or just use http://.

sudo EXTERNAL_URL="https://gitlab.example.com" yum install -y gitlab-ee

3. Browse to the hostname and login

On your first visit, you’ll be redirected to a password reset screen. Provide the password for the initial administrator account and you will be redirected back to the login screen. Use the default account’s username root to login.

See our documentation for detailed instructions on installing and configuration.

4. Set up your communication preferences

Visit our email subscription preference center to let us know when to communicate with you. We have an explicit email opt-in policy so you have complete control over what and how often we send you emails.

Twice a month, we send out the GitLab news you need to know, including new features, integrations, docs, and behind the scenes stories from our dev teams. For critical security updates related to bugs and system performance, sign up for our dedicated security newsletter.

IMPORTANT NOTE: If you do not opt-in to the security newsletter, you will not receive security alerts.

2. 本地下载安装实操过程

1. 现执行上面的1.1与1.2中的相关命令并下载

curl -s https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.rpm.sh | sudo bash

2. 下载到本地版本如下

gitlab-ce-12.9.0-ce.0.el7.x86_64.rpm

3. 安装

rpm -i gitlab-ce-12.9.0-ce.0.el7.x86_64.rpm

4. 安装成功信息

执行命令后,出现下面信息表示安装成功

[root@MiWiFi-R4CM-srv mysoftware]# rpm -i gitlab-ce-12.9.0-ce.0.el7.x86_64.rpm 
警告:gitlab-ce-12.9.0-ce.0.el7.x86_64.rpm: 头V4 RSA/SHA1 Signature, 密钥 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 now ships with a newer version of PostgreSQL (11.7), but it is not yet
enabled by default. To upgrade, please see:
https://docs.gitlab.com/omnibus/settings/database.html#upgrade-packaged-postgresql-server

5. 修改相关配置

修改gitlab配置文件指定服务器ip和自定义端口

vim /etc/gitlab/gitlab.rb

# 将 external_url 'http://gitlab.example.com' 改为自己的主机及端口,GitLab默认端口8080,如果被占用会包502错误,如下:

external_url 'http:192.168.31.10:8090'

6. 重新配置与启动

分别执行下面两条命令

# 重新配置
gitlab-ctl reconfigure 

# 重启gitlab
gitlab-ctl restart

3. GitLab服务命令及组件说明

1. GitLab服务常用命令

 # 启动服务;
sudo gitlab-ctl reconfigure
# 修改默认的配置文件;
sudo vim /etc/gitlab/gitlab.rb 
# 检查gitlab;
gitlab-rake gitlab:check SANITIZE=true --trace 
 # 查看服务状态;
sudo gitlab-ctl status   
# 启动所有 gitlab 组件;
sudo gitlab-ctl start 
# 停止所有 gitlab 组件;
sudo gitlab-ctl stop 
sudo gitlab-ctl restart 
# 重启所有 gitlab 组件;
 # 查看日志
sudo gitlab-ctl tail nginx

2. Gitlab组件

nginx:静态Web服务器
gitlab-shell:用于处理Git命令和修改authorized keys列表
gitlab-workhorse: 轻量级的反向代理服务器
logrotate:日志文件管理工具
postgresql:数据库
redis:缓存数据库
sidekiq:用于在后台执行队列任务(异步执行)
unicorn:GitLab Rails应用是托管在这个服务器上面的。
文章来源:https://blog.csdn.net/yuanjinshenglife/article/details/135640124
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。