Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to install and use GitLab under Linux

2025-03-04 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly introduces how to install and use GitLab under Linux related knowledge, the content is detailed and easy to understand, the operation is simple and fast, with a certain reference value, I believe you will have a harvest after reading this article on how to install and use GitLab under Linux, let's take a look.

Install 1. Configure yum Feed

Vim / etc/yum.repos.d/gitlab-ce.repo

Copy the following:

[gitlab-ce] name=Gitlab CE Repositorybaseurl= https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el$releasever/gpgcheck=0enabled=12. Update the local yum cache

Yum makecache

3. Install GitLab Community Edition

Yum install gitlab-ce # automatically installs the latest version

Note: if you need to install the specified version, you can add the version number, namely yum install gitlab-ce-x.x.x

4. Turn on GitLab

Gitlab-ctl start

* Common GitLab commands *

Gitlab-ctl start # starts all gitlab components

Gitlab-ctl stop # stop all gitlab components

Gitlab-ctl restart # restart all gitlab components

Gitlab-ctl status # View service status

Gitlab-ctl reconfigure # start the service; (reload the configuration file, which can be used after GitLab is installed for the first time, but it cannot be used arbitrarily in the business environment. Reconfigure will restore some of the past config, resulting in the loss of modified ports and domain names. )

Vim / etc/gitlab/gitlab.rb # modify the default configuration file

Gitlab-rake gitlab:check SANITIZE=true-trace # check gitlab

Sudo gitlab-ctl tail # View logs

GitLab uses 1. Log in to GitLab

Enter the server's public network IP in the browser's address bar to display the GitLab interface. The first login will force the user to change the password. After the password has been changed successfully, enter the user name and password to log in.

Note: if the service cannot be accessed, you can use the ps-ef command to check whether the service starts normally. If it is not started, restart it. If it still fails to start, you can use the gitlab-ctl reconfigure command to start the service, and then access GitLab.

two。 Create Project

After a successful login, the following page appears:

3. Modify domain name

Since there is no DNS server, the domain name cannot be resolved, so you need to modify the host name of the domain name and go to the terminal to modify the file.

Vim / opt/gitlab/embedded/service/gitlab-rails/config/gitlab.yml

# # GitLab settings gitlab: # # Web server settings (note: host is the FQDN, do not include http://) host: 10.0.0.210 port: 8888 https: false restart GitLab

Gitlab-ctl restart

Refresh the GitLab page to see if the modification is successful

Backup and recovery of GitLab GitLab create backup

Gitlab-rake gitlab:backup:create

Using the above command, by default, a zip file named 1520580592_2018_03_09_10.5.3_gitlab_backup.tar is created in the / var/opt/gitlab/backups directory, which is the entire part of Gitlab, where the first 1520580592, 2018, 03, 09, 10.5.3 is the date on which the backup was created.

two。 Delete project

Click the "Remove project" button at the bottom of the created project page to delete the project.

There is no project now

3.GitLab recovery

Stop related data connection services

Gitlab-ctl stop unicorn

Gitlab-ctl stop sidekiq

Restore from backup no. 1520580592 / 2018 / 03 / 09 / 10.5.3

Gitlab-rake gitlab:backup:restore BACKUP=1520580592_2018_03_09_10.5.3

Start Gitlab

Gitlab-ctl start

4. Check to see if project is restored in the GitLab page.

* * Gitlab*** modify the default directory of backup files *

You can modify the directory where backup files are stored by default by modifying / etc/gitlab/gitlab.rb.

Vim / etc/gitlab/gitlab.rb

Gitlab_rails ['backup_path'] = "/ mnt/gitlab/backup" > > modify the file path and then use the gitlab-ctl reconfigure command to reload the configuration file.

Note: because it involves reloading the configuration, * * reconfigure will restore some past config, resulting in the loss of the modified port and domain name. It is recommended to modify the default path of the warehouse after the service is installed. If you modify this in the later business, it will have a certain impact on the business. If you need to modify this item in the later business, please prepare in advance, and then modify the corresponding parameters in the configuration file. **

You will find that the permissions of / mnt/gitlab/backup have changed after reloading the configuration file.

* * modify the default path of the warehouse *

Modify the configuration file to find git_data_dirs

Vim / etc/gitlab/gitlab.rb

# git_data_dirs ({# "default" = > {# "path" > "/ mnt/nfs-01/git-data" #} #}) git_data_dir "/ data/gitlab" > > add a custom warehouse path here. The directory needs to be created in advance and add a sentence "/ data/gitlab" under git_data_dir.

two。 Stop the current gitlab and reload the configuration

Note: the modification of the warehouse path will lead to the loss of the existing * * project. Please back up in advance. For specific backup operations, please refer to "backup and recovery of GitLab" above, and then modify the corresponding parameters in the configuration file. **

Gitlab-ctl stop

Gitlab-ctl reconfigure

3. After reloading, you will find that there is an extra repositories directory in the / data/gitlab directory

4. Finally, start gitlab.

Gitlab-ctl start

* * GitLab* service port modification *

The configuration file path of GitLab installed in yum mode is / var/opt/gitlab/nginx/conf (the configuration file path of other installation methods may not be the same, please find it yourself).

1. Modify the configuration file

Vim / var/opt/gitlab/nginx/conf/gitlab-http.conf

# # configuration # # upstream gitlab-workhorse {server unix:/var/opt/gitlab/gitlab-workhorse/socket;} server {listen *: 8888; > modify the port here to restart the service

Gitlab-ctl restart

3. Visit ip:port to see if the page is working properly

Note * * 1: after the port is modified, the IP in project needs to be modified accordingly. Please refer to "modify Domain name" above and modify the port parameter. **

Note 2: after executing the gitlab-ctl reconfigure command, the configuration file will be reloaded and the service port will be restored to the default port 80, so if you need to modify the port, please do so after the above two steps.

Be careful not to conflict ports in Gitlab deployment.

This is the end of the article on "how to install and use GitLab under Linux". Thank you for reading! I believe you all have a certain understanding of "how to install and use GitLab under Linux". If you want to learn more, you are welcome to follow the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report