gitlab-org--gitlab-foss/doc/install/installation.md

264 lines
6.9 KiB
Markdown
Raw Normal View History

2012-10-25 04:13:11 -04:00
_This installation guide created for Debian/Ubuntu and properly tested._
2012-03-12 08:47:57 -04:00
2012-10-25 04:13:11 -04:00
_Checkout requirements before setup_
2012-03-13 14:19:03 -04:00
### IMPORTANT
2012-10-10 10:17:23 -04:00
Please make sure you have followed all the steps below before posting to the mailing list with installation and configuration questions.
2012-10-10 10:17:23 -04:00
Only create a GitHub Issue if you want a specific part of this installation guide updated.
2012-10-10 10:17:23 -04: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-10-10 10:17:23 -04:00
2012-10-25 04:13:11 -04:00
- - -
2012-03-13 14:19:03 -04:00
2012-10-24 13:42:55 -04:00
# Basic setup
2012-03-12 08:47:57 -04:00
2012-10-24 13:42:55 -04:00
The basic installation will provide you a GitLab setup with options:
2012-10-24 13:42:55 -04:00
1. ruby 1.9.3
2. mysql as main db
3. gitolite v3 fork by gitlab
4. nginx + unicorn
2012-10-24 13:42:55 -04:00
The installation consists of next steps:
2012-10-24 13:59:48 -04:00
1. Packages / dependencies
2. Ruby
3. Users
4. Gitolite
5. Mysql
6. GitLab.
7. Nginx
2012-03-12 08:47:57 -04:00
# 1. Packages / dependencies
2012-03-12 08:47:57 -04: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 08:47:57 -04:00
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install -y wget curl build-essential checkinstall libxml2-dev libxslt-dev libcurl4-openssl-dev libreadline6-dev libc6-dev libssl-dev zlib1g-dev libicu-dev redis-server openssh-server git-core python2.7 libyaml-dev postfix
2012-10-24 13:59:48 -04:00
sudo pip install pygments
# 2. Install Ruby
2012-03-12 08:47:57 -04:00
2012-09-04 12:44:17 -04: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 08:47:57 -04:00
./configure
make
sudo make install
2012-10-24 13:59:48 -04:00
# 3. Users
2012-03-12 08:47:57 -04:00
Create user for git:
2012-03-12 08:47:57 -04: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 08:47:57 -04:00
# ubuntu/debian
sudo adduser --disabled-login --gecos 'gitlab system' gitlab
2012-03-12 08:47:57 -04:00
2012-10-25 04:13:11 -04:00
Add your users to groups:
2012-03-12 08:47:57 -04:00
sudo usermod -a -G git gitlab
sudo usermod -a -G gitlab git
2012-03-12 08:47:57 -04:00
Generate key:
2012-03-12 08:47:57 -04:00
sudo -H -u gitlab ssh-keygen -q -N '' -t rsa -f /home/gitlab/.ssh/id_rsa
2012-10-24 13:59:48 -04:00
# 4. Gitolite
Clone GitLab's fork of the Gitolite source code:
2012-08-28 19:03:04 -04:00
sudo -H -u git git clone -b gl-v304 https://github.com/gitlabhq/gitolite.git /home/git/gitolite
2012-03-12 08:47:57 -04:00
Setup:
2012-08-28 19:03:04 -04: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-28 19:03:04 -04:00
sudo -u git sh -c 'gitolite/install -ln /home/git/bin'
2012-03-12 08:47:57 -04:00
sudo cp /home/gitlab/.ssh/id_rsa.pub /home/git/gitlab.pub
sudo chmod 0444 /home/git/gitlab.pub
2012-03-12 08:47:57 -04:00
2012-08-28 19:03:04 -04:00
sudo -u git -H sh -c "PATH=/home/git/bin:$PATH; gitolite setup -pk /home/git/gitlab.pub"
2012-03-12 08:47:57 -04:00
Permissions:
2012-03-12 08:47:57 -04: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 08:47:57 -04:00
# if succeed you can remove it
sudo rm -rf /tmp/gitolite-admin
2012-03-12 08:47:57 -04: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 08:47:57 -04:00
# 5. Database
2012-10-24 13:42:55 -04:00
See doc/install/databases.md
2012-10-24 13:42:55 -04:00
2012-10-24 13:59:48 -04:00
# 6. GitLab
2012-03-12 08:47:57 -04:00
cd /home/gitlab
2012-10-24 13:59:48 -04: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 13:59:48 -04:00
#### Copy configs
2012-03-12 08:47:57 -04:00
cd gitlab
2012-03-12 08:47:57 -04:00
# Rename config files
2012-10-25 04:13:11 -04:00
#
2012-03-12 08:47:57 -04:00
sudo -u gitlab cp config/gitlab.yml.example config/gitlab.yml
2012-10-25 04:13:11 -04:00
# Copy unicorn config
#
sudo -u gitlab cp config/unicorn.rb.example config/unicorn.rb
2012-10-09 19:41:33 -04:00
2012-03-12 08:47:57 -04:00
#### Install gems
2012-10-24 13:59:48 -04:00
cd /home/gitlab/gitlab
sudo gem install charlock_holmes --version '0.6.9'
2012-10-24 13:59:48 -04:00
sudo gem install bundler
2012-11-27 15:36:09 -05:00
sudo -u gitlab -H bundle install --without development test postgres --deployment
2012-03-12 08:47:57 -04:00
#### Configure git client
Gitlab needs to be able to commit and push changes to gitolite.
Git requires a username and email in order to be able to do that.
sudo -u gitlab -H git config --global user.email "gitlab@localhost"
sudo -u gitlab -H git config --global user.name "Gitlab"
2012-10-24 13:59:48 -04:00
#### Setup application
2012-04-03 18:02:54 -04:00
sudo -u gitlab bundle exec rake gitlab:app:setup RAILS_ENV=production
2012-10-24 13:50:34 -04:00
#### Setup GitLab hooks
2012-08-28 19:03:04 -04: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 08:47:57 -04:00
Checking status:
2012-04-03 18:02:54 -04:00
sudo -u gitlab bundle exec rake gitlab:app:status RAILS_ENV=production
2012-03-12 08:47:57 -04: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 08:47:57 -04:00
2012-10-24 13:50:34 -04:00
If you got all YES - congratulations! You can run a GitLab app.
2012-03-12 08:47:57 -04:00
2012-10-24 13:59:48 -04:00
#### init script
2012-03-12 08:47:57 -04:00
2012-10-24 13:50:34 -04:00
Create init script in /etc/init.d/gitlab:
2012-10-24 13:50:34 -04:00
sudo wget https://raw.github.com/gitlabhq/gitlab-recipes/master/init.d/gitlab -P /etc/init.d/
sudo chmod +x /etc/init.d/gitlab
2012-10-24 13:50:34 -04:00
GitLab autostart:
2012-10-24 13:50:34 -04:00
sudo update-rc.d gitlab defaults 21
2012-03-13 14:19:03 -04:00
2012-10-24 13:59:48 -04:00
#### Now you should start GitLab application:
2012-03-12 08:47:57 -04:00
2012-10-24 13:50:34 -04:00
sudo service gitlab start
2012-03-12 08:47:57 -04:00
2012-10-24 13:50:34 -04:00
# 7. Nginx
# Install first
sudo apt-get install nginx
# Add GitLab to nginx sites & change with your host specific settings
2012-09-04 12:44:17 -04:00
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
2012-03-12 08:47:57 -04: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 14:19:03 -04:00
# Restart nginx:
sudo /etc/init.d/nginx restart
2012-03-13 14:19:03 -04:00
2012-10-25 04:13:11 -04:00
# Done! Visit YOUR_SERVER for gitlab instance
You can login via web using admin generated with setup:
2012-03-12 08:51:21 -04:00
admin@local.host
5iveL!fe
2012-03-12 08:47:57 -04:00
2012-10-25 04:13:11 -04:00
- - -
2012-03-12 08:47:57 -04:00
2012-10-24 13:42:55 -04:00
# Advanced setup tips:
## 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 **