Installing Gitlab on Debian

First install these packages to resolve all dependancies:
apt-get install -y 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 logrotate python python-docutils

Install Ruby 2.0:
cd /tmp
tar -xvpf ruby-2.0.0-p247.tar.gz
cd ruby-2.0.0-p247
make install

Install Bundler:
gem install bundler

Create the git user:
sudo adduser −−disabled-login −−gecos 'GitLab' git

Install Gitlab-shell:
cd /home/git
sudo -u git -H git clone
cd gitlab-shell
sudo -u git -H cp config.yml.example config.yml
sudo -u git -H vi config.yml #change gitlab_url to the absolute url of your server
sudo -u git -H ./bin/install

It is important to let user git execute this commands in order not to have permission problems afterwards!

Install mysql server and client:
apt-get install -y mysql-server
Set whatever password you like for root. When the installation has finished, connect to mysql: mysql –user=root -p

Now create the gitlab database and a user to connect to it:
CREATE DATABASE IF NOT EXISTS `gitlabhq_production` DEFAULT CHARACTER SET `utf8` COLLATE `utf8_unicode_ci`;
GRANT SELECT, LOCK TABLES, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER ON `gitlabhq_production`.* TO 'gitlab'@'localhost';


Install gitlab:
sudo -u git -H git clone /home/git/gitlab
cd /home/git/gitlab
If you want the latest stable, you have to check it out:
sudo -u git -H git checkout 6-8-stable
Else you can leave it at master – so you'll have the latest bleeding edge version!

Create a gitlab config from the example file:
sudo -u git -H cp config/gitlab.yml.example config/gitlab.yml
sudo -u git -H editor config/gitlab.yml

Lookup these lines and change them accordingly to your server:
port: 80
https: false
email_from: gitlab@localhost
support_email: support@localhost

Update permissions to the log and tmp directories:
sudo chown -R git log/ tmp/
sudo chmod -R u+rwX  log/ tmp/

Create a directory for satellites:
sudo -u git -H mkdir /home/git/gitlab-satellites

Create directories for sockets and pids with correct permissions:
sudo -u git -H mkdir tmp/pids/ tmp/sockets/
sudo chmod -R u+rwX  tmp/pids/ tmp/sockets/

Create a public uploads directory (for backups):
sudo -u git -H mkdir public/uploads
sudo chmod -R u+rwX  public/uploads

Create a Unicorn config from the example file:
sudo -u git -H cp config/unicorn.rb.example config/unicorn.rb
You might want to change the worker_processes to a higher value dependent on your requirements.

Copy the example Rack attack config:
sudo -u git -H cp config/initializers/rack_attack.rb.example config/initializers/rack_attack.rb

Find and uncomment the line 'config.middleware.use Rack::Attack' in the following file:
sudo -u git -H editor config/application.rb

Configure Git global settings for git user:
sudo -u git -H git config −−global "GitLab"
sudo -u git -H git config −−global "gitlab@localhost"
sudo -u git -H git config −−global core.autocrlf input

Configure Gitlab's database access:
sudo -u git cp config/database.yml.mysql config/database.yml
sudo -u git -H editor config/database.yml
Be sure to set the database name to gitlabhq_production and username/password to what has been configured above in mysql.

Use bundler to install gems:
gem install charlock_holmes −−version ''
sudo -u git -H bundle install −−deployment −−without development test postgres aws

Run gitlab setup, install database and precompile assets:
sudo -u git -H bundle exec rake gitlab:setup RAILS_ENV=production
sudo -u git -H bundle exec rake db:migrate RAILS_ENV=production
sudo -u git -H bundle exec rake assets:clean assets:precompile cache:clear RAILS_ENV=production

Install the init script:
cp lib/support/init.d/gitlab /etc/init.d/gitlab
chmod +x /etc/init.d/gitlab
update-rc.d gitlab defaults

Setup logrotate for gitlab:
sudo cp lib/support/logrotate/gitlab /etc/logrotate.d/gitlab

Startup gitlab:
/etc/init.d/gitlab start

Now setup Nginx:
apt-get install -y nginx
sudo cp lib/support/nginx/gitlab /etc/nginx/sites-available/gitlab
sudo ln -s /etc/nginx/sites-available/gitlab /etc/nginx/sites-enabled/gitlab

You might want to set your fully qualified domain name into the configuration:
sudo editor /etc/nginx/sites-available/gitlab

Then restart nginx: /etc/init.d/nginx restart

Now visit your gitlab installation and login:
Password: 5iveL!fe


At the end I still have a few useful rake commands you might appreciate:

sudo -u git -H bundle exec rake gitlab:env:info RAILS_ENV=production Check your environment
sudo -u git -H bundle exec rake gitlab:shell:setup RAILS_ENV=production Setup gitlab shell – or if you want to rebuild your authorized_keys
sudo -u git -H bundle exec rake db:migrate RAILS_ENV=production Bring up your database structure up2date after an upgrade
sudo -u git -H bundle exec rake assets:clean assets:precompile cache:clear RAILS_ENV=production Clean caches and precompile assets