1. Download the RPM installation package

Download address:

https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/
Copy the code

To download the RPM package in your own file, I selected the latest version:

Wget HTTP: / / https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/gitlab-ce-11.6.10-ce.0.el7.x86_64.rpmCopy the code

2, file authorization, grant execute permission on the line, here directly to 777

Chmod 777 gitlab - ce - 11.6.10 - ce. 0. El7. X86_64. RPMCopy the code

3, installation,

The RPM - the ivh gitlab - ce - 11.6.10 - ce. 0. El7. X86_64. RPMCopy the code

If you find that the “policycoreutils-python” dependency is missing:

Continue installation:

yum -y install policycoreutils-python
Copy the code

The installation is complete

4, configuration,

Editing a Configuration File

vim /etc/gitlab/gitlab.rb
Copy the code

Gitllab contains modules that occupy ports 80 (Nginx), 8082 (Sidekiq), and 9090 (Prometheus), which may conflict with the system default ports. Therefore, you are advised to modify the default port configuration

external_url 'http://192.168.31.32:8083/gitlab'
unicorn['port'] = 8081
Copy the code

Restart the service

# gitlab.rb (gitlab.rb)
gitlab-ctl reconfigure
gitlab-ctl restart
gitlab-ctl status
Copy the code

5. Note that if the firewall is not closed, close the firewall first, otherwise the access will fail

Checking the Firewall Status

firewall-cmd --state
Copy the code

Stop the firewall

systemctl stop firewalld.service
Copy the code

Disable the firewall startup upon startup

systemctl disable firewalld.service 
Copy the code

You can directly access, my address is: http://192.0.0.179:8083/gitlab

6. Start using

For the first time, you will be asked to register your account. You can register according to your own information. After registration, log in to the home page

When creating a new project, git will assign us a default IP address, which is not the IP address of the host and cannot be pinged. Therefore, first change the host to the actual IP address of our host.

Edit the gitlab configuration file gitlab.yml

vim /opt/gitlab/embedded/service/gitlab-rails/config/gitlab.yml
Copy the code

Save and exit, and restart GitLab

gitlab-ctl restart
Copy the code

The clone address will be our host IP when the new project is created.

7. New projects

Fill in the project name as required and click Create.

8. Generate a key pair and upload the public key

Check whether an SSH key is generated. The SSH public key is stored in the ~/. SSH directory of the account home directory by default. Check it out:

Pub (or pairs of files such as id_dsa and id_dsa.pub). The file with the.pub suffix is the public key, and the other file is the key.

If not, use ssh-keygen to create it

# Note that 'C' is capitalized here
ssh-keygen -t rsa -C "[email protected]"
Copy the code

Just press Enter. You are then prompted for your password, and your local key pair is generated.

The public key id_rsa.pub can be found in the folder, or you can use git bash to directly view the contents of the folder and copy the contents

 cat ~/.ssh/id_rsa.pub
Copy the code

Open your GitLab, click on your avatar, and then Settings -> left click on SSH Keys

Paste your public key inside and click Add Key to Add it

9. Submit local projects to GITLab

At this point in gitLab, open the new project that we just created and slide down and you can see the command that we need

In your local project directory, right-click to open Git bash.

Designated account, email address

git config --global user.name "root"

git config --global user.email "youremail.com"

Copy the code

Turn directories into repositories that Git can manage

git init
Copy the code

Associate with a remote library

Git remote add origin XXXCopy the code

Add files to the version library

git add .
Copy the code

Commit to local repository

git commit -m "Initial commit"
Copy the code

Push to remote repository

git push -u origin master
Copy the code

Submit completed