GitLab is a self hosted Git management software based on Ruby on Rails.
It is free software and that is always a plus!
This tutorial is heavily based on the excellent post at rosehosting.com and collects information I found in documentation and on the internet generally.
Note: We'll work in a root console using Bash
If you don't have an editor of choice install vim (it's great!)
apt-get install vim
Then install a few useful packages:
apt-get install dialog build-essential zlib1g-dev libyaml-dev libssl-dev libgdbm-dev libreadline-dev libncurses5-dev libffi-dev curl git-core openssh-server redis-server checkinstall libxml2-dev libxslt-dev libcurl4-openssl-dev libicu-dev python-docutils sudo
Your Python version has to be greater than 2.5 and lower than 3.0+
python --version
now check if you can access python shell via ‘python2′:
test ! -e /usr/bin/python2 && ln -s /usr/bin/python /usr/bin/python2
python2 --version
(the version has, obviously, to be the same!)
Unfortunately the ruby version included in Wheezy is not the one we'd like to use, so we'll have to compile and install it from source:
mkdir /opt/ruby
cd /opt/ruby
curl --progress ftp://ftp.ruby-lang.org/pub/ruby/2.0/ruby-2.0.0-p353.tar.gz | tar xz
cd ruby-2.0.0-p353
./configure && make
make install
Now you can use ruby to install the bundler ruby gem:
gem install bundler --no-ri --no-rdoc
Then create git user and install gitlab-shell:
adduser --disabled-login --gecos 'GitLab' git
cd /home/git
sudo -u git -H git clone https://github.com/gitlabhq/gitlab-shell.git
cd gitlab-shell
sudo -u git -H git checkout v1.8.0
Edit the configuration including your URL as gitlab_url instead of the default "http://localhost/"
sudo -u git -H cp config.yml.example config.yml
sudo -u git -H vim config.yml
Now that the shell is properly configured, we can run the install script for gitlab-shell
sudo -u git -H ./bin/install
Then we need to install MariaDB as database server. Go to https://downloads.mariadb.org/mariadb/repositories/ and follow the istructions to be able to install deb packages from their repositories and them:
apt-get install mariadb-server-10.0 mariadb-client-10.0 libmariadbclient-dev
When prompted insert a proper password for your administrator, then start using it
mysql -u root -p
MariaDB [(none)]> CREATE DATABASE IF NOT EXISTS `gitlabDB` DEFAULT CHARACTER SET `utf8` COLLATE `utf8_unicode_ci`;
MariaDB [(none)]> GRANT ALL ON `gitlabDB`.* TO 'gitlab'@'localhost' identified by 'INSERT_PASSWORD_HERE_PLEASE';
MariaDB [(none)]> exit
Once the database has been created, proceed with the installation of GitLab:
cd ../
sudo -u git -H git clone https://github.com/gitlabhq/gitlabhq.git gitlab
cd gitlab/
sudo -u git -H git checkout 6-4-stable
Edit the configuration including your URL as host instead of the default "localhost" and filling email_from and support_email with proper values
sudo -u git -H cp config/gitlab.yml.example config/gitlab.yml
sudo -u git -H vim config/gitlab.yml
Fix directory permissions:
chown -R git log/ tmp/
chmod -R u+rwX log/ tmp/
sudo -u git -H mkdir /home/git/gitlab-satellites
sudo -u git -H mkdir tmp/pids/
sudo -u git -H mkdir tmp/sockets/
sudo -u git -H mkdir public/uploads
chmod -R u+rwX tmp/pids/ tmp/sockets/ public/uploads
Configure unicorn HTTP server - make sure you tune unicorn to suit your needs. be careful how much resources you allocate and actually have. you can always start with something like worker_processes 1 and timeout 120:
sudo -u git -H cp config/unicorn.rb.example config/unicorn.rb
sudo -u git -H vim config/unicorn.rb
Now configure git user's git configuration
sudo -u git -H git config --global user.name "GitLab"
sudo -u git -H git config --global user.email "gitlab@INSERT_YOUR_DOMAIN"
sudo -u git -H git config --global core.autocrlf input
Edit database configuration (in "production" section) to setup connection to mysql and db, editing "database", "username" and "password" according to your configuration (in this example database is gitlabDB and username is gitlab)
sudo -u git cp config/database.yml.mysql config/database.yml
sudo -u git -H vim config/database.yml
sudo -u git -H chmod o-rwx config/database.yml
Use ruby to initialize the database
gem install charlock_holmes --version '0.6.9.4'
sudo -u git -H bundle install --deployment --without development test postgres aws
sudo -u git -H bundle exec rake gitlab:setup RAILS_ENV=production
You have to answer ‘yes’ when asked "Do you want to continue (yes/no)?"
GitLab needs an init script in init.d
cp lib/support/init.d/gitlab /etc/init.d/gitlab
chmod +x /etc/init.d/gitlab
update-rc.d gitlab defaults 21
then check gitlab application status and start it
sudo -u git -H bundle exec rake gitlab:env:info RAILS_ENV=production
/etc/init.d/gitlab start
Install and configure Nginx:
apt-get install nginx
cp lib/support/nginx/gitlab /etc/nginx/sites-available/gitlab
Edit the configuration (delete default_server if this is not the only website on your server, for example) and make sure to change server_name YOUR_SERVER_FQDN to your real url
vim /etc/nginx/sites-available/gitlab
ln -s /etc/nginx/sites-available/gitlab /etc/nginx/sites-enabled/gitlab
service nginx restart
now you can point your browser to your domain and enjoy gitlab
username: [email protected]
password: 5iveL!fe