Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment