Sunday, August 2, 2015

Install and Configure Gitlab for Local Network in Ubuntu


Introduction

Gitlab is a Web Application for Git Version Control System, written in Rails.
This article describe how to install Gitlab on Ubuntu 14.04 and config it to work with local network.

Pre-Request


A working Ubuntu installation, e.g.

Install Ubuntu 14.04 on VirtualBox

Steps

Install Gitlab CE

sudo apt-get update

# from official site
# 1. Install and configure the necessary dependencies
sudo apt-get install curl openssh-server ca-certificates postfix

# 2. Add the GitLab package server and install the package
curl https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.deb.sh | sudo bash
sudo apt-get install gitlab-ce

# E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?

sudo apt-get update
sudo apt-get install gitlab-ce

# E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?

sudo apt-get install gitlab-ce --fix-missing

# E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?

sudo apt-get update --fix-missing
sudo apt-get install gitlab-ce

# Finally it works...
# it will tell you where you can link to after reconfigure


I don't know which step fixed the problem, probably just the network issue?

Configure and Start Gitlab

# 3. Configure and start GitLab

sudo gitlab-ctl reconfigure


Then link to the url provided by "# 2. Add the GitLab package server and install the package", for me its "http://benbai-virtualbox/"

use the name/pass from official site to login (its root/5iveL!fe now)


Change myhostname and set rewrite rule for sender

After gitlab launched, I tried to sign up a new account but has problem to receive confirmation email
the message below is found in my /var/log/mail.log

... Our system has detected that this message is 550-5.7.1 likely unsolicited mail... Our system has detected that this message is likely unsolicited mail. To reduce the amount of spam sent to Gmail, this message has been blocked. For more information, review this article.


what I did to solve this:

edit /etc/postfix/main.cf
# change myhostname:

# this is raquired to escape from gmail 550 5.7.1

myhostname = yahoo.com.tw

# add sender_canonical_maps:

# specify the file that contains rewrite rule for sender

sender_canonical_maps = hash:/etc/postfix/canonical


create /etc/postfix/canonical and set rewrite rule as below
gitlab@benbai-VirtualBox    your_acc@yahoo.com.tw
then create the postfix db and restart postfix
# create the postfix db
sudo postmap /etc/postfix/canonical
# restart postfix

sudo postfix stop

sudo postfix start


finally I can receive the confirmation email, but it is still placed in 'spam' box...

Change Address for Gitlab

Another problem is the link of confirmation email is http://benbai-virtualbox but I want it be real IP address.

I solve this as below:

edit /etc/gitlab/gitlab.rb
modify external_url
# someone said this is the correct place

# but it doesn't work for confirmation however

external_url 'http://192.168.31.122'


edit /var/opt/gitlab/gitlab-rails/etc/gitlab.yml
modify host
# this works for the confirmation mail

host: 192.168.31.122

then restart Gitlab

# restart gitlab, you can also try simply 'sudo gitlab-ctl restart'

sudo gitlab-ctl stop

sudo gitlab-ctl start

Finally everything works well.

References

Official Download Page

SMTP Error Reference

Why has Gmail blocked my messages?

How to rewrite outgoing address in Postfix

How to change URL of a working GitLab install?

No comments:

Post a Comment