Skip to content

Instantly share code, notes, and snippets.

@cristianrasch
Created April 22, 2012 01:50
  • Star 32 You must be signed in to star a gist
  • Fork 22 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save cristianrasch/2440768 to your computer and use it in GitHub Desktop.
Install Gitlab on Debian Squeeze/Wheezy
aptitude install -y git curl python-dev python-pip redis-server ruby1.9.1-full rubygems1.9.1
aptitude install -y mysql-server libmysqlclient-dev
adduser --system --shell /bin/sh --gecos 'git version control' --group --disabled-password --home /home/git git
adduser --disabled-login --gecos 'gitlab system' gitlab
usermod -a -G git gitlab
su - gitlab
ssh-keygen -q -N '' -t rsa -f /home/gitlab/.ssh/id_rsa
aptitude install gitolite
cp /home/gitlab/.ssh/id_rsa.pub /home/git/gitlab.pub
su - git
cp /etc/gitolite/example.gitolite.rc ~/.gitolite.rc
sed -i 's/0077/0007/g' .gitolite.rc
gl-setup /home/git/gitlab.pub
chmod -R g+rwX /home/git/repositories
# test:
su - gitlab
git clone git@localhost:gitolite-admin.git /tmp/gitolite-admin
aptitude install make build-essential libicu-dev libsqlite3-dev
gem install bundler
pip install pygments
su - gitlab
git clone git://github.com/gitlabhq/gitlabhq.git gitlab
cd gitlab
cp config/gitlab.yml.example config/gitlab.yml
cp config/database.yml.sqlite config/database.yml
# Change username/password in the config/database.yml file
bundle install --without development test --deployment
bundle exec rake gitlab:app:setup RAILS_ENV=production
# test all is set up
bundle exec rake gitlab:app:status RAILS_ENV=production
bundle exec rails s -e production
# start the resque worker
./resque.sh
aptitude install nginx
su - gitlab
cd gitlab
cp config/unicorn.rb.orig config/unicorn.rb
bundle exec unicorn_rails -c config/unicorn.rb -E production -D
# append to the http section of the /etc/nginx/nginx.conf file
upstream gitlab {
server unix:/home/gitlab/gitlab/tmp/sockets/gitlab.socket;
}
# remove nginx default site
rm /etc/nginx/sites-enabled/default
editor /etc/nginx/sites-available/gitlab
server {
server_name localhost;
root /home/gitlab/gitlab/public;
# individual nginx logs for this gitlab vhost
access_log /var/log/nginx/gitlab_access.log;
error_log /var/log/nginx/gitlab_error.log;
location / {
# serve static files from defined root folder;.
# @gitlab is a named location for the upstream fallback, see below
try_files $uri $uri/index.html $uri.html @gitlab;
}
# if a file, which is not found in the root folder is requested,
# then the proxy pass the request to the upsteam (gitlab unicorn)
location @gitlab {
proxy_redirect off;
# you need to change this to "https", if you set "ssl" directive to "on"
proxy_set_header X-FORWARDED_PROTO http;
proxy_set_header Host localhost:80;
proxy_set_header X-Real-IP $remote_addr;
proxy_pass http://gitlab;
}
}
ln -s /etc/nginx/sites-available/gitlab /etc/nginx/sites-enabled/gitlab
service nginx restart
editor /etc/init.d/gitlab
#! /bin/bash
### BEGIN INIT INFO
# Provides: gitlab
# Required-Start: $local_fs $remote_fs $network $syslog redis-server
# Required-Stop: $local_fs $remote_fs $network $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: GitLab git repository management
# Description: GitLab git repository management
### END INIT INFO
DAEMON_OPTS="-c /home/gitlab/gitlab/config/unicorn.rb -E production -D"
NAME=unicorn
DESC="Gitlab service"
PID=/home/gitlab/gitlab/tmp/pids/unicorn.pid
RESQUE_PID=/home/gitlab/gitlab/tmp/pids/resque_worker.pid
case "$1" in
start)
CD_TO_APP_DIR="cd /home/gitlab/gitlab"
START_DAEMON_PROCESS="bundle exec unicorn_rails $DAEMON_OPTS"
START_RESQUE_PROCESS="sh resque.sh"
echo -n "Starting $DESC: "
if [ `whoami` = root ]; then
sudo -u gitlab sh -c "$CD_TO_APP_DIR > /dev/null 2>&1 && $START_DAEMON_PROCESS && $START_RESQUE_PROCESS"
else
$CD_TO_APP_DIR > /dev/null 2>&1 && $START_DAEMON_PROCESS && $START_RESQUE_PROCESS
fi
echo "$NAME."
;;
stop)
echo -n "Stopping $DESC: "
kill -QUIT `cat $PID`
kill -QUIT `cat $RESQUE_PID`
echo "$NAME."
;;
restart)
echo -n "Restarting $DESC: "
kill -USR2 `cat $PID`
kill -USR2 `cat $RESQUE_PID`
echo "$NAME."
;;
reload)
echo -n "Reloading $DESC configuration: "
kill -HUP `cat $PID`
kill -HUP `cat $RESQUE_PID`
echo "$NAME."
;;
*)
echo "Usage: $NAME {start|stop|restart|reload}" >&2
exit 1
;;
esac
exit 0
chmod +x /etc/init.d/gitlab
insserv gitlab
service gitlab restart
@axilleas
Copy link

The .gitolite.rc file is not created and it stops at line 11.

@cristianrasch
Copy link
Author

Nice catch, I must have copied the default that came with the Debian package. Fixed now :)

@axilleas
Copy link

Sorry for bothering again. When I run "gl-setup -q /home/git/gitlab.pub" at line 13, I get "-q must end in .pub". I removed the p flag and it proceeded.

@cristianrasch
Copy link
Author

No worries, does your public key file have a .pub extension? Also, make sure the git user can read the gitlab.pub key.

@axilleas
Copy link

Yeap, it did have a .pub extension and 644 permissions. I also changed the owner from root:root to git:git, I don't know if that matters.
In addition the bundle command gave an error " bundle: command not found".
What I did was to give "export PATH=/var/lib/gems/1.9.1/bin/:${PATH}".
In line 31 did you miss the d flag in order for the server to be ran as daemon?

@cristianrasch
Copy link
Author

The bundler issue is kinda odd. Did you install bundler (gem install bundler) and run the bundle command as the same user? It should work out of the box, but I guess computers can always surprise us in so many new ways.
Moreover, I did not miss the -d switch on line 31, all I wanted to accomplish was to make sure the dependencies were set up correctly, so I was just testing what I had previously installed. If you access the server at por 3000 you should see the Gitlab home page.
Nonetheless, thanks for making me release I should probably clarify on each step who is running the commands, indentation along won't do it :(

@axilleas
Copy link

Well, my gitlab is up and running thanks to your gist xD
I followed all the steps based on indentation for each user. I ran gem install bundler as root and bundle install as gitlab user.

@cristianrasch
Copy link
Author

Hey, glad to hear you got it up and running. That settles it then, you should have run the bundle install command and root as well, I guess your user's PATH env var wasn't updated, which also makes sense. Cheers!

@cheako
Copy link

cheako commented Jul 9, 2012

What about Postgress instead of MySQL?

Line 4 should also use --system along with whatever parameters it needs because of --system flag.
Line 5 should be: adduser gitlab git; # These tools do what they should, but only if they are used correctly.
Line 6: su - -s /bin/sh gitlab -c
Line 7: "ssh-keygen -q -N '' -t rsa -f /home/gitlab/.ssh/id_rsa"; # Continuation of previous line.
Line ~15, missing exit.
Line 17: cat /etc/ssh/ssh_host_rsa_key.pub >> .ssh/known_hosts; # Perhaps using "ssh-keyscan localhost" is better?
Line 19: bundler in Wheezy.
Line 20: Same with python-pygments.
Line 27: Missing apt-get -f install rubygems/squeeze-backports... or whatever aptitude command is.
Also list all the downloaded|Installing modules in-case they can be installed via pkgs as well, don't forget ppl can be using 3rd part repos that have things that may otherwise be impossible to get.
What is this?
Post-install message from rdoc:
Depending on your version of ruby, you may need to install ruby rdoc/ri data:

<= 1.8.6 : unsupported
= 1.8.7 : gem install rdoc-data; rdoc-data --install
= 1.9.1 : gem install rdoc-data; rdoc-data --install

= 1.9.2 : nothing to do! Yay!
I'm ignoring for now.

What now:
gitlab@www:~/gitlab$ bundle exec rake gitlab:app:setup RAILS_ENV=production
/home/gitlab/gitlab/vendor/bundle/ruby/1.8/bundler/gems/omniauth-ldap-7edf27d0281e/lib/omniauth-ldap/version.rb:3: warning: already initialized constant VERSION
WARNING: using the built-in Timeout class which is known to have issues when used for opening connections. Install the SystemTimer gem if you want to make sure the Redis client will not hang.
rake aborted!
/home/gitlab/gitlab/lib/tasks/bulk_import.rake:78: syntax error, unexpected ':', expecting ')'
name: project_name,
^
/home/gitlab/gitlab/lib/tasks/bulk_import.rake:79: syntax error, unexpected ':', expecting '='
code: project_name,
^
/home/gitlab/gitlab/lib/tasks/bulk_import.rake:80: syntax error, unexpected ':', expecting '='
path: project_name,
^
/home/gitlab/gitlab/lib/tasks/bulk_import.rake:81: syntax error, unexpected ':', expecting '='
owner: user,
^
/home/gitlab/gitlab/lib/tasks/bulk_import.rake:82: syntax error, unexpected ':', expecting '='
description: "Automatically created from R...
^
/home/gitlab/gitlab/lib/tasks/bulk_import.rake:83: syntax error, unexpected ')', expecting kEND
/home/gitlab/gitlab/lib/tasks/bulk_import.rake:107: syntax error, unexpected kELSE, expecting kEND
/home/gitlab/gitlab/lib/tasks/bulk_import.rake:111: syntax error, unexpected $end, expecting kEND

(See full trace by running task with --trace)

@cheako
Copy link

cheako commented Jul 9, 2012

Modules in log:
rake
i18n
multi_json
activesupport
builder
activemodel
erubis
journey
rack
rack-cache
rack-test
hike
tilt
sprockets
actionpack
mime-types
polyglot
treetop
mail
actionmailer
arel
tzinfo
activerecord
activeresource
Using
rack-ssl
json
rdoc
thor
railties
rails
acts-as-taggable-on
acts_as_list
bcrypt-ruby
blankslate
bootstrap-sass
carrierwave
charlock_holmes
chosen-rails
coffee-script-source
execjs
coffee-script
coffee-rails
colored
daemons
orm_adapter
warden
devise
diff-lcs
drapper
escape_utils
eventmachine

Module Package Names:
xargs apt-get -fy -t wheezy install; # Just paste the first line.
(Then paste everything after this line on the next line)
ruby-minitest/wheezy
ruby-arel
ruby1.8-dev=1.8.7.358-4
ruby-treetop
ruby-i18n
rake
libi18n-ruby/wheezy
ruby-builder
ruby-erubis
ruby-journey
ruby-rack
ruby-rack-cache
ruby-rack-test
ruby-hike
ruby-tilt
ruby-sprockets
ruby-mime-types
ruby-polyglot
ruby-treetop
ruby-mail
ruby-arel
ruby-tzinfo
ruby-rack-ssl
ruby-json
ruby-thor
ruby-passenger
ruby-bcrypt
ruby-blankslate
ruby-daemons
ruby-diff-lcs
ruby-eventmachine
ruby-rails-2.3
ruby-activesupport-2.3
ruby-activerecord-2.3
ruby-actionpack-2.3
ruby-actionmailer-2.3
ruby-activeresource-2.3
(hit ctrl-d)

Make sure you don't get ruby1.9.1, it's not ready ATM.

@cheako
Copy link

cheako commented Jul 10, 2012

The instructions here seam better, but they seam to ignore any possibility of ever using deb packages. Well I guess since ruby needs to be a whopping 1.9.2-p290.

https://github.com/gitlabhq/gitlabhq/blob/stable/doc/installation.md

@christianpauli
Copy link

Gitlab 5 uses gitlab-shell instead of gitolite which after testing runs faster and is more stable. Try adapting the script.
(The install-how-to on gitlabhq is very good and understandable)

@dosire
Copy link

dosire commented Mar 25, 2014

@dosire
Copy link

dosire commented Aug 3, 2014

Please consider using the package for Debian, it installs in 2 minutes https://about.gitlab.com/downloads/

@ilikenwf
Copy link

The omnibus sucks as it installs a bunch of non-tracked files and doesn't allow you to use a remote SQL server.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment