GitLab with Apache and Ubuntu

Let’s make it ab ovo. Big Boss wants to keep track of The Code bug, objectives, and whatever else somehow nicely, and after a few ‘I don’t know what is the best solution’ I got the hint: I should investigate myself and just do it™. We both agreed on using GitLab (I’ve never actually used it, but I like GitHub and Git), but Big Boss was not so sure as he’d had problems before installing it next to an Apache server. As our server still hasn’t arrived, I decided to install GitLab on my own machine, a Linode server on which basically all my academic life depends on. It is already running my personal website and some svn/git servers, so it was no option to use the out-of-the-box solution from GitLab, which includes its own Ruby server.  So, that’s why, here, a quick guide to install GitLab next to an Apache server running on Ubuntu:

  1. Get the last version of GitLab Community Edition (CE) through their repository. For this, I just followed the instructions on the GitHub website.
  2. When that is finished, GitLab should be installed and there should be a conflict between Apache and the server used by GitLab, Unicorn. First we have to reconfigure GitLab.
  3. Find the gitlab configuration file gitlab.rb, in my case in /etc/gitlab/. Edit (or uncomment) the following fields:
    external_url ""
    nginx['enable'] = false
    ci_nginx['enable'] = false
    web_server['external_users'] = ['www-data']

    Where should be the host of your GitLab code. Port 80 can be changed to anything, but then keep that in mind for what follows. Also, www-data is the username used by your Apache configuration; this is the default value.

  4. Reconfigure GitLab:
    sudo gitlab-ctl reconfigure
  5. Next, we need to create an appropriate Apache config file. Luckily, the guys of GitLab provide one. I used gitlab-apache24.conf, but they’re all pretty similar. There are some things that need to be modified in this file, basically just replace all appearances of YOUR_SERVER_FQDN with the host address,
  6. You probably need to activate the necessary modules of Apache. In the terminal:
    sudo a2enmod rewrite
    sudo a2enmod proxy
    sudo a2enmod proxy_http

    Most probably the two first ones were already activated.

  7. If you’re running Ubuntu, then the Apache configuration file needs to be placed in the right place. In the Apache config directory (usually /etc/apache2), move gitlab-apache24.conf to sites-available, and rename it to reflect the domain name:
    mv gitlab-apache24.conf /etc/apache2/sites-available/
  8. Then enable the site:
  9. That should actually be it. In my case, I was struggling for a while with a 504 error. All I had to do was go to the DNS Manager of Linode and add a CNAME Record for my new virtual server. And then, back to The Code.

Leave a Reply

Your email address will not be published. Required fields are marked *