gitlabhq/doc/install/installation.md

276 lines
7.4 KiB
Markdown
Raw Normal View History

2012-10-25 10:13:11 +02:00
_This installation guide created for Debian/Ubuntu and properly tested._
2012-03-13 19:19:03 +01:00
2012-10-25 10:13:11 +02:00
_Checkout requirements before setup_
### IMPORTANT
Please make sure you have followed all the steps below before posting to the mailing list 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-10-25 10:13:11 +02:00
- - -
2012-10-24 19:42:55 +02:00
# Basic setup
The basic installation will provide you a GitLab setup with options:
1. ruby 1.9.3
2. mysql as main db
3. gitolite v3 fork by gitlab
4. nginx + unicorn
The installation consists of next steps:
2012-10-24 19:59:48 +02:00
1. Packages / dependencies
2. Ruby
3. Users
4. Gitolite
5. Mysql
6. GitLab.
7. Nginx
2012-03-12 13:47:57 +01:00
2012-10-24 19:42:55 +02:00
# 1. Packages / dependencies
2012-03-12 13:47:57 +01: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-10-12 19:12:35 +02:00
sudo apt-get install -y wget curl gcc checkinstall libxml2-dev libxslt-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 libpq-dev
2012-10-24 19:59:48 +02:00
sudo pip install pygments
# 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-10-24 19:59:48 +02:00
# 3. Users
2012-03-12 13:47:57 +01:00
Create user for git:
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
Create user for GitLab:
2012-03-12 13:47:57 +01:00
# ubuntu/debian
sudo adduser --disabled-login --gecos 'gitlab system' gitlab
2012-03-12 13:47:57 +01:00
2012-10-25 10:13:11 +02:00
Add your users to groups:
2012-03-12 13:47:57 +01:00
sudo usermod -a -G git gitlab
sudo usermod -a -G gitlab git
2012-03-12 13:47:57 +01:00
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-10-24 19:59:48 +02:00
# 4. Gitolite
Clone GitLab's fork of the Gitolite source code:
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-08-29 01:03:04 +02:00
cd /home/git
sudo -u git -H mkdir bin
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
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"
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/
# 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
2012-03-12 13:47:57 +01:00
# if succeed you can remove it
sudo rm -rf /tmp/gitolite-admin
2012-03-12 13:47:57 +01: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-10-24 19:42:55 +02:00
2012-10-24 19:59:48 +02:00
# 5. Mysql database
2012-10-24 19:42:55 +02:00
sudo apt-get install -y mysql-server mysql-client libmysqlclient-dev
# Login to MySQL
$ mysql -u root -p
# Create the GitLab production database
mysql> CREATE DATABASE IF NOT EXISTS `gitlabhq_production` DEFAULT CHARACTER SET `utf8` COLLATE `utf8_unicode_ci`;
# Create the MySQL User change $password to a real password
mysql> CREATE USER 'gitlab'@'localhost' IDENTIFIED BY '$password';
# Grant proper permissions to the MySQL User
mysql> GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER ON `gitlabhq_production`.* TO 'gitlab'@'localhost';
2012-10-24 19:59:48 +02:00
# 6. GitLab
2012-03-12 13:47:57 +01:00
cd /home/gitlab
2012-10-24 19:59:48 +02:00
#### Get source code
# Get gitlab code. Use this for stable setup
sudo -H -u gitlab git clone -b stable https://github.com/gitlabhq/gitlabhq.git gitlab
# 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-10-24 19:59:48 +02:00
#### Copy configs
2012-03-12 13:47:57 +01:00
cd gitlab
2012-03-12 13:47:57 +01:00
# Rename config files
2012-10-25 10:13:11 +02:00
#
2012-03-12 13:47:57 +01:00
sudo -u gitlab cp config/gitlab.yml.example config/gitlab.yml
2012-10-24 19:42:55 +02:00
# Copy mysql db config
2012-10-25 10:13:11 +02:00
#
# make sure to update username/password in config/database.yml
2012-10-25 10:13:11 +02:00
#
2012-10-24 19:42:55 +02:00
sudo -u gitlab cp config/database.yml.mysql config/database.yml
2012-10-10 01:41:33 +02:00
2012-10-25 10:13:11 +02:00
# Copy unicorn config
#
sudo -u gitlab cp config/unicorn.rb.example config/unicorn.rb
2012-03-12 13:47:57 +01:00
#### Install gems
2012-10-24 19:59:48 +02:00
cd /home/gitlab/gitlab
sudo gem install charlock_holmes --version '0.6.8'
sudo gem install bundler
2012-10-10 01:41:33 +02:00
sudo -u gitlab -H bundle install --without development test sqlite postgres --deployment
2012-10-24 19:59:48 +02:00
#### Setup application
2012-04-04 00:02:54 +02:00
sudo -u gitlab bundle exec rake gitlab:app:setup RAILS_ENV=production
2012-10-24 19:50:34 +02:00
#### Setup GitLab hooks
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
#### Check application status
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
/home/git/share/gitolite/hooks/common/post-receive exists? ............YES
2012-03-12 13:47:57 +01:00
2012-10-24 19:50:34 +02:00
If you got all YES - congratulations! You can run a GitLab app.
2012-03-12 13:47:57 +01:00
2012-10-24 19:59:48 +02:00
#### init script
2012-10-24 19:42:55 +02:00
2012-10-24 19:50:34 +02:00
Create init script in /etc/init.d/gitlab:
sudo wget https://raw.github.com/gitlabhq/gitlab-recipes/master/init.d/gitlab -P /etc/init.d/
sudo chmod +x /etc/init.d/gitlab
GitLab autostart:
sudo update-rc.d gitlab defaults 21
2012-10-24 19:59:48 +02:00
#### Now you should start GitLab application:
2012-10-24 19:50:34 +02:00
sudo service gitlab start
2012-10-24 19:42:55 +02:00
2012-10-24 19:50:34 +02:00
# 7. Nginx
2012-10-24 19:42:55 +02:00
# Install first
sudo apt-get install nginx
# Add GitLab to nginx sites & change with your host specific settings
sudo wget https://raw.github.com/gitlabhq/gitlab-recipes/master/nginx/gitlab -P /etc/nginx/sites-available/
sudo ln -s /etc/nginx/sites-available/gitlab /etc/nginx/sites-enabled/gitlab
# 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
# Restart nginx:
sudo /etc/init.d/nginx restart
2012-03-12 13:47:57 +01:00
2012-10-25 10:13:11 +02:00
# Done! Visit YOUR_SERVER for gitlab instance
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
2012-10-25 10:13:11 +02:00
- - -
2012-03-12 13:47:57 +01:00
2012-10-24 19:42:55 +02:00
# Advanced setup tips:
_Checkout databases.md for postgres or sqlite_
2012-10-24 19:59:48 +02:00
## Customizing Resque's Redis connection
If you'd like Resque to connect to a Redis server on a non-standard port or on
a different host, you can configure its connection string in the
**config/resque.yml** file:
production: redis.example.com:6379
**Ok - we have a working application now. **
**But keep going - there are some things that should be done **