• Get In Touch
June 21, 2016

How to Install and Setup GitLab on CentOS 7

Want your very own server? Get our 1GB memory, Xeon V4, 25GB SSD VPS for £10.00 / month.
Get a Cloud Server

Gitlab is graphical implementation of git, it is an open source repository management and version control system. GitLab is developed on Ruby on Rails. Using GitLab you can host your source code on your own server. This ensures security of the code, and gives you total freedom on the number of users as well as number of repositories and number of files. GitLab provides you with a platform to collaborate on projects and to keep track of changes in code. GitLab is widely used for software development and version control related tasks. In many ways it is similar to GitHub, except you can install it in your own server. It is very popular version control system and used by many prominent companies like Alibaba, IBM, NASA, SpaceX etc.

Features of GitLab

Although there are many features of GitLab, but few notable features are.

  • GitLab provides you web interface to edit files, directories and create merge requests.
  • It is self hosted, hence you have full control over your server and the source code hosted inside.
  • It provides LDAP user authentication and has two factor authentication system which makes the application very secure.
  • You can insert your own branding in the login page and it also supports project import from GitHub and other sources to GitLab.
  • It has lots of features like code reviews, issue tracking, activity feeds and inbuilt wiki.
  • It provides a fine work flow management which gives you ability to create groups for a project, ability to fork a repository as well as it provides ability to manage large binaries with git LFS.
  • GitLab comes with GitLab CI for continuous integration. You can also Docker with GitLab CI.
  • It’s free and open source hence you won’t have to deal with any licensing issues.

Requirements

GitLab supports many Linux operating system but in this tutorial we are going to install GitLab Community Edition into CentOS 7.x.

Requirements to install GitLab –

  • VPS, Cloud or Dedicated Server running CentOS 7.x
  • 1 core CPU can support upto 100 users but recommended 2 core CPU which can easily support up to 500 users.
  • At least 2GB memory combining both RAM and swap.
    Apart from this we will need to install all the required dependencies in the tutorial. If you have more the 500 users using GitLab you can always increase the CPU cores and Memory to add support for more users. If you have very high availability like more the 50000 users you can also run it on multiple application servers.

Installing GitLab

In this guide we will be using a non root account to install GitLab and all the required dependencies. If you are logged in to your server using rootaccount, omit using sudo command from all the commands.

Update the packages of yum using the following command

sudo yum -y update

Now install SSH server on your machine using the command below. If you are installing it on a remote server using an SSH client like putty then you already have openssh-server and openssh-clients installed. If they are already installed you can skip this step.

sudo yum -y install openssh-server openssh-clients
sudo systemctl enable sshd
sudo systemctl start sshd

The first command will install SSH on your server, if it is already installed, it will display a message that nothing to do. The next command will enable the SSH server to automatically start on startup. The final command will start SSH immediately.

Now install dependencies by running the following command.

sudo yum -y install curl policycoreutils postfix
sudo systemctl enable postfix
sudo systemctl start postfix

The first command will install curl, policycoreutils and postfix in to your server. curl is used to transfer data between servers and the policycoreutils packages contain the core utilities that are required for the basic operation of a SELinux system and its policies. postfix is a free and open-source mail transfer agent that routes and delivers emails. The next command will enable postfix to automatically start on startup. The final command will start postfix immediately.

Now add firewall exception for http and https in your server by issuing the following commands –

sudo firewall-cmd –permanent –add-service=http
sudo firewall-cmd –permanent –add-service=https
sudo systemctl reload firewalld

Now execute the following command to add Gitlab package server into your repository –

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

Now run the following command to install Gitlab Community Edition –

sudo yum -y install gitlab-ce

Once the installation is finished you will see output similar to this –

    gitlab: Thank you for installing GitLab!
    gitlab: To configure and start GitLab, RUN THE FOLLOWING COMMAND:

    sudo gitlab-ctl reconfigure

    gitlab: GitLab should be reachable at http://vps.liptanbiswas.com
    gitlab: Otherwise configure GitLab for your system by editing /etc/gitlab/gitlab.rb file
    gitlab: And running reconfigure again.
    gitlab:
    gitlab: For a comprehensive list of configuration options please see the Omnibus GitLab readme
    gitlab: https://gitlab.com/gitlab-org/omnibus-gitlab/blob/master/README.md
    gitlab:
    It looks like GitLab has not been configured yet; skipping the upgrade script.
      Verifying  : gitlab-ce-8.8.5-ce.1.el7.x86_64                              1/1

    Installed:
      gitlab-ce.x86_64 0:8.8.5-ce.1.el7

    Complete!

Now you will need to run the following command to configure and run GitLab –

sudo gitlab-ctl reconfigure

Now you browse the following address using your favorite web browser –

http://server_IP_address

Where server_IP_address is the IP address of your server. You can also access the server using your hostname if your domain is pointed to the server. You will see the following interface in your browser, where you will be asked to create a new password for root or Administrative user of GitLab.

HP_NO_IMG/data/uploads/users/1a4f26de-5d97-48b7-abf5-631194ef3a10/694461511.png” alt=”” />

Enter the new password twice and click on Change your password button.

Now you will be taken to sign in interface. This interface will be shown to everybody who visits the website. You can login to administrative account by using the username root and your newly created password.

HP_NO_IMG/data/uploads/users/1a4f26de-5d97-48b7-abf5-631194ef3a10/1876564229.png” alt=”” />

Once you are logged in you will see the following interface –

HP_NO_IMG/data/uploads/users/1a4f26de-5d97-48b7-abf5-631194ef3a10/683236370.png” alt=”” />

GitLab is now successfully installed. Now you can either configure the settings or you can create a new project.

Branding of the Login Page

Once you are logged in you can brand your login page by changing the logos and text of your login page. Click on the small setting icon next to search bar on top menu to access Admin area of GitLab.

HP_NO_IMG/data/uploads/users/2a78e75d-343a-47ce-9d84-14a6ba54abbc/1250983085.png” alt=”” />

Click on the Appearance option from sidebar and you will be taken to Appearance settings interface from where you can modify look and feel of GitLab. For Sign in/Sign up pages, Enter your custom title of the page. In the description area, you can provide a further description for the login page, in Markdown syntax. Next choose your custom logo for the Sign in/Sign up page. The recommended size of the logo is 640×360 px. In next option you can choose Logo for your header. The recommended size for header logo is 72×72 px. Click the Save button to save the Appearance of the pages.

HP_NO_IMG/data/uploads/users/2a78e75d-343a-47ce-9d84-14a6ba54abbc/1853140762.png” alt=”” />

Now you can logout to view the login page changes.

HP_NO_IMG/data/uploads/users/2a78e75d-343a-47ce-9d84-14a6ba54abbc/1657903592.png” alt=”” />

Creating a New Project

To create a new project on GitLab, go back to the user dashboard by clicking on the GitLab Icon, and then click on New Project button, or you can always click on the + icon next to the notification icon to create a new project.

HP_NO_IMG/data/uploads/users/2a78e75d-343a-47ce-9d84-14a6ba54abbc/1475532413.png” alt=”” />

In the new project interface, enter the path for your new project. If you want to import project from some other source, you can click on the icon provided. Now enter the description for your project, and choose a visibility level for your project. If project visibility is set to Private then admin must provide permission to each user to access the project. The project can be cloned by only those users who have access to the project. If project visibility is set to internal then all the logged in user can clone the project, if it is set to public then project can be cloned without any authentication.

HP_NO_IMG/data/uploads/users/2a78e75d-343a-47ce-9d84-14a6ba54abbc/1970635442.png” alt=”” />

Click on Create project button and your project will be created.

HP_NO_IMG/data/uploads/users/2a78e75d-343a-47ce-9d84-14a6ba54abbc/839194604.png” alt=”” />

To clone, push or pull the project via git, you will need to add your SSH public key. You can click on add an SSH key link, or you can always go to your Profile -> Keys to add SSH keys. In Add an SSH key, enter your public key in Key field and provide a title for your key.

HP_NO_IMG/data/uploads/users/2a78e75d-343a-47ce-9d84-14a6ba54abbc/907598572.png” alt=”” />

Click on Add key once done. You can now manage your project via SSH too.

Conclusion

In this tutorial we have learnt how to install and setup Gitlab on CentOS 7.x. You can now successfully deploy GitLab on CentOS. You can also setup a new project in GitLab. Using GitLab is very easy, and it has an inbuilt help feature to provide you instructions on using GitLab. Once you setup GitLab successfully, all your collaborators can signup and start contributing to your project.

Want your very own server? Get our 1GB memory, Xeon V4, 25GB SSD VPS for £10.00 / month.
Get a Cloud Server

Share this Article!

Related Posts

Node.js Authentication – A Complete Guide with Passport and JWT

Node.js Authentication – A Complete Guide with Passport and JWT

Truth be told, it’s difficult for a web application that doesn’t have some kind of identification, even if you don’t see it as a security measure in and of itself. The Internet is a kind of lawless land, and even on free services like Google’s, authentication ensures that abuses will be avoided or at least […]

Node.js and MongoDB: How to Connect MongoDB With Node

Node.js and MongoDB: How to Connect MongoDB With Node

MongoDB is a document-oriented NoSQL database, which was born in 2007 in California as a service to be used within a larger project, but which soon became an independent and open-source product. It stores documents in JSON, a format based on JavaScript and simpler than XML, but still with good expressiveness. It is the dominant […]

Using MySQL with Node.js: A Complete Tutorial

Using MySQL with Node.js: A Complete Tutorial

Although data persistence is almost always a fundamental element of applications, Node.js has no native integration with databases. Everything is delegated to third-party libraries to be included manually, in addition to the standard APIs. Although MongoDB and other non-relational databases are the most common choice with Node because if you need to scale an application, […]

Node.Js Vs Django: Which Is the Best for Your Project

Node.Js Vs Django: Which Is the Best for Your Project

Django and NodeJs are two powerful technologies for web development, both have great functionality, versatile applications, and a great user interface. Both are open source and can be used for free. But which one fits your project best? NodeJs is based on JavaScript, while Django is written in Python. These are two equally popular technologies […]

Nodejs Vs PHP:  Which Works Best?

Nodejs Vs PHP: Which Works Best?

Before getting into the “battle” between Node.js and PHP we need to understand why the issue is still ongoing. It all started with the increased demand for smartphone applications, their success forcing developers to adapt to new back-end technologies that could handle a multitude of simultaneous requests. JavaScript has always been identified as a client-side […]