We’ll show you how to install GitLab on CentOS 7. GitLab is a self-hosted git repository management system. It is used by more than 100,000 organizations worldwide. Today we will show you how to install GitLab on your CentOS VPS. For instructions about how to install GitLab on an Ubuntu VPS, you can check our Install GitLab on Debian tutorial. Installing GitLab on CentOS 7 is fairly easy task and it should take 10 minutes for the installation.
To run GitLab on your server you will need to have Ruby 2.0 or 2.1 installed on your server. GitLab requires 2 CPU cores and 2GB of RAM so it can support up to 500 users. This makes our SSD 2 VPS hosting plan suitable for your needs. You will need to have MySQL or PostgreSL and Redis. Additional packages will be installed. When it comes to this tutorial, we are using our CentOS 6 64bit full template.
Step 1: Add the required repositories to your system
The first step is to add the required repositories to your system. You can do this using the following commands:
Step 2: Installing the required packages
Next thing you need to do is update all your system software, remove the unnecessary packages and install the required packages.
Step 3: Create user
Create a system user for GitLab:
Now edit the ‘/etc/sudoers’ file and add ‘/usr/local/bin’ at the end of:
It should look like this:
Step 4: Download Git source
Download Git source and extract it in your ‘/tmp’ directory. At the moment of writing, the latest version available is 2.1.3.
Step 5: Download and install Ruby
After doing this, you will need to download and install Ruby on your CentOS VPS. At the moment of writing, the latest version available is 2.1.5.
Step 6: Create new database
Once the installation of Ruby is completed, it is time to create a database. You can do this using the following commands:
Do not forget to change ‘PaSsWoRd’ with a password of your choice.
Step 7: Configure Redis
Now, let’s configure Redis. Open the ‘/etc/redis.conf’ file with an editor of your choice and set ‘port 0’.
Then, add the following lines at the end of the file:
Restart the service and add git to the redis group:
Step 7: Install GitLab on CentOS 7
Now, let’s install GitLab. We assume that you have a full root access to your Linux VPS so you should execute all these commands as root. Also, you can change the ‘7-4-stable’ to the latest stable version available.
Edit ‘config/gitlab.yml’ and follow the instructions at the top of the file.
Execute the commands:
Then, copy the ‘config/unicorn.rb.example’ file to ‘config/unicorn.rb’. Edit the ‘config/unicorn.rb’ file and set the number of workers to match the number of cores on your CentOS VPS.
Please note, ‘unicorn.rb’ and ‘gitlab.yml’ should contain the same information.
Now, copy ‘config/database.yml.mysql’ to ‘config/database.yml’ and edit the file. Please note that you will need to change the secure password with your ‘PaSsWoRd’ value.
Install Bundler, gems, GitLab shell and initialize the database.
Please change ‘YourPassword’ with your password. Also, you can review and modify the ‘config.yml’ file.
Step 8: Install init script
We are approaching the end of this tutorial. It is now time to install the init script. You can use the following commands:
Set the logrotate, check the status, compile the assets and then start the GitLab:
Step 9: Configure Nginx
OK, it is time to configure Nginx on your server and generate an SSL.
Edit the ‘/etc/nginx/conf.d/gitlab.conf’ file to match your FQDN and your SSL path. Also, you will need to comment the following lines:
Finally, run the following commands:
That’s it. If you followed closely every single step of this tutorial, you should be able to access your newly installed GitLab using your domain name or your CentOS VPS IP address. For example, if your IP address is 12.34.56.78 you need to enter https://12.34.56.78 .
Of course, you don’t have to Install GitLab on CentOS 7, if you use one of our Linux VPS hosting services, in which case you can simply ask our expert Linux admins to install GitLab for you. They are available 24×7 and will take care of your request immediately. You can also check our guide on How to Install GitLab on Ubuntu 18.04.
PS. If you liked this post, on how to install GitLab on CentOS 7, please share it with your friends on the social networks using the buttons on the left or simply leave a reply below. Thanks.
Please share the guide on how to configure email setup (postfix) for gitlab ce 11.3.0 on centos7.