..

Setup gitlab-ce 9.0 on a vServer running Ubuntu 14.04 with Plesk 12

Recently, I had some struggle to get a GitLab instance running on my virtual server. Since I have no or minimal knowledge of configuring a server, Plesk seem to help a lot. Nevertheless, there are some differences between installing GitLab on a Plesk server and installing it on a raw apache setup. Following steps seem to work:

1. Add your (sub-)domain in Plesk

In this example I chose the subdomain git.myVServer.com.

2. Edit apache config

cd /etc/apache2/
cd /var/www/vhosts/system/git.myVServer.com/conf/
DocumentRoot /opt/gitlab/embedded/service/gitlab-rails/public  
ServerName http://git.myVServer.com  
ServerSignature Off  
ProxyPreserveHost On  
AllowEncodedSlashes NoDecode  
<Location \>
    Require all granted
    #Allow forwarding to gitlab-workhorse  
    ProxyPassReverse http://127.0.0.1:8081  
    ProxyPassReverse http://git.myVServer.com:81  
</Location>  
RewriteEngine on  

#Forward all requests to gitlab-workhorse except existing files like error documents  
RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} !-f [OR]  
RewriteCond %{REQUEST_URI} ^/uploads/.*  
RewriteRule .* http://127.0.0.1:8181%{REQUEST_URI} [P,QSA,NE]  

# needed for downloading attachments  
DocumentRoot /opt/gitlab/embedded/service/gitlab-rails/public  

#Set up apache error documents, if back end goes down (i.e. 503 error) then a maintenance/deploy page is thrown up.  
ErrorDocument 404 /404.html  
ErrorDocument 422 /422.html  
ErrorDocument 500 /500.html  
ErrorDocument 502 /502.html  
ErrorDocument 503 /503.html  

# It is assumed that the log directory is in /var/log/httpd.  
# For Debian distributions you might want to change this to  
# /var/log/apache2.  
LogFormat "%{X-Forwarded-For}i %l %u %t \"%r\" %>s %b" common_forwarded  
ErrorLog /var/log/apache2/gitlab_error.log  
CustomLog /var/log/apache2/gitlab_forwarded.log common_forwarded  
CustomLog /var/log/apache2/gitlab_access.log combined env=!dontlog  
CustomLog /var/log/apache2/gitlab.log combined
/opt/psa/admin/sbin/httpdmng --reconfigure-domain git.myVServer.com
/etc/init.d/apache2 restart

3. Install GitLab

sudo apt-get install curl openssh-server ca-certificates postfix
curl -sS https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.deb.sh | sudo bash
sudo apt-get install gitlab-ce
cd /etc/gitlab/

and make sure the following settings are not commented out and set to:

external_url 'http://git.myVServer.com'
gitlab_url = 'http://127.0.0.1:8081'  
gitlab_workhorse['listen_network'] = "tcp"  
gitlab_workhorse['listen_addr'] = "127.0.0.1:8181"  
unicorn['port'] = 8081  

nginx['enable'] = false  
web_server['external_users'] = ['www-data']
gitlab-ctl reconfigure
gitlab-ctl status

4. Done

Now, if everything went to plan, your GitLab instance should be running and you can reach it from http://git.myVServer.com