Hint: You can use the Tab key to autocomplete all filenames and directories, so you don't have to type in the complete file or directory name manually.
This tutorial was last checked and updated on April 3, 2023.
- If you havn't already done so, download the program "PuTTY".
- Connect to your root server or VPS/vServer via SSH using PuTTY. To do this, open PuTTY and enter the domain or IP address of your server in the text box named "Host Name (or IP address)". Then click the "OK" button below.
- Update your package lists with the command
apt update
. - Now install any available updates of the packages already installed on your server using the command
apt upgrade -y
. - Next, install the packages needed for future installations in this tutorial by executing the following command:
apt install curl nano -y
- If you want to use your own mail server to send e-mails (e.g. for user account activations), then I recommend the Mailcow mail server. I've also published a tutorial for this. Alternatively, you can also use Postfix, but Mailcow is recommended. However, if you want to install Postfix, use the command
apt install postfix -y
, select "internet site" during the installation and enter your domain as the "system e-mail name". If you want to use an external SMTP server (Gmail, Mailgun etc.) or Mailcow to send e-mails from GitLab, then skip this step and continue with step 10 of this tutorial after you've installed GitLab (SMTP configuration). - Add the repository needed to install GitLab:
- Use the following command to add the key needed for the GitLab repository:
curl -fsSL https://packages.gitlab.com/gitlab/gitlab-ee/gpgkey | gpg --dearmor -o /usr/share/keyrings/gitlab-archive-keyring.gpg
- Add the repository needed to install GitLab by executing this command:
For Debian:echo "deb [signed-by=/usr/share/keyrings/gitlab-archive-keyring.gpg] https://packages.gitlab.com/gitlab/gitlab-ee/debian/ $(lsb_release -sc) main" > /etc/apt/sources.list.d/gitlab.list
For Ubuntu:echo "deb [signed-by=/usr/share/keyrings/gitlab-archive-keyring.gpg] https://packages.gitlab.com/gitlab/gitlab-ee/ubuntu/ $(lsb_release -sc) main" > /etc/apt/sources.list.d/gitlab.list
- Use the following command to add the key needed for the GitLab repository:
- Now update your package lists again with the command
apt update
. - Install GitLab and other required packages with the following command:
EXTERNAL_URL="http://gitlab.domain.com" apt install gitlab-ee -y
. Replace "http://gitlab.domain.com" with the URL, that you want to use to access the GitLab web interface. Note: The default web server port 80 will be used. If a web server like Apache2 is already installed, then you have to choose a different port. In this case, just enter the desired port behind the URL (e.g. "http://gitlab.domain.com:8888" for port 8888). - Optional (if you want to use Mailcow or an external SMTP server to send e-mails) :
- Open the GitLab configuration file by executing the command
nano /etc/gitlab/gitlab.rb
- Go to the SMTP configuration section starting at line 80 of this file and remove the "#" characters on the beginning of lines 85 to 94. Then customize the SMTP configuration to match the SMTP server you want to use. You can find some information, including the SMTP configuration for Mailcow, here.
- Save your changes to the configuration by pressing CTRL + X, then hit the "Y" key followed by enter.
- Now you have to regenerate the GitLab configuration. To do this, enter the command
gitlab-ctl reconfigure
and restart GitLab by using the commandgitlab-ctl restart
.
- Open the GitLab configuration file by executing the command
- Run the command
cat /etc/gitlab/initial_root_password | grep "Password:"
to display the randomly generated initial password of the GitLab user "root". - Next, open the GitLab web interface in your browser under the URL you set during the installation and log in with the user "root" and the initial password you read out earlier.
- You can find several configuration parameters in the file "/etc/gitlab/gitlab.rb". For example, to change the URL of your GitLab installation, enter the command
nano /etc/gitlab/gitlab.rb
to open this file and change the value of the parameter "EXTERNAL_URL" in line 32. Save your changes to the configuration by pressing CTRL + X, then hit the "Y" key followed by enter and regenerate the GitLab configuration using the commandgitlab-ctl reconfigure
. After you've done this, GitLab needs to be restarted. Use the commandgitlab-ctl restart
to do this.