How to deploy GitLab in alicloud?

   this tutorial defaults to the creation of alicloud ECS and the deployment of GitLab environment on this basis.

   there is a manual deployment tutorial on the GitLab official website, and the instructions of different operating systems are more or less different. The tutorial link on the official website is as follows:

However, the tutorial on the official website is a little too ideal. If you follow this tutorial completely, you often fail to deploy. Therefore, we have sorted out the deployment method. The system I use is centos-8. If it is other systems, please refer to the deployment instructions on the official website for modification.

  1. Install dependent packages
sudo dnf install -y curl policycoreutils openssh-server perl
  1. Set SSH startup self startup and start SSH service
sudo systemctl enable sshd
sudo systemctl start sshd
  1. Open HTTP and SSH services in the firewall
# 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

In this step, you may encounter the error prompt firewall is not running. Use the following command to turn on the firewall:

systemctl start firewalld.service
  1. Install Postfix boot self
sudo dnf install postfix
sudo systemctl enable postfix
sudo systemctl start postfix
  1. Start the Postfix service

Run the command vim /etc/postfix/, edit the file, and modify the following two parameters:

inet_interfaces = all
inet_protocols = ipv4 // Or all

Prompt: press i to enter the editing mode. After editing, press: wq save to exit.

After modification, execute the following command to start the service:

sudo systemctl restart postfix
  1. Open ports and set up firewalls

In this step, I operate directly on the web page, security group - > configuration rules in network and security

Add rules and define them as follows. The port number can be set by yourself, such as 8888

There are also scripts on the Internet, but the author has not tried:

#Open 8888 port (the port number is set by yourself) firewall-cmd --zone=public --add-port=8888/tcp --permanent#Restart the firewall systemctl restart firewalld
  1. Add GitLab's package repository
curl | sudo bash
  1. Installing GitLab

At this point, we need to enter the alicloud instance to view the IP address of the public network:

Assuming that the IP address is, the port number set above is 8888.

sudo EXTERNAL_URL="" yum install -y gitlab-ee

The following gitlab EE represents the enterprise version, or you can install the community version, that is, gitlab CE.

After installation, enter in the browser address to see the following interface. That is, the password needs to be reset when logging in for the first time, and the user name is root.

  1. If you can't enter the GitLab page after deployment, it indicates that there are problems in the above deployment process, and then check it carefully.

  2. There is no page to reset the password, and the following page to enter the user name and password appears. However, we have not set the password at this time, so we can't log in.

At this time, enter the cd /opt/gitlab/bin directory through the command line and execute

gitlab-rails console prodection

If the command prompts an error, execute:

sudo gitlab-rails console -e production

If the instruction is executed normally, the following interface will appear and perform the following operations:

  • Switch to root and enter u = User.where(id:1).first
  • Set password: u.password='12345678 '
  • Confirm password: u.password_confirmation='12345678'
  • Save settings:!
  • If true appears, the setting is successful. Enter exit to exit and return to the command line mode

At this point, go to the GitLab page just now, enter the user name and password. The user name is root and the password is 12345678 we just set, and you can log in.

After logging in, even if you use it yourself, you'd better create a separate user instead of using root directly.

Welcome to WeChat official account: Quant_Times

Tags: git GitLab Alibaba Cloud

Posted on Tue, 21 Sep 2021 17:59:02 -0400 by amchargue