How to install and set up Gitlab CE Server on Rocky/Alma Linux 8

GitLab allows you to host an on-premise Git repository that can be accessed from either your local LAN or (if you have an available public IP address) from outside your company. GitLab is an open-source repository manager based on Rails developed by GitLab Inc. It is a web-based git repository manager that allows your team to collaborate on coding, testing, and deploying applications. GitLab provides several features, including wikis, issue tracking, code reviews, and activity feeds.

In this guide, we will install the GitLab CE on a Rocky/Alma Linux 8 server. We will install the GitLab CE using the ā€˜omnibusā€™ package provided by GitLab.

Related content:

Prerequisites

  • Updated Rocky Linux 8 server
  • Access to the internet
  • Ensure that your server is at lease 4GB of RAM with more than 20GB of disk space and 2 CPUs

Ensure that the server packages are up to date

Before proceeding let us update our Rocky Linux server using this command:

sudo dnf -y update

Install common packages that will be essential

sudo dnf install -y vim

Install and configure the necessary dependencies

Before proceeding letā€™s ensure that the pakages needed are installed. Use this command:

sudo dnf install -y curl policycoreutils openssh-server perl

Next, ensure that the ssh server is started and enabled to start on boot:

sudo systemctl start sshd
sudo systemctl enable sshd

If you have firewall enabled, open up http and https traffic using this command:

sudo firewall-cmd --permanent --add-service={ssh,http,https} --permanent 
sudo firewall-cmd --reload

Our Gitlab CE server will be sending emails. Let us install postfix for this purpose:

sudo dnf install -y postfix

Then letā€™s enable and start the service:

sudo systemctl enable postfix
sudo systemctl start postfix

Confirm that postfix was installed and started successfully:

$ sudo systemctl status postfix
● postfix.service - Postfix Mail Transport Agent
     Loaded: loaded (/usr/lib/systemd/system/postfix.service; enabled; vendor preset: disabled)
     Active: active (running) since Tue 2022-10-25 06:20:58 UTC; 34s ago
    Process: 543665 ExecStartPre=/usr/sbin/restorecon -R /var/spool/postfix/pid/master.pid (code=exited, status=255/EXCEPTION)
    Process: 543666 ExecStartPre=/usr/libexec/postfix/aliasesdb (code=exited, status=0/SUCCESS)
    Process: 543670 ExecStartPre=/usr/libexec/postfix/chroot-update (code=exited, status=0/SUCCESS)
    Process: 543671 ExecStart=/usr/sbin/postfix start (code=exited, status=0/SUCCESS)
   Main PID: 543739 (master)
      Tasks: 3 (limit: 21385)
     Memory: 5.0M
        CPU: 450ms
     CGroup: /system.slice/postfix.service
             ├─543739 /usr/libexec/postfix/master -w
             ├─543740 pickup -l -t unix -u
             └─543741 qmgr -l -t unix -u

Oct 25 06:20:57 unstable-rockysrv systemd[1]: Starting Postfix Mail Transport Agent...
Oct 25 06:20:57 unstable-rockysrv restorecon[543665]: /usr/sbin/restorecon: lstat(/var/spool/postfix/pid/master.pid) failed: No such file or directory
Oct 25 06:20:58 unstable-rockysrv postfix/postfix-script[543737]: starting the Postfix mail system
Oct 25 06:20:58 unstable-rockysrv postfix/master[543739]: daemon started -- version 3.5.9, configuration /etc/postfix
Oct 25 06:20:58 unstable-rockysrv systemd[1]: Started Postfix Mail Transport Agent.

Add the GitLab package repository and install the package

Add the GitLab package repository.

curl https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.rpm.sh | sudo bash

Next, install the GitLab package. We will use a custom domain to access our Gitlab instance. Ensure that you have mapped the DNS records for your domai to point to the server where you are installing Gitlab. Installation will automatically configure and start GitLab at that URL.

sudo EXTERNAL_URL="http://gitlab.citizix.com" dnf install -y gitlab-ce

Configuring Gitlab CE

Now that gitlab is successfully installed, letā€™s configure it. The main configuration file can be found in the file/etc/gitlab/gitlab.rb. Open the file (vim /etc/gitlab/gitlab.rb) and confirm that the external url is set as defined during installation:

external_url 'http://gitlab.citizix.com'

Save & and run the reconfiguration script

sudo gitlab-ctl reconfigure

Wait for the configuration script to finish. You should see something similar to this:

Recipe: gitlab::database_reindexing_disable
  * crond_job[database-reindexing] action delete
    * file[/var/opt/gitlab/crond/database-reindexing] action delete (up to date)
     (up to date)
[2022-10-25T06:56:12+00:00] INFO: Cinc Client Run complete in 23.97298455 seconds

Running handlers:
[2022-10-25T06:56:12+00:00] INFO: Running report handlers
Running handlers complete
[2022-10-25T06:56:12+00:00] INFO: Report handlers complete
Infra Phase complete, 0/776 resources updated in 30 seconds
gitlab Reconfigured!

Accessing Gitlab CE

Once the configuration is complete, Gitlab CE is available in the URL provided (In my caseĀ http://gitlab.citizix.com. Ensure that the DNS entry for the URL is pointing to the server then access that url in the browser. You should be redirected to the login page as shown below:

Gitlab CE Sign in Page

Unless you provided a custom password during installation, a password will be randomly generated and stored for 24 hours inĀ /etc/gitlab/initial_root_password. Use this password with usernameĀ rootĀ to login.

sudo cat /etc/gitlab/initial_root_password

Once logged in you can use the gitlab server to create and manange projects and repositories.

Conclusion

Congratulations, you now have your local GitLab up and running.Ā  You can now use your Gitlab CE Server to manage repositories and projects.

Have fun!

comments powered by Disqus
Citizix Ltd
Built with Hugo
Theme Stack designed by Jimmy