Overview
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.
Software
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
Prerequisites
The security group rules for the Linux instance have already been configured. Open the port 80. For more information, see Adding Security Group Rules. Directions
Installing GitLab
2. Run the following command to install dependencies.
yum install -y curl policycoreutils-python openssh-server
3. Run the following commands in sequence to enable SSH service autostart and start the SSH service.
4. Run the following command to install Postfix.
5. Run the following command to enable Postfix service autostart.
6. Run the following command to open Postfix’s configuration file main.cf.
7. Press i to enter the editing mode. Delete #
before inet_interfaces = all
, and add #
before inet_interfaces = localhost
, as shown below:
8. Press Esc and enter :wq to save and close the file.
9. Run the following command to start Postfix.
10. 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
11. Run the following command to install GitLab.
sudo EXTERNAL_URL="Public IP address of the instance" yum install -y gitlab-ce
12. In a local browser, visit the public IP address that you have obtained. If the following page appears, GitLab has been installed successfully.
Note:
Configure the password for your GitLab account here.
Creating projects
1. 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:
2. Create a private project as instructed. This document uses test
as an example in the following figure:
3. After the project is created, click Add SSH Key at the top of the page.
4. On the SSH Keys page, add a SSH key by performing the following steps:
4.1 Get the key for the PC to be managed by the project and paste it in the Key
field. 4.2 Enter the key name in the Title
field.
4.3 Click Add key as shown below:
If the result is similar to the following figure, the key has been added successfully:
5. On the project homepage, click clone
to record the project address, as shown below:
Cloning projects
1. Run the following command on the managed PC to configure the username of the Git repository.
git config --global user.name "username"
2. Run the following command to configure the email for the username.
git config --global user.email "xxx@example.com"
3. Run the following command to clone the project. Replace the project address with the actual values obtained in Step 5. git clone “Project address”
After the project is successfully cloned, the same directory and all project files will be generated on your local computer.
Uploading files
1. Run the following command to access the project directory.
2. Run the following command to create the target file to be uploaded to GitLab. This document uses the test.sh file as an example.
3. Run the following command to add the test.sh file to the index.
4. Run the following command to submit the test.sh to the local repository.
5. Run the following command to synchronize the test.sh file with the GitLab server.
git push -u origin master
Go back to the test project page. You can now see the file on the page, as shown below:
Relevant Operations
Getting the key
1. On the PC to be managed by the project, run the following command to install Git.
2. 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.
3. Run the following command to view and record the key information.
Was this page helpful?