Gitlab is an online code repository hosting software based on Git implementation. You can use GitLab to build a system similar to Github, which is convenient for an enterprise, organization or school to develop and learn.

Today I will share the installation and configuration of GitLab on the server, taking Debian as an example.

1. Install GitLab

Gitlab has two versions, CE and EE, which are free community version and enterprise version with paid functions respectively. Usually, small organizations can use the community version. Today, we will also install the community version as an example.

First install dependencies:

sudo apt install curl openssh-server ca-certificates perl postfix
Copy the code

The Postfix configuration page is displayed during the installation:

Select Internet Site, ok, next fill in mail name, choose your own:

Then add gitLab’s warehouse:

curl -sS https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.deb.sh | sudo bash
Copy the code

Then install gitlab-CE:

sudo apt install gitlab-ce
Copy the code

The installation package is very large and may take a long time. Wait until the installation is complete!

2. Configure GitLab

Go to /etc/gitlab/gitlab.rb, this is the gitlab configuration file, open it with a text editor, we just need to modify some common configurations.

Most of the configuration is commented out by default with the leading #, remember to uncomment the leading # first before configuring the value.

(1) Configure the access address

In the configuration file, find external_url and change it to your server access domain name or IP address. If you do not want to use the standard port, you can also set it to another port (for example, xx.com:2122). Generally, set it to the Intranet server address:

If your address is HTTPS, you will also need to configure an SSL certificate, have a valid CRT certificate ready, and modify the following configuration items:

nginx['enable'] = true nginx['redirect_http_to_https'] = true nginx['redirect_http_to_https_port'] = 80 Nginx ['ssl_certificate_key'] = "certificate key"Copy the code

(2) Permission configuration

Normal users of gitlab can also create groups by default, but in general this needs to be turned off. Go to gitlab_rails[‘gitlab_default_can_create_group’] and set it to false:

(3) Mailbox configuration

First of all to prepare a mailbox, 163, QQ can be, and open SMTP service.

Then locate the following configuration values and configure them as follows:

Gitlab_rails ['smtp_enable'] = true gitlab_rails['smtp_address'] = "SMTP server address" gitlab_rails['smtp_port'] = 465 Gitlab_rails ['smtp_user_name'] = "Your email" gitlab_rails['smtp_password'] = "authorization code" gitlab_rails['smtp_domain'] = "SMTP server address" gitlab_rails['smtp_authentication'] = "login" gitlab_rails['smtp_enable_starttls_auto'] = true gitlab_rails['smtp_tls'] Gitlab_rails ['gitlab_email_from'] = true gitlab_rails['smtp_pool'] = false Gitlab_rails ['gitlab_email_display_name'] = 'Sender display name'Copy the code

Note that gitlab_rails[‘gitlab_email_from’] must also be configured as your email address, and now most mail is sent using port 465, so gitlab_rails[‘ smtp_TLS ‘] must be true.

(4) Code storage location configuration

Find git_data_dirs and change path to the custom value:

There is no special need to configure this.

(5) Backup Settings

Find the following configuration and configure it as follows:

Gitlab_rails [' manage_backup_PATH '] = true gitlab_rails[' backup_PATH '] = "Backup location" gitlab_rails['backup_keep_time'] = 604800Copy the code

Gitlab_rails [‘backup_keep_time’] indicates the backup retention duration.

Backup Settings can be modified without special requirements.

Finally, run the following command to reload the configuration:

sudo gitlab-ctl reconfigure
Copy the code

3. Access and log in to the administrator account

Once the startup is complete, you can access the server address and log in.

The default administrator account name is root and the password can be found in the /etc/gitlab/initial_root_password file:

Change the administrator password after login.

4,

The basic installation configuration is now complete. Here are some reference addresses:

  • Gitlab official installation instructions
  • Gitlab official configuration document
  • Uninstall gitLab reference completely