GitLab is a self-managed Git project repository that was developed by Ruby and provides a web interface for access to public or private projects. This topic describes how to install and use GitLab on an Elastic Compute Service (ECS) instance.


An ECS instance is created and meets the following requirements:
  • The instance has at least two vCPUs and 4 GiB of memory. In this example, the following instance type and operating system are used:
    • Instance type: ecs.c6.large
    • Operating system: CentOS 7.2 64-bit
    For more information about how to create an instance, see Create an instance by using the wizard.
  • An inbound rule is added to the security group of the instance to allow traffic on port 80. For more information, see Add a security group rule.

Manually deploy a GitLab environment

  1. Install the dependency.
    sudo yum install -y curl policycoreutils-python openssh-server
    • In this example, the instance that runs a 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 when you run the preceding command on the instance. This is because the dependency is not included in the software repository of CentOS 8. The absence of this dependency does not affect the deployment of GitLab. You can ignore this issue and proceed to run subsequent commands.
    • Additionally, CentOS 8 reached its end of life (EOL). If you use instances that run CentOS 8 operating systems, change the CentOS 8 repository address. For more information, see Change CentOS 8 repository addresses.
  2. Configure SSH.
    1. Run the following command to start SSH:
      sudo systemctl start sshd
    2. Run the following command to configure SSH to start on instance startup:
      sudo systemctl enable sshd
  3. Install Postfix to send notification emails.
    sudo yum install postfix
  4. Configure Postfix to start on instance startup.
    sudo systemctl enable postfix
  5. Start Postfix.
    1. Run the following command to open the file:
      vim /etc/postfix/
    2. Find the code line shown in the following figure and 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 then press the Enter key to save and close the file.
    5. Run the following command to start Postfix:
      sudo systemctl 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 choose Instances & Images > Instances in the left-side navigation pane in the ECS console and obtain the public IP address of the ECS instance from the Instances page.
  8. Use a browser to access the public IP address of the ECS instance.
    The following page indicates that GitLab is installed. You must set the GitLab 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 to GitLab. gl3
  2. Creates 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:
      KeyRun 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, click New Project to create a project.
    4. Set the required parameters. Then, click Create project.
    5. Add an SSH key.
      1. Click add an SSH key. import-sshkey-1
      2. Import the content of the public key file generated in Step ii. import-sshkey-2
      The following page indicates that the SSH key is added. import-ssh-key-complete
    6. Record the address of the new project for future use.
      Project address
  3. Configure GitLab.
    1. Add the username of the GitLab user.
      git config --global "testname" 
    2. Add the email address of the GitLab user.
      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 project files are available in the directory.
      git clone git@iZ****3Z: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 that you want to upload to GitLab.
      echo "test" > /root/
    3. Copy the file or directory to the local project directory.
      cp /root/ ./ 
      Upload a file
    4. Add the file to the index.
      git add
    5. Commit the file to the local GitLab repository.
      git commit -m ""
    6. Push the file to the ECS instance.
      git push -u origin master
      Git push commands to push the file
      The file is pushed to GitLab and displayed on the Project page. Push results