GitLab is a Ruby-based open-source version management system. It provides the code management tool Git and the self-hosted Git repository to support your Web access to public and private projects. This document describes how to install and use GitLab on Tencent Cloud CVM.
The CVM instance needs to be configured with:
- vCPU: 2 cores
- Memory: 4 GB
- Linux operating system: this document uses CentOS 7.7 as an example
- See Log in to Linux Instances Using the Standard Login Method. You can also use other login methods that you are more comfortable with:
- Run the following command to install dependencies.
yum install -y curl policycoreutils-python openssh-server
- Run the following commands in sequence to enable SSH service autostart and start the SSH service.
systemctl enable sshd
systemctl start sshd
- Run the following command to install Postfix.
yum install -y postfix
- Run the following command to enable Postfix service autostart.
systemctl enable postfix
- Run the following command to open Postfix’s configuration file main.cf.
- Press i to enter the editing mode. Delete
inet_interfaces = all, and add
inet_interfaces = localhost, as shown below:
- Press Esc and enter :wq to save and close the file.
- Run the following command to start Postfix.
systemctl start postfix
- Run the following command to add the GitLab software repository.
curl https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.rpm.sh | sudo bash
- Run the following command to install GitLab.
For more information about how to obtain the public IP of the instance, see Getting Public IP Addresses.
sudo EXTERNAL_URL="Public IP address of the instance" yum install -y gitlab-ce
- In a local browser, visit the public IP address that you have obtained. If the following page appears, GitLab has been installed successfully.
Configure the password for your GitLab account here.
- In a local browser, visit the public IP address of your CVM to access the GitLab login page. Enter your
root account and the configured password, as shown below:
- Create a private project as instructed. This document uses
test as an example in the following figure:
- After the project is created, click Add SSH Key at the top of the page.
- On the SSH Keys page, add a SSH key by performing the following steps:
- Get the key for the PC to be managed by the project and paste it in the
- Enter the key name in the
- Click Add key as shown below:
If the result is similar to the following figure, the key has been added successfully:
- On the project homepage, click clone to record the project address, as shown below:
- Run the following command on the managed PC to configure the username of the Git repository.
git config --global user.name "username"
- Run the following command to configure the email for the username.
git config --global user.email "firstname.lastname@example.org"
- Run the following command to clone the project. Replace the project address with the actual values obtained in Step 5.
After the project is successfully cloned, the same directory and all project files will be generated on your local computer.
git clone “Project address”
- Run the following command to access the project directory.
- Run the following command to create the target file to be uploaded to GitLab. This document uses the test.sh file as an example.
echo "test" > test.sh
- Run the following command to add the test.sh file to the index.
git add test.sh
- Run the following command to submit the test.sh to the local repository.
git commit -m "test.sh"
- Run the following command to synchronize the test.sh file with the GitLab server.
Go back to the test project page. You can now see the file on the page, as shown below:
git push -u origin master
Getting the key
- On the PC to be managed by the project, run the following command to install Git.
yum install -y git
- Run the following command to generate the key file “.ssh/id_rsa”. During the key file generation process, press Enter to keep the default configurations.
- Run the following command to view and record the key information.