2012-08-26 16:18:13 +02:00
## Platform requirements:
2012-03-12 13:47:57 +01:00
2012-03-28 09:07:24 +02: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.
2012-03-28 09:07:24 +02:00
We officially support (recent versions of) these Linux distributions:
2012-03-13 19:19:03 +01:00
2012-03-28 09:07:24 +02:00
- Ubuntu Linux
- Debian/GNU Linux
2012-03-13 19:19:03 +01:00
It should work on:
- Fedora
- CentOs
2012-03-28 09:07:24 +02:00
- RedHat
2012-03-13 19:19:03 +01:00
2012-03-28 09:07:24 +02:00
You might have some luck using these, but no guarantees:
2012-03-13 19:19:03 +01:00
2012-03-28 09:07:24 +02:00
- MacOS X
2012-03-13 19:19:03 +01:00
- FreeBSD
2012-09-04 11:26:25 +02:00
GitLab does **not** run on Windows and we have no plans of making GitLab compatible.
2012-03-13 19:19:03 +01:00
2012-08-26 16:18:13 +02:00
## This installation guide created for Debian/Ubuntu and properly tested.
2012-03-13 19:19:03 +01:00
The installation consists of 6 steps:
2012-03-12 13:47:57 +01:00
2012-03-28 09:07:24 +02:00
1. Install packages / dependencies
2. Install ruby
2012-09-04 11:26:25 +02:00
3. Install Gitolite
4. Install and configure GitLab.
2012-03-28 09:07:24 +02:00
5. Start the web front-end
6. Start a Resque worker (for background processing)
### IMPORTANT
2012-09-04 11:26:25 +02:00
Please make sure you have followed all the steps below before posting to the mailing list with installation and configuration questions.
2012-03-28 09:07:24 +02:00
2012-09-04 11:26:25 +02:00
Only create a GitHub Issue if you want a specific part of this installation guide updated.
2012-03-12 13:47:57 +01:00
2012-03-28 09:07:24 +02: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
> - - -
2012-09-04 11:26:25 +02:00
> The first 3 steps of this guide can be easily skipped by executing an install script:
2012-08-26 16:18:13 +02:00
>
> # Install curl and sudo
2012-03-13 19:19:03 +01:00
> apt-get install curl sudo
2012-08-26 16:18:13 +02:00
>
2012-03-13 19:19:03 +01:00
> # 3 steps in 1 command :)
2012-09-04 18:44:17 +02:00
> curl https://raw.github.com/gitlabhq/gitlab-recipes/master/install/debian_ubuntu.sh | sh
2012-08-26 16:18:13 +02:00
>
2012-09-04 11:26:25 +02:00
> Now you can go to [Step 4](#4-install-gitlab-and-configuration-check-status-configuration)
2012-09-02 22:41:21 +02:00
>
2012-09-04 11:26:25 +02:00
> Or if you are installing on Amazon Web Services using Ubuntu 12.04 you can do all steps (1 to 6) at once with:
2012-09-02 22:41:21 +02:00
>
2012-09-04 18:44:17 +02:00
> curl https://raw.github.com/gitlabhq/gitlab-recipes/master/install/debian_ubuntu_aws.sh | sh
2012-09-02 22:41:21 +02:00
>
2012-09-04 18:44:17 +02:00
> for more detailed instructions read the HOWTO section of [the script](https://github.com/gitlabhq/gitlab-recipes/blob/master/install/debian_ubuntu_aws.sh)
2012-03-13 19:19:03 +01:00
> - - -
2012-03-12 13:47:57 +01:00
# 1. Install packages
2012-09-04 11:26:25 +02:00
*Keep in mind that `sudo` is not installed on Debian by default. You should install it as root:*
apt-get update & & apt-get upgrade & & apt-get install sudo
Now install the required packages:
2012-03-12 13:47:57 +01:00
sudo apt-get update
sudo apt-get upgrade
2012-07-30 23:42:40 +02:00
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 postfix
2012-08-26 16:18:13 +02:00
2012-03-28 09:07:24 +02:00
# 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
2012-09-04 11:26:25 +02:00
# 2. Install Ruby
2012-03-12 13:47:57 +01:00
2012-09-04 18:44:17 +02:00
wget http://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.3-p194.tar.gz
tar xfvz ruby-1.9.3-p194.tar.gz
cd ruby-1.9.3-p194
2012-03-12 13:47:57 +01:00
./configure
make
sudo make install
2012-09-04 11:26:25 +02:00
# 3. Install Gitolite
2012-03-12 13:47:57 +01:00
Create user for git:
2012-08-26 16:18:13 +02:00
2012-03-12 13:47:57 +01:00
sudo adduser \
--system \
--shell /bin/sh \
--gecos 'git version control' \
--group \
--disabled-password \
--home /home/git \
git
2012-09-04 11:26:25 +02:00
Create user for GitLab:
2012-03-13 23:07:13 +01:00
2012-03-12 13:47:57 +01:00
# ubuntu/debian
2012-08-26 16:18:13 +02:00
sudo adduser --disabled-login --gecos 'gitlab system' gitlab
2012-03-12 13:47:57 +01:00
2012-09-04 11:26:25 +02:00
Add your user to the `git` group:
2012-03-13 23:07:13 +01:00
2012-03-12 13:47:57 +01:00
sudo usermod -a -G git gitlab
Generate key:
2012-03-13 23:07:13 +01:00
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-09-04 11:26:25 +02:00
Clone GitLab's fork of the Gitolite source code:
2012-03-13 23:07:13 +01:00
2012-03-12 13:47:57 +01:00
cd /home/git
2012-08-29 01:03:04 +02:00
sudo -H -u git git clone -b gl-v304 https://github.com/gitlabhq/gitolite.git /home/git/gitolite
2012-03-12 13:47:57 +01:00
Setup:
2012-03-13 23:07:13 +01:00
2012-08-29 01:03:04 +02:00
cd /home/git
sudo -u git -H mkdir bin
2012-07-10 12:47:30 +02:00
sudo -u git sh -c 'echo -e "PATH=\$PATH:/home/git/bin\nexport PATH" >> /home/git/.profile'
2012-08-29 01:03:04 +02:00
sudo -u git sh -c 'gitolite/install -ln /home/git/bin'
2012-03-12 13:47:57 +01:00
sudo cp /home/gitlab/.ssh/id_rsa.pub /home/git/gitlab.pub
2012-07-06 00:25:53 +02:00
sudo chmod 0444 /home/git/gitlab.pub
2012-03-12 13:47:57 +01:00
2012-08-29 01:03:04 +02:00
sudo -u git -H sh -c "PATH=/home/git/bin:$PATH; gitolite setup -pk /home/git/gitlab.pub"
sudo -u git -H sed -i 's/0077/0007/g' /home/git/.gitolite.rc
2012-08-26 16:18:13 +02:00
2012-03-12 13:47:57 +01:00
Permissions:
2012-03-13 23:07:13 +01:00
2012-03-12 13:47:57 +01:00
sudo chmod -R g+rwX /home/git/repositories/
sudo chown -R git:git /home/git/repositories/
#### CHECK: Logout & login again to apply git group to your user
2012-08-26 16:18:13 +02:00
2012-03-12 13:47:57 +01:00
# clone admin repo to add localhost to known_hosts
# & be sure your user has access to gitolite
2012-08-26 16:18:13 +02:00
sudo -u gitlab -H git clone git@localhost:gitolite-admin.git /tmp/gitolite-admin
2012-03-12 13:47:57 +01:00
# if succeed you can remove it
2012-08-26 16:18:13 +02:00
sudo rm -rf /tmp/gitolite-admin
2012-03-12 13:47:57 +01:00
2012-09-04 11:26:25 +02:00
**IMPORTANT! If you can't clone `gitolite-admin` repository - DO NOT PROCEED WITH INSTALLATION**
Check the [Trouble Shooting Guide ](https://github.com/gitlabhq/gitlab-public-wiki/wiki/Trouble-Shooting-Guide )
and ensure you have followed all of the above steps carefully.
2012-03-12 13:47:57 +01:00
2012-09-04 11:26:25 +02:00
# 4. Clone GitLab source and install prerequisites
2012-03-12 13:47:57 +01:00
2012-08-19 09:20:42 +02:00
sudo gem install charlock_holmes --version '0.6.8'
2012-03-12 13:47:57 +01:00
sudo pip install pygments
sudo gem install bundler
cd /home/gitlab
2012-09-16 12:39:49 +02:00
# Get gitlab code. Use this for stable setup
2012-09-04 11:26:25 +02:00
sudo -H -u gitlab git clone -b stable https://github.com/gitlabhq/gitlabhq.git gitlab
2012-09-16 12:39:49 +02:00
# Skip this for stable setup.
# Master branch (recent changes, less stable)
sudo -H -u gitlab git clone -b master https://github.com/gitlabhq/gitlabhq.git gitlab
2012-03-12 13:47:57 +01:00
cd gitlab
2012-08-26 16:18:13 +02:00
2012-03-12 13:47:57 +01:00
# Rename config files
sudo -u gitlab cp config/gitlab.yml.example config/gitlab.yml
2012-09-04 11:26:25 +02:00
#### Select the database you want to use
2012-03-13 23:07:13 +01:00
2012-03-12 13:47:57 +01:00
# SQLite
sudo -u gitlab cp config/database.yml.sqlite config/database.yml
2012-08-26 16:18:13 +02:00
# Or
2012-03-12 13:47:57 +01:00
# Mysql
2012-07-30 03:47:28 +02:00
# Install MySQL as directed in Step #1
2012-08-26 16:18:13 +02:00
2012-07-30 03:47:28 +02:00
# Login to MySQL
2012-08-26 16:18:13 +02:00
$ mysql -u root -p
2012-09-06 09:50:47 +02:00
# Create the GitLab production database
2012-07-30 03:47:28 +02:00
mysql> CREATE DATABASE IF NOT EXISTS `gitlabhq_production` DEFAULT CHARACTER SET `utf8` COLLATE `utf8_unicode_ci` ;
2012-08-26 16:18:13 +02:00
2012-07-30 03:47:28 +02:00
# Create the MySQL User change $password to a real password
2012-08-26 16:18:13 +02:00
mysql> CREATE USER 'gitlab'@'localhost' IDENTIFIED BY '$password';
2012-07-30 03:47:28 +02:00
# Grant proper permissions to the MySQL User
mysql> GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER ON `gitlabhq_production` .* TO 'gitlab'@'localhost';
2012-08-26 16:18:13 +02:00
2012-07-30 03:47:28 +02:00
# Exit MySQL Server and copy the example config, make sure to update username/password in config/database.yml
2012-03-12 13:47:57 +01:00
sudo -u gitlab cp config/database.yml.example config/database.yml
#### Install gems
2012-03-13 23:07:13 +01:00
2012-03-12 13:47:57 +01:00
sudo -u gitlab -H bundle install --without development test --deployment
2012-09-04 11:26:25 +02:00
#### Setup database
2012-03-13 23:07:13 +01:00
2012-04-04 00:02:54 +02:00
sudo -u gitlab bundle exec rake gitlab:app:setup RAILS_ENV=production
2012-08-26 16:18:13 +02:00
2012-09-04 11:26:25 +02:00
#### Setup GitLab hooks
2012-09-02 18:31:16 +02:00
2012-08-29 01:03:04 +02:00
sudo cp ./lib/hooks/post-receive /home/git/.gitolite/hooks/common/post-receive
sudo chown git:git /home/git/.gitolite/hooks/common/post-receive
2012-09-02 18:31:16 +02:00
2012-09-04 11:26:25 +02:00
#### Check application status
2012-03-12 13:47:57 +01:00
Checking status:
2012-03-13 23:07:13 +01:00
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-09-02 18:31:16 +02:00
/home/git/share/gitolite/hooks/common/post-receive exists? ............YES
2012-03-12 13:47:57 +01:00
2012-09-04 11:26:25 +02:00
If you got all YES - congratulations! You can go to the next step.
2012-03-12 13:47:57 +01:00
2012-09-04 11:26:25 +02:00
# 5. Start the web server
2012-03-12 13:47:57 +01:00
2012-03-13 19:19:03 +01:00
Application can be started with next command:
2012-03-13 23:07:13 +01:00
2012-08-26 16:18:13 +02: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
2012-08-02 14:30:22 +02:00
You can login via web using admin generated with setup:
admin@local.host
5iveL!fe
2012-09-04 11:26:25 +02:00
# 6. Run Resque process (for processing job queue).
2012-03-12 13:47:57 +01:00
# Manually
sudo -u gitlab bundle exec rake environment resque:work QUEUE=* RAILS_ENV=production BACKGROUND=yes
2012-09-04 11:26:25 +02:00
# GitLab start script
2012-07-30 03:49:43 +02:00
sudo -u gitlab ./resque.sh
# if you run this as root /home/gitlab/gitlab/tmp/pids/resque_worker.pid will be owned by root
# causing the resque worker not to start via init script on next boot/service restart
2012-03-13 19:19:03 +01:00
2012-03-28 09:07:24 +02:00
**Ok - we have a working application now. **
2012-08-29 13:04:37 +02:00
**But keep going - there are some things that should be done **
2012-03-13 19:19:03 +01:00
2012-03-12 13:47:57 +01:00
# Nginx && Unicorn
2012-09-04 19:50:00 +02:00
## 1. Unicorn
2012-03-13 23:07:13 +01:00
2012-03-12 13:47:57 +01:00
cd /home/gitlab/gitlab
2012-09-15 21:23:41 +02:00
sudo -u gitlab cp config/unicorn.rb.example 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-09-04 19:50:00 +02:00
## 2. Nginx
# Install first
sudo apt-get install nginx
2012-08-26 16:18:13 +02:00
2012-09-04 19:50:00 +02:00
# Add GitLab to nginx sites & change with your host specific settings
2012-09-04 18:44:17 +02:00
sudo wget https://raw.github.com/gitlabhq/gitlab-recipes/master/nginx/gitlab -P /etc/nginx/sites-available/
2012-09-02 18:31:16 +02:00
sudo ln -s /etc/nginx/sites-available/gitlab /etc/nginx/sites-enabled/gitlab
2012-03-12 13:47:57 +01:00
2012-09-02 18:31:16 +02:00
# Change **YOUR_SERVER_IP** and **YOUR_SERVER_FQDN**
# to the IP address and fully-qualified domain name
# of the host serving GitLab.
sudo vim /etc/nginx/sites-enabled/gitlab
2012-03-13 19:19:03 +01:00
2012-03-13 23:07:13 +01:00
2012-09-04 19:50:00 +02: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-09-04 19:50:00 +02:00
## 3. Init script
2012-03-12 13:47:57 +01:00
Create init script in /etc/init.d/gitlab:
2012-03-13 23:07:13 +01:00
2012-09-04 18:44:17 +02:00
sudo wget https://raw.github.com/gitlabhq/gitlab-recipes/master/init.d/gitlab -P /etc/init.d/
2012-03-12 13:51:21 +01:00
sudo chmod +x /etc/init.d/gitlab
2012-09-04 11:26:25 +02:00
GitLab autostart:
2012-03-13 23:07:13 +01:00
2012-06-23 12:09:06 +02:00
sudo update-rc.d gitlab defaults
2012-03-12 13:47:57 +01:00
2012-09-04 11:26:25 +02:00
Now you can start/restart/stop GitLab like:
2012-03-13 23:07:13 +01:00
2012-03-13 19:19:03 +01:00
sudo /etc/init.d/gitlab restart