gitlab搭建


gitlab搭建

linux服务器版本为 CentOS Linux release 7.6.1810 (Core)

  • 官方下载地址

https://about.gitlab.com/install/#centos-7

  • 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. 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 curl 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 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.

  • 离线下载gitlab社区版rpm包 https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/?C=M&O=A
  • 下载后上传到linux的 /opt目录
  • 安装rpm包 rpm -ivh gitlab-ce-14.6.7-ce.0.el7.x86_64.rpm
  • 安装完成后重置gitlab gitlab-ctl reconfigure
  • 重启gitlab gitlab-ctl restart
  • 查看密码 cd /opt/gitlab/bin
  • 查看gitlab信息并更改密码 gitlab-rails console -e production
  • 依次执行

    • user = User.where(username:"root").first
    • user.password = "yourPassword"
    • user.save!
[root@localhost bin]# gitlab-rails console -e production
--------------------------------------------------------------------------------
 Ruby:         ruby 2.7.5p203 (2021-11-24 revision f69aeb8314) [x86_64-linux]
 GitLab:       14.6.7 (ef9a203353d) FOSS
 GitLab Shell: 13.22.1
 PostgreSQL:   12.7
--------------------------------------------------------------------------------
Loading production environment (Rails 6.1.4.1)

irb(main):001:0> user = User.where(username:"root").first
=> #<User id:1 @root>
irb(main):003:0> user.password = "#Test4796"
=> "#Chint4796"
irb(main):004:0> user.save!
=> true
irb(main):005:0> quit

声明:木心|版权所有,违者必究|如未注明,均为原创|本网站采用BY-NC-SA协议进行授权

转载:转载请注明原文链接 - gitlab搭建


Carpe Diem and Do what I like