How to Install GitLab on Debian 9
A fresh installed Debian 9 server
A sudoer system user
8GB of memory or higher
For more details about hardware requirements, please refer to this link https://docs.gitlab.com/ce/install/requirements.html
Log in to your server via SSH:
# ssh root@server_ip
Before starting with the GitLab installation, it is encouraged to check that our system package database is up to date.
Update the system
# apt update # apt upgrade
Now, make sure that we are not running a web server on port 80 because GitLab will install nginx on that port and enable it on boot
# systemctl stop apache2 # systemctl disable apache2
Create a system user
# adduser gituser
# usermod -aG sudo gituser
Start the GitLab installation
To start the installation, we need to switch to the regular user we created earlier
# su gituser $ cd $ sudo apt install ca-certificates curl
Add the GitLab package repository.
In this tutorial, we will install GitLab CE (Community Edition), and we have to add the package repository to continue with the installation.
$ sudo curl -LO https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.deb.sh
$ sudo bash script.deb.sh
After adding the repository, run the following command to install GitLab Community Edition on Debian 9
$ sudo apt install gitlab-ce
Next, we need to edit the gitlab.rb file, find external_url string and edit it to your server IP address or domain you want to use to access GitLab.
$ sudo nano /etc/gitlab/gitlab.rb
$ sudo gitlab-ctl reconfigure
The installation will take a few minutes to complete, it will automatically configure and install nginx web server to run GitLab at that defined URL.
Once completed, navigate to your server IP address or domain name you previously specified in external_url in /etc/gitlab/gitlab.rg in a web browser, you will need to create a new password.
Once created you can log in to your GitLab backend using “root” user and the new password you created earlier. You can change this “root” username in Settings – Account.
gitlab-ctl is the command line utility you can use to manage GitLab. For example, you can start/stop it using the following commands:
$ sudo gitlab-ctl start
$ sudo gitlab-ctl stop
Additional configuration for application email:
By default, GitLab will use sendmail to send emails from the application. If you would rather send application email via an SMTP server instead of via Sendmail, add the following configuration information to /etc/gitlab/gitlab.rb
gitlab_rails['smtp_enable'] = true gitlab_rails['smtp_address'] = "smtp.gmail.com" gitlab_rails['smtp_port'] = 587 gitlab_rails['smtp_user_name'] = "email@example.com" gitlab_rails['smtp_password'] = "my-gmail-password" gitlab_rails['smtp_domain'] = "smtp.gmail.com" gitlab_rails['smtp_authentication'] = "login" gitlab_rails['smtp_enable_starttls_auto'] = true gitlab_rails['smtp_tls'] = false gitlab_rails['smtp_openssl_verify_mode'] = 'peer' # Can be: 'none', 'peer', 'client_once', 'fail_if_no_peer_cert', see http://api.rubyonrails.org/classes/ActionMailer/Base.html
Once edited, you can run this command:
$ sudo gitlab-ctl reconfigure
How to Backup GitLab on Debian 9
The default data backup will be stored in /var/opt/gitlab/backups. You can modify this backup path in /etc/gitlab/gitlab.rb file. If you made changes to the backup configuration, do not forget to run the following command to create the backup.
$ sudo gitlab-rake gitlab:backup:create
You can also add the same command in the cron job to backup your data.
0 3 * * 2-6 sudo gitlab-rake gitlab:backup:create
That’s it, GitLab has been successfully installed and running on your Debian 9 server, you and your team can start working with it now.