Install and configure GitLab with Plesk 12 on CentOS 6
Phase 2 – GitLab
At this point, having completed the prerequisites, you must add the server for the GitLab CE (Community Edition) package with:
curl https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.rpm.sh | sudo bash
and finally install the package (about 328 Mb download, 904 Mb installation for version 8.0.4) with:
sudo yum install gitlab-ce
Now we got GitLab installed on our server, in the /var/opt/gitlab/ folder, which however must be configured according to our needs.
Suppose you want your Git repository to be available for example at the address http://git.nullalo.com. The first thing to do is edit the /etc/gitlab/gitlab.rb file and change the following values (above each of them we put a note with the meaning):
# External URL for the GitLab repository external_url 'http://git.nullalo.com' # Completely disable GitLab's Nginx, since we're going to use the Plesk one nginx['enable'] = false # Sets server SSH port gitlab_rails['gitlab_shell_ssh_port'] = 22
To use GitLab with SSL protocol you need to change external_url and add an option as follows:
external_url 'https://git.nullalo.com' nginx['listen_https'] = false # to communicate with GitLab Nginx internally over HTTP, even if external_url is in HTTPS nginx['redirect_http_to_https'] = true # redirects all traffic to HTTPS
If you need to use an HTTPS port other than the default (443), just specify it as part of the external_url:
If your GitLab version is 8.0.x or 8.1.x, you must also change the settings for the new gitlab-git-http-server, since Apache cannot connect to a UNIX socket but instead needs to connect to a TCP Port:
gitlab_git_http_server['listen_network'] = "tcp" gitlab_git_http_server['listen_addr'] = "localhost:8181"
Starting from version 8.2, gitlab-git-http-server has been replaced by new version gitlab-workhorse, a daemon that handles downloads too. Therefore, for GitLab 8.2.x you must ignore above gitlab_git_http_server settings and insert:
gitlab_workhorse['listen_network'] = "tcp" gitlab_workhorse['listen_addr'] = "localhost:8181"
If you want GitLab to send you emails, edit in the same file also SMTP server settings by typing in the server’s host (in the example mail.nullalo.com), port (usually 25, if you do not use SSL/TLS) username and password to be used and authentication type (“plain” in our example):
gitlab_rails['gitlab_email_enabled'] = true gitlab_rails['gitlab_email_from'] = 'email@example.com' gitlab_rails['gitlab_email_display_name'] = 'Nullalo Git Repository' gitlab_rails['gitlab_email_reply_to'] = 'firstname.lastname@example.org' gitlab_rails['smtp_enable'] = true gitlab_rails['smtp_address'] = "mail.nullalo.com" gitlab_rails['smtp_port'] = 25 gitlab_rails['smtp_user_name'] = "email@example.com" gitlab_rails['smtp_password'] = "yourpassword" gitlab_rails['smtp_domain'] = "mail.nullalo.com" gitlab_rails['smtp_authentication'] = "plain" gitlab_rails['smtp_enable_starttls_auto'] = true gitlab_rails['smtp_tls'] = false gitlab_rails['smtp_openssl_verify_mode'] = 'none'
To move data folder in your virtual host’s one:
To move uploads folder as well:
gitlab_rails['uploads_directory'] = "/var/www/vhosts/nullalo.com/git.nullalo.com/uploads"
If you wish to set backup folder and schedule:
gitlab_rails['backup_path'] = "/var/www/vhosts/nullalo.com/git.nullalo.com/backups" gitlab_rails['backup_keep_time'] = 604800 # Limits backups lifetime to 7 days (604800 seconds)
Now reconfigure and start GitLab with previous settings using the command:
sudo gitlab-ctl reconfigure
Pay particular attention when moving GitLab folders in the virtual host’s ones: if right permissions are not set, those folders won’t be backupped by Plesk. For it is essential that GitLab works with git user and group, and it enforces 700 as permissions on both data (/var/opt/gitlab/git-date/) and backup (/var/opt/gitlab/backups) folders, the quickest solution is to change folders permissions after each reconfiguration of GitLab (gitlab-ctl reconfigure), so that Plesk can back them up. This can be done with the following command:
chmod a+x -R /var/www/vhosts/nullalo.com/git.nullalo.com/git-data chmod a+x -R /var/www/vhosts/nullalo.com/git.nullalo.com/uploads chmod a+x -R /var/www/vhosts/nullalo.com/git.nullalo.com/backups