GitLab is a self-managed Git project warehouse developed by Ruby and provides access to public or private projects through a web interface. This topic describes how to install and use GitLab on an ECS instance.


An Alibaba Cloud account is created. To create an Alibaba Cloud account, go to the account registration page.

An ECS instance is created and meets the following requirements:
  • The instance has at least two vCPUs and 4 GiB of memory. In the examples in this topic, the instance uses the following configurations:
    • Instance type: ecs.c6.large
    • Operating system: CentOS 7.2 64-bit
  • The security group rule described in the following table is added to the security group of the instance. For more information, see Add security group rules.
    Direction Protocol Port range Authorization object
    Inbound HTTP(80) 80

Manually install GitLab

  1. Install the dependency package.
    sudo yum install -y curl policycoreutils-python openssh-server
    Note In the examples in this topic, the CentOS 7.2 64-bit operating system is used. If you use an ECS instance that runs CentOS 8, you cannot find the policycoreutils-python dependency package when you run the preceding command on the instance. This is because the dependency package is not included in the software source of CentOS 8. The absence of this dependency package does not affect the deployment of GitLab. You can ignore this issue and continue to run subsequent commands.
  2. Set SSH to run at startup and start SSH.
    sudo systemctl enable sshd
    sudo systemctl start sshd
  3. Install Postfix to send notification emails.
    sudo yum install postfix
  4. Set Postfix to run at startup.
    sudo systemctl enable postfix
  5. Start Postfix.
    1. Run the vim /etc/postfix/ command to open the file and find the code line shown in the following figure.
    2. Press the I key to enter the edit mode.
    3. Change the code line to inet_interfaces = all.
    4. Press the Esc key to exit the edit mode. Enter :wq and press the Enter key to save and close the file.
    5. Run the sudo systemctl start postfix command to start Postfix.
  6. Add the GitLab software package repository.
     curl | sudo bash
  7. Install GitLab.
    sudo EXTERNAL_URL="<Public IP address of the ECS instance>" yum install -y gitlab-ce
    Note You can obtain the public IP address of the ECS instance from the Instances page in the ECS console.
  8. Use a browser to access the public IP address of the ECS instance.
    The following page indicates that GitLab is installed. You must reset the GitLab root password.gitlab1

Use GitLab

  1. Log on to GitLab.
    In the address bar of your browser, enter the public IP address of the ECS instance where GitLab is installed and press the Enter key. The GitLab logon page is displayed. Use the root username and the new password that you set at your first logon to log on.gl2
    The following page indicates that you are logged on.gl3
  2. Create a project.
    1. Use the software repository provided by Linux to install Git.
      yum install git
    2. Generate a key file.
      Run the following command to generate the .ssh/id_rsa key file:
      KeysRun the following command to view the content of the public key file. In the next step, you must paste the content into the SSH key configuration file on the ECS instance where GitLab is installed.
      cat .ssh/
      Public key
    3. On the GitLab homepage, create a project.
    4. Add an SSH key and import the content of the key file generated in Substep b.
      The following page indicates that the SSH key is added.import-ssh-key-complete
    5. Record the address of the new project for later use.
      Project address
  3. Configure GitLab.
    1. Add the name of the user who will use GitLab.
      git config --global "testname" 
    2. Add the email address of the user who will use GitLab.
      git config --global "" 
    3. Clone the project you created in the previous step to create a local directory that has the same name as the project. All the project files are available in the directory.
      git clone git@iZxxxxxxxxxxxxxxxxx3Z:root/test.git
      Configure GitLab
  4. Upload a file.
    1. Access the local project directory you created in the previous step.
      cd test/ 
    2. Create a file as the target file to upload to GitLab.
      echo "test" > /root/
    3. Copy the target file or directory to the local project directory.
      cp /root/ . / 
      Upload the file
    4. Add the file to the index.
      git add
    5. Commit the file to the local GitLab repository.
      git commit -m ""
    6. Synchronize the file to the ECS instance.
      git push -u origin master
      Command used to synchronize the file
      The file is synchronized to GitLab and displayed on the Project page.File synchronization results