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.
Prerequisites
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
- Install the dependency.
sudo yum install -y curl policycoreutils-python openssh-server
Note
- 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.
- Configure SSH.
- Run the following command to start SSH:
sudo systemctl start sshd
- Run the following command to configure SSH to start on instance startup:
sudo systemctl enable sshd
- Install Postfix to send notification emails.
- Configure Postfix to start on instance startup.
sudo systemctl enable postfix
- Start Postfix.
- Run the following command to open the main.cf file:
- Find the code line shown in the following figure and press the I key to enter the edit mode.
- Change the code line to
inet_interfaces = all
.
- Press the Esc key to exit the edit mode, enter
:wq
, and then press the Enter key to save and close the file.
- Run the following command to start Postfix:
sudo systemctl start postfix
- Add the GitLab software package repository.
curl https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.rpm.sh | sudo bash
- Install GitLab.
sudo EXTERNAL_URL="<Public IP address of the ECS instance>" yum install -y gitlab-ce
Note You can choose in the left-side navigation pane in the ECS console and obtain the public IP address
of the ECS instance from the Instances page.
- 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.

Use GitLab
- 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.

The following page indicates that you are logged on to GitLab.

- Creates a project.
- Use the software repository provided by Linux to install Git.
yum install git

- Generate a key file.
Run the following command to generate the
.ssh/id_rsa key file:
ssh-keygen

Run the following command to view the content of the
id_rsa.pub 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/id_rsa.pub

- On the GitLab homepage, click New Project to create a project.
- Set the required parameters. Then, click Create project.
- Add an SSH key.
- Click add an SSH key.

- Import the content of the public key file generated in Step ii.

The following page indicates that the SSH key is added.

- Record the address of the new project for future use.
- Configure GitLab.
- Add the username of the GitLab user.
git config --global user.name "testname"
- Add the email address of the GitLab user.
git config --global user.email "abc@example.com"
- 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

- Upload a file.
- Access the local project directory you created in the previous step.
- Create a file that you want to upload to GitLab.
echo "test" > /root/test.sh
- Copy the file or directory to the local project directory.
cp /root/test.sh ./

- Add the test.sh file to the index.
- Commit the test.sh file to the local GitLab repository.
- Push the file to the ECS instance.
git push -u origin master

The
test.sh file is pushed to GitLab and displayed on the Project page.
