I've successfully been running an instance of GitLab for almost a year now. The same server is running Redmine, hence both GitLab and Redmine are running in their respective sub-directories. Phusion Passenger is my application server of choice. Unfortunately, it became increasingly difficult to keep this setup running with newer versions of GitLab. First, GitLab officially is not supporting running it out of a sub-directory, second, by default it uses Unicorn. Here, I want to detail my setup how you still can achieve the GitLab + Apache + Phusion Passenger combo, because I could only find slightly outdated guides online.
As of this writing, my setup looks like the following:
- Ubuntu 12.04 LTS
- Apache 2.2.22
- GitLab 6.1
- passenger 4.0.19
First of all, you should obviously install Apache and passenger. For the latter follow the steps outlined here, and I assume you just installed the Apache package shipped by your distribution of choice first. After the basic setup, you can start setting up GitLab 6.1. However, because the sub-directory + Apache + Passenger setup is non-standard, you have to alter some of the steps when configuring GitLab:
- In the gitlab section of config/gitlab.yml, add
- In config/application.rb, uncomment the line containing
config.relative_url_root = "/gitlab"
- Skip setting up the config/unicorn.rb file
- Instead of using the init script shipped with GitLab, use this file without the unicorn related parts and copy it to /etc/init.d/gitlab
- After completing the official install guide, you want to precompile assets using the following command:
sudo -u git -H bundle exec rake assets:precompile RAILS_ENV=production RAILS_RELATIVE_URL_ROOT=/gitlab
You can check if everything worked so far by executing
sudo servive gitlab start sudo -u git -H bundle exec rake gitlab:check RAILS_ENV=production
Note that it will complain about the init script not being up-to-date because it was replaced with a custom version.
Now it's time to configure Apache to run GitLab in the gitlab sub-directory. First of all, ensure that Passenger's Apache module is loaded. After that, go to /var/www/htdocs and create a symbolic link to /home/git/gitlab/public. Next, update your Apache configuration to look like this:
<VirtualHost *:80> DocumentRoot /var/www/htdocs <Directory /var/www/htdocs> Options FollowSymLinks Order allow,deny Allow from all PassengerResolveSymlinksInDocumentRoot on </Directory> Alias /gitlab "/var/www/htdocs/gitlab" <Directory /var/www/htdocs/gitlab> Options -MultiViews SetEnv RAILS_RELATIVE_URL_ROOT "/gitlab" PassengerAppRoot "/home/git/gitlab" </Directory> </VirtualHost>
Finally, start apache and go to yourdomain.com/gitlab.