gitlabhq/doc/installation.md

338 lines
10 KiB
Markdown
Raw Normal View History

2012-03-13 19:19:03 +01:00
## Platform requirements:
2012-03-12 13:47:57 +01:00
**The project is designed for the Linux operating system.**
2012-03-13 19:19:03 +01:00
It may work on FreeBSD and Mac OS, but we don't test our application for these systems and can't guarantee stability and full functionality.
We officially support (recent versions of) these Linux distributions:
2012-03-13 19:19:03 +01:00
- Ubuntu Linux
- Debian/GNU Linux
2012-03-13 19:19:03 +01:00
It should work on:
- Fedora
- CentOs
- RedHat
2012-03-13 19:19:03 +01:00
You might have some luck using these, but no guarantees:
2012-03-13 19:19:03 +01:00
- MacOS X
2012-03-13 19:19:03 +01:00
- FreeBSD
Gitlab does **not** run on Windows and we have no plans of making Gitlab compatible.
2012-03-13 19:19:03 +01:00
## This installation guide created for Debian/Ubuntu and properly tested.
The installation consists of 6 steps:
2012-03-12 13:47:57 +01:00
1. Install packages / dependencies
2. Install ruby
3. Install gitolite
4. Install and configure Gitlab.
5. Start the web front-end
6. Start a Resque worker (for background processing)
### IMPORTANT
Please make sure you have followed all the steps below before posting to the mailinglist with installation and configuration questions.
Only create a Github Issue if you want a specific part of this installation guide updated.
2012-03-12 13:47:57 +01:00
Also read the [Read this before you submit an issue](https://github.com/gitlabhq/gitlabhq/wiki/Read-this-before-you-submit-an-issue) wiki page.
2012-03-12 13:47:57 +01:00
2012-03-13 19:19:03 +01:00
> - - -
> First 3 steps can be easily skipped with simply install script:
>
> # Install curl and sudo
> apt-get install curl sudo
>
> # 3 steps in 1 command :)
> curl https://raw.github.com/gitlabhq/gitlabhq/master/doc/debian_ubuntu.sh | sh
2012-03-13 19:19:03 +01:00
>
> Now you can go to step 4"
> - - -
2012-03-12 13:47:57 +01:00
# 1. Install packages
2012-03-13 19:19:03 +01:00
*Keep in mind that `sudo` is not installed for debian by default. You should install it with as root:* **apt-get update && apt-get upgrade && apt-get install sudo**
2012-03-12 13:47:57 +01:00
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install -y wget curl gcc checkinstall libxml2-dev libxslt-dev sqlite3 libsqlite3-dev libcurl4-openssl-dev libreadline6-dev libc6-dev libssl-dev libmysql++-dev make build-essential zlib1g-dev libicu-dev redis-server openssh-server git-core python-dev python-pip libyaml-dev sendmail
# If you want to use MySQL:
sudo apt-get install -y mysql-server mysql-client libmysqlclient-dev
2012-03-12 13:47:57 +01:00
# 2. Install ruby
wget http://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.2-p290.tar.gz
tar xzfv ruby-1.9.2-p290.tar.gz
2012-03-12 13:47:57 +01:00
cd ruby-1.9.2-p290
./configure
make
sudo make install
# 3. Install gitolite
Create user for git:
sudo adduser \
--system \
--shell /bin/sh \
--gecos 'git version control' \
--group \
--disabled-password \
--home /home/git \
git
Create user for gitlab:
2012-03-12 13:47:57 +01:00
# ubuntu/debian
sudo adduser --disabled-login --gecos 'gitlab system' gitlab
Add your user to git group:
2012-03-12 13:47:57 +01:00
sudo usermod -a -G git gitlab
Generate key:
2012-03-12 13:47:57 +01:00
sudo -H -u gitlab ssh-keygen -q -N '' -t rsa -f /home/gitlab/.ssh/id_rsa
2012-03-13 19:19:03 +01:00
Get gitolite source code:
2012-03-12 13:47:57 +01:00
cd /home/git
sudo -H -u git git clone git://github.com/gitlabhq/gitolite /home/git/gitolite
Setup:
sudo -u git sh -c 'echo -e "PATH=\$PATH:/home/git/bin\nexport PATH" >> /home/git/.profile'
sudo -u git -H sh -c "PATH=/home/git/bin:$PATH; /home/git/gitolite/src/gl-system-install"
2012-03-12 13:47:57 +01:00
sudo cp /home/gitlab/.ssh/id_rsa.pub /home/git/gitlab.pub
sudo chmod 0444 /home/git/gitlab.pub
2012-03-12 13:47:57 +01:00
sudo -u git -H sed -i 's/0077/0007/g' /home/git/share/gitolite/conf/example.gitolite.rc
sudo -u git -H sh -c "PATH=/home/git/bin:$PATH; gl-setup -q /home/git/gitlab.pub"
2012-03-12 13:47:57 +01:00
Permissions:
2012-03-12 13:47:57 +01:00
sudo chmod -R g+rwX /home/git/repositories/
sudo chown -R git:git /home/git/repositories/
sudo chown gitlab:gitlab /home/git/repositories/**/hooks/post-receive
2012-03-12 13:47:57 +01:00
#### CHECK: Logout & login again to apply git group to your user
# clone admin repo to add localhost to known_hosts
# & be sure your user has access to gitolite
sudo -u gitlab -H git clone git@localhost:gitolite-admin.git /tmp/gitolite-admin
# if succeed you can remove it
sudo rm -rf /tmp/gitolite-admin
**IMPORTANT! If you cant clone `gitolite-admin` repository - DONT PROCEED INSTALLATION**
2012-03-12 13:47:57 +01:00
# 4. Install gitlab and configuration. Check status configuration.
sudo gem install charlock_holmes
sudo pip install pygments
sudo gem install bundler
cd /home/gitlab
2012-06-04 16:38:08 +02:00
sudo -H -u gitlab git clone -b stable git://github.com/gitlabhq/gitlabhq.git gitlab
2012-03-12 13:47:57 +01:00
cd gitlab
sudo -u gitlab mkdir tmp
2012-03-12 13:47:57 +01:00
# Rename config files
sudo -u gitlab cp config/gitlab.yml.example config/gitlab.yml
#### Select db you want to use
2012-03-12 13:47:57 +01:00
# SQLite
sudo -u gitlab cp config/database.yml.sqlite config/database.yml
# Or
# Mysql
sudo -u gitlab cp config/database.yml.example config/database.yml
2012-03-13 19:19:03 +01:00
# Change username/password of config/database.yml to real one
2012-03-12 13:47:57 +01:00
#### Install gems
2012-03-12 13:47:57 +01:00
sudo -u gitlab -H bundle install --without development test --deployment
#### Setup DB
2012-04-04 00:02:54 +02:00
sudo -u gitlab bundle exec rake gitlab:app:setup RAILS_ENV=production
2012-03-12 13:47:57 +01:00
Checking status:
2012-04-04 00:02:54 +02:00
sudo -u gitlab bundle exec rake gitlab:app:status RAILS_ENV=production
2012-03-12 13:47:57 +01:00
# OUTPUT EXAMPLE
Starting diagnostic
config/database.yml............exists
config/gitlab.yml............exists
/home/git/repositories/............exists
/home/git/repositories/ is writable?............YES
remote: Counting objects: 603, done.
remote: Compressing objects: 100% (466/466), done.
remote: Total 603 (delta 174), reused 0 (delta 0)
Receiving objects: 100% (603/603), 53.29 KiB, done.
Resolving deltas: 100% (174/174), done.
Can clone gitolite-admin?............YES
UMASK for .gitolite.rc is 0007? ............YES
2012-03-13 19:19:03 +01:00
If you got all YES - congrats! You can go to next step.
2012-03-12 13:47:57 +01:00
# 5. Server up
2012-03-13 19:19:03 +01:00
Application can be started with next command:
2012-03-13 19:19:03 +01:00
# For test purposes
2012-03-12 13:47:57 +01:00
sudo -u gitlab bundle exec rails s -e production
2012-03-13 19:19:03 +01:00
# As daemon
sudo -u gitlab bundle exec rails s -e production -d
2012-03-12 13:47:57 +01:00
You can login via web using admin generated with setup:
admin@local.host
5iveL!fe
2012-03-12 13:47:57 +01:00
# 6. Run resque process (for processing queue).
# Manually
sudo -u gitlab bundle exec rake environment resque:work QUEUE=* RAILS_ENV=production BACKGROUND=yes
# Gitlab start script
./resque.sh
2012-03-13 19:19:03 +01:00
**Ok - we have a working application now. **
**But keep going - there are some thing that should be done **
2012-03-13 19:19:03 +01:00
2012-03-12 13:47:57 +01:00
# Nginx && Unicorn
### Install Nginx
sudo apt-get install nginx
## Unicorn
2012-03-12 13:47:57 +01:00
cd /home/gitlab/gitlab
sudo -u gitlab cp config/unicorn.rb.orig config/unicorn.rb
2012-03-16 13:58:49 +01:00
sudo -u gitlab bundle exec unicorn_rails -c config/unicorn.rb -E production -D
2012-03-12 13:47:57 +01:00
2012-07-13 19:26:52 +02:00
Edit /etc/nginx/nginx.conf. In the *http* section add:
2012-03-13 19:19:03 +01:00
2012-03-12 13:47:57 +01:00
upstream gitlab {
2012-04-01 21:44:02 +02:00
server unix:/home/gitlab/gitlab/tmp/sockets/gitlab.socket;
2012-03-12 13:47:57 +01:00
}
server {
2012-07-13 19:26:52 +02:00
listen YOUR_SERVER_IP:80; # e.g., listen 192.168.1.1:80;
server_name YOUR_SERVER_FQDN; # e.g., server_name source.example.com;
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 / {
2012-07-13 19:26:52 +02:00
# 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;
2012-07-13 19:26:52 +02:00
# you need to change this to "https", if you set "ssl" directive to "on"
proxy_set_header X-FORWARDED_PROTO http;
2012-07-13 19:26:52 +02:00
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_pass http://gitlab;
2012-03-12 13:47:57 +01:00
}
}
2012-07-13 19:26:52 +02:00
Change **YOUR_SERVER_IP** and **YOUR_SERVER_FQDN** to the IP address and fully-qualified domain name of the host serving GitLab.
2012-03-13 19:19:03 +01:00
2012-03-12 13:47:57 +01:00
Restart nginx:
2012-03-12 13:47:57 +01:00
/etc/init.d/nginx restart
2012-03-13 19:19:03 +01:00
2012-03-12 13:47:57 +01:00
Create init script in /etc/init.d/gitlab:
2012-03-12 13:47:57 +01:00
#! /bin/bash
### BEGIN INIT INFO
2012-04-02 01:57:09 +02:00
# Provides: gitlab
# Required-Start: $local_fs $remote_fs $network $syslog redis-server
2012-03-12 13:47:57 +01:00
# Required-Stop: $local_fs $remote_fs $network $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
2012-04-02 01:57:09 +02:00
# Short-Description: GitLab git repository management
# Description: GitLab git repository management
2012-03-12 13:47:57 +01:00
### 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
2012-03-15 18:49:36 +01:00
RESQUE_PID=/home/gitlab/gitlab/tmp/pids/resque_worker.pid
2012-03-12 13:47:57 +01:00
case "$1" in
start)
CD_TO_APP_DIR="cd /home/gitlab/gitlab"
START_DAEMON_PROCESS="bundle exec unicorn_rails $DAEMON_OPTS"
2012-03-15 19:06:26 +01:00
START_RESQUE_PROCESS="./resque.sh"
2012-03-12 13:47:57 +01:00
echo -n "Starting $DESC: "
if [ `whoami` = root ]; then
sudo -u gitlab sh -l -c "$CD_TO_APP_DIR > /dev/null 2>&1 && $START_DAEMON_PROCESS && $START_RESQUE_PROCESS"
2012-03-12 13:47:57 +01:00
else
2012-03-15 18:49:36 +01:00
$CD_TO_APP_DIR > /dev/null 2>&1 && $START_DAEMON_PROCESS && $START_RESQUE_PROCESS
2012-03-12 13:47:57 +01:00
fi
echo "$NAME."
;;
stop)
echo -n "Stopping $DESC: "
kill -QUIT `cat $PID`
2012-03-15 18:49:36 +01:00
kill -QUIT `cat $RESQUE_PID`
2012-03-12 13:47:57 +01:00
echo "$NAME."
;;
restart)
echo -n "Restarting $DESC: "
kill -USR2 `cat $PID`
2012-03-15 18:49:36 +01:00
kill -USR2 `cat $RESQUE_PID`
2012-03-12 13:47:57 +01:00
echo "$NAME."
;;
reload)
echo -n "Reloading $DESC configuration: "
kill -HUP `cat $PID`
2012-03-15 18:49:36 +01:00
kill -HUP `cat $RESQUE_PID`
2012-03-12 13:47:57 +01:00
echo "$NAME."
;;
*)
echo "Usage: $NAME {start|stop|restart|reload}" >&2
exit 1
;;
esac
exit 0
2012-03-12 13:51:21 +01:00
Adding permission:
2012-03-12 13:51:21 +01:00
sudo chmod +x /etc/init.d/gitlab
2012-06-23 12:09:06 +02:00
Gitlab autostart:
2012-06-23 12:09:06 +02:00
sudo update-rc.d gitlab defaults
2012-03-12 13:47:57 +01:00
2012-03-13 19:19:03 +01:00
Now you can start/restart/stop gitlab like:
2012-03-13 19:19:03 +01:00
sudo /etc/init.d/gitlab restart