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:
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.
sudo EXTERNAL_URL="Public IP address of the instance" yum install -y gitlab-ce
For more information about how to obtain the public IP of the instance, see Getting Public IP Addresses.
12. 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.
rootaccount and the configured password, as shown below:
testas an example in the following figure:
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.
git clone “Project address”
After the project is successfully cloned, the same directory and all project files will be generated on your local computer.
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.
git push -u origin master
Go back to the test project page. You can now see the file on the page, as shown below:
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.