installation.md 7.45 KB
Newer Older
1 2 3
This installation guide was created for Debian/Ubuntu and tested on it.

Please read doc/install/requirements.md for hardware andplatform requirements.
Valery Sizov's avatar
Valery Sizov committed
4

Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
5

Riyad Preukschas's avatar
Riyad Preukschas committed
6 7 8 9 10 11
**Important Note**
The following steps have been known to work.
If you deviate from this guide, do it with caution and make sure you don't
violate any assumptions GitLab makes about its environment.
If you find a bug/error in this guide please an issue or pull request following
the contribution guide (see CONTRIBUTING.md).
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
12

randx's avatar
randx committed
13
- - -
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
14

Riyad Preukschas's avatar
Riyad Preukschas committed
15
# Overview
Valery Sizov's avatar
Valery Sizov committed
16

Riyad Preukschas's avatar
Riyad Preukschas committed
17
The GitLab installation consists of setting up th following components:
18

Riyad Preukschas's avatar
Riyad Preukschas committed
19
1. Packages / Dependencies
randx's avatar
randx committed
20
2. Ruby
Riyad Preukschas's avatar
Riyad Preukschas committed
21
3. System Users
randx's avatar
randx committed
22
4. Gitolite
Riyad Preukschas's avatar
Riyad Preukschas committed
23 24 25
5. Database
6. GitLab
7. Nginx
Valery Sizov's avatar
Valery Sizov committed
26 27


Riyad Preukschas's avatar
Riyad Preukschas committed
28
# 1. Packages / Dependencies
Valery Sizov's avatar
Valery Sizov committed
29

30 31 32 33
*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

Riyad Preukschas's avatar
Riyad Preukschas committed
34
Make sure your system is up-to-date:
Valery Sizov's avatar
Valery Sizov committed
35 36 37 38

    sudo apt-get update
    sudo apt-get upgrade

Riyad Preukschas's avatar
Riyad Preukschas committed
39
Install the required packages:
40

Riyad Preukschas's avatar
Riyad Preukschas committed
41
    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
42 43


Riyad Preukschas's avatar
Riyad Preukschas committed
44
# 2. Ruby
Valery Sizov's avatar
Valery Sizov committed
45

Riyad Preukschas's avatar
Riyad Preukschas committed
46 47 48
    wget http://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.3-p327.tar.gz
    tar xfvz ruby-1.9.3-p327.tar.gz
    cd ruby-1.9.3-p327
Valery Sizov's avatar
Valery Sizov committed
49 50 51 52 53
    ./configure
    make
    sudo make install


Riyad Preukschas's avatar
Riyad Preukschas committed
54 55 56
# 3. System Users

Create a user for Git and Gitolite:
57

Valery Sizov's avatar
Valery Sizov committed
58 59 60
    sudo adduser \
      --system \
      --shell /bin/sh \
Riyad Preukschas's avatar
Riyad Preukschas committed
61
      --gecos 'Git Version Control' \
Valery Sizov's avatar
Valery Sizov committed
62 63 64 65 66
      --group \
      --disabled-password \
      --home /home/git \
      git

Riyad Preukschas's avatar
Riyad Preukschas committed
67
Create a user for GitLab:
Valery Sizov's avatar
Valery Sizov committed
68

Riyad Preukschas's avatar
Riyad Preukschas committed
69
    sudo adduser --disabled-login --gecos 'GitLab' gitlab
70

Riyad Preukschas's avatar
Riyad Preukschas committed
71 72
    # Add it to the git group
    sudo addmod -a -G git gitlab
73

Riyad Preukschas's avatar
Riyad Preukschas committed
74
    # Generate the SSH key
75
    sudo -u gitlab -H ssh-keygen -q -N '' -t rsa -f /home/gitlab/.ssh/id_rsa
Valery Sizov's avatar
Valery Sizov committed
76

randx's avatar
randx committed
77 78 79

# 4. Gitolite

80
Clone GitLab's fork of the Gitolite source code:
81

82
    sudo -u git -H git clone -b gl-v304 https://github.com/gitlabhq/gitolite.git /home/git/gitolite
Valery Sizov's avatar
Valery Sizov committed
83

Riyad Preukschas's avatar
Riyad Preukschas committed
84 85 86 87
Setup Gitolite with GitLab as its admin:

**Important Note**
GitLab assumes *full and unshared* control over this Gitolite installation.
88

Riyad Preukschas's avatar
Riyad Preukschas committed
89
    # Add Gitolite scripts to $PATH
randx's avatar
randx committed
90 91
    cd /home/git
    sudo -u git -H mkdir bin
92 93
    sudo -u git -H sh -c 'echo -e "PATH=\$PATH:/home/git/bin\nexport PATH" >> /home/git/.profile'
    sudo -u git -H sh -c 'gitolite/install -ln /home/git/bin'
randx's avatar
randx committed
94

Riyad Preukschas's avatar
Riyad Preukschas committed
95
    # Copy the gitlab user's (public) SSH key ...
Valery Sizov's avatar
Valery Sizov committed
96
    sudo cp /home/gitlab/.ssh/id_rsa.pub /home/git/gitlab.pub
97
    sudo chmod 0444 /home/git/gitlab.pub
Valery Sizov's avatar
Valery Sizov committed
98

Riyad Preukschas's avatar
Riyad Preukschas committed
99
    # ... and use it as the Gitolite admin key for setup
randx's avatar
randx committed
100
    sudo -u git -H sh -c "PATH=/home/git/bin:$PATH; gitolite setup -pk /home/git/gitlab.pub"
101

Riyad Preukschas's avatar
Riyad Preukschas committed
102
Fix the directory permissions for the repository:
103

Riyad Preukschas's avatar
Riyad Preukschas committed
104
    # Make sure the repositories dir is owned by git and it stays that way
105
    sudo chmod -R ug+rwXs /home/git/repositories/
Valery Sizov's avatar
Valery Sizov committed
106 107
    sudo chown -R git:git /home/git/repositories/

Riyad Preukschas's avatar
Riyad Preukschas committed
108 109 110 111
## Test if everything works so far

    # Clone the admin repo so SSH adds localhost to known_hosts ...
    # ... and to be sure your users have access to Gitolite
112
    sudo -u gitlab -H git clone git@localhost:gitolite-admin.git /tmp/gitolite-admin
Valery Sizov's avatar
Valery Sizov committed
113

Riyad Preukschas's avatar
Riyad Preukschas committed
114
    # If it succeeded without errors you can remove the cloned repo
115
    sudo rm -rf /tmp/gitolite-admin
Valery Sizov's avatar
Valery Sizov committed
116

Riyad Preukschas's avatar
Riyad Preukschas committed
117 118
**Impornant Note**
If you can't clone the `gitolite-admin` repository: **DO NOT PROCEED WITH INSTALLATION**
119
Check the [Trouble Shooting Guide](https://github.com/gitlabhq/gitlab-public-wiki/wiki/Trouble-Shooting-Guide)
Riyad Preukschas's avatar
Riyad Preukschas committed
120
and make sure you have followed all of the above steps carefully.
Valery Sizov's avatar
Valery Sizov committed
121 122


123
# 5. Database
randx's avatar
randx committed
124

125
See doc/install/databases.md
randx's avatar
randx committed
126 127


randx's avatar
randx committed
128
# 6. GitLab
Valery Sizov's avatar
Valery Sizov committed
129

Riyad Preukschas's avatar
Riyad Preukschas committed
130
    We'll install GitLab into the gitlab user's home directory
Valery Sizov's avatar
Valery Sizov committed
131
    cd /home/gitlab
132

Riyad Preukschas's avatar
Riyad Preukschas committed
133
## Clone the Source
randx's avatar
randx committed
134

Riyad Preukschas's avatar
Riyad Preukschas committed
135
    # Clone the latest stable release
136
    sudo -u gitlab -H git clone -b stable https://github.com/gitlabhq/gitlabhq.git gitlab
137

Riyad Preukschas's avatar
Riyad Preukschas committed
138 139 140
**Note***
You can change `stable` to `master` if you want the *bleeding edge* version, but
do so with caution!
141

Riyad Preukschas's avatar
Riyad Preukschas committed
142
## Configure it
randx's avatar
randx committed
143

Riyad Preukschas's avatar
Riyad Preukschas committed
144
    cd /home/gitlab/gitlab
145

Riyad Preukschas's avatar
Riyad Preukschas committed
146
    # Copy the example GitLab config
147
    sudo -u gitlab -H cp config/gitlab.yml.example config/gitlab.yml
Valery Sizov's avatar
Valery Sizov committed
148

Riyad Preukschas's avatar
Riyad Preukschas committed
149
    # Copy the example Unicorn config
150
    sudo -u gitlab -H cp config/unicorn.rb.example config/unicorn.rb
Andrey Kumanyaev's avatar
Andrey Kumanyaev committed
151

Riyad Preukschas's avatar
Riyad Preukschas committed
152 153 154
Make sure to edit both files to match your setup.

## Install Gems
155

randx's avatar
randx committed
156
    cd /home/gitlab/gitlab
157

158
    sudo gem install charlock_holmes --version '0.6.9'
randx's avatar
randx committed
159
    sudo gem install bundler
Riyad Preukschas's avatar
Riyad Preukschas committed
160
    sudo -u gitlab -H bundle install --deployment --without development test 
Valery Sizov's avatar
Valery Sizov committed
161

Riyad Preukschas's avatar
Riyad Preukschas committed
162
## Configure Git
163

Riyad Preukschas's avatar
Riyad Preukschas committed
164 165 166
GitLab needs to be able to commit and push changes to Gitolite. In order to do
that Git requires a username and email. (Please use the `email.from` address
for the email)
167

Riyad Preukschas's avatar
Riyad Preukschas committed
168
    sudo -u gitlab -H git config --global user.name "GitLab"
169 170
    sudo -u gitlab -H git config --global user.email "gitlab@localhost"

Riyad Preukschas's avatar
Riyad Preukschas committed
171
## Setup GitLab hooks
172

Riyad Preukschas's avatar
Riyad Preukschas committed
173 174
    sudo cp ./lib/hooks/post-receive /home/git/.gitolite/hooks/common/post-receive
    sudo chown git:git /home/git/.gitolite/hooks/common/post-receive
175

Riyad Preukschas's avatar
Riyad Preukschas committed
176
## Initialise Database and Activate Advanced Features
randx's avatar
randx committed
177

Riyad Preukschas's avatar
Riyad Preukschas committed
178
    sudo -u gitlab -H bundle exec rake gitlab:app:setup RAILS_ENV=production
179 180


Riyad Preukschas's avatar
Riyad Preukschas committed
181
## Check Application Status
182

Riyad Preukschas's avatar
Riyad Preukschas committed
183
Just to check we didn't miss anything.
184

185
    sudo -u gitlab -H bundle exec rake gitlab:app:status RAILS_ENV=production
Valery Sizov's avatar
Valery Sizov committed
186

Riyad Preukschas's avatar
Riyad Preukschas committed
187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202
```
# 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
```
Valery Sizov's avatar
Valery Sizov committed
203

Riyad Preukschas's avatar
Riyad Preukschas committed
204 205
If you are all green - congratulations! You run a GitLab now.
But there are still a few steps to go.
Valery Sizov's avatar
Valery Sizov committed
206 207


Riyad Preukschas's avatar
Riyad Preukschas committed
208
## Install Init Script
Valery Sizov's avatar
Valery Sizov committed
209

Riyad Preukschas's avatar
Riyad Preukschas committed
210
Download the init script (will be /etc/init.d/gitlab):
211

randx's avatar
randx committed
212 213
    sudo wget https://raw.github.com/gitlabhq/gitlab-recipes/master/init.d/gitlab -P /etc/init.d/
    sudo chmod +x /etc/init.d/gitlab
214

Riyad Preukschas's avatar
Riyad Preukschas committed
215
Make GitLab start on boot:
216

randx's avatar
randx committed
217
    sudo update-rc.d gitlab defaults 21
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
218

Riyad Preukschas's avatar
Riyad Preukschas committed
219 220

Start your GitLab instance:
Valery Sizov's avatar
Valery Sizov committed
221

randx's avatar
randx committed
222
    sudo service gitlab start
223

Valery Sizov's avatar
Valery Sizov committed
224

randx's avatar
randx committed
225
# 7. Nginx
226

Riyad Preukschas's avatar
Riyad Preukschas committed
227
## Installation
228
    sudo apt-get install nginx
229

Riyad Preukschas's avatar
Riyad Preukschas committed
230 231 232 233
## Site Configuration

Download an example site config:

randx's avatar
randx committed
234
    sudo wget https://raw.github.com/gitlabhq/gitlab-recipes/master/nginx/gitlab -P /etc/nginx/sites-available/
235
    sudo ln -s /etc/nginx/sites-available/gitlab /etc/nginx/sites-enabled/gitlab
Valery Sizov's avatar
Valery Sizov committed
236

Riyad Preukschas's avatar
Riyad Preukschas committed
237 238
Make sure to edit the config file to match your setup:

239 240
    # Change **YOUR_SERVER_IP** and **YOUR_SERVER_FQDN**
    # to the IP address and fully-qualified domain name
Riyad Preukschas's avatar
Riyad Preukschas committed
241
    # of your host serving GitLab
242
    sudo vim /etc/nginx/sites-enabled/gitlab
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
243

Riyad Preukschas's avatar
Riyad Preukschas committed
244 245
## Restart

246
    sudo /etc/init.d/nginx restart
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
247

248

Riyad Preukschas's avatar
Riyad Preukschas committed
249
# Done!
250

Riyad Preukschas's avatar
Riyad Preukschas committed
251 252
Visit YOUR_SERVER for your first GitLab login.
The setup has created an admin account for you. You can use it to log in:
Valery Sizov's avatar
Valery Sizov committed
253

254 255
    admin@local.host
    5iveL!fe
256

Riyad Preukschas's avatar
Riyad Preukschas committed
257 258 259 260 261 262
**Important Note**
Please go over to your profile page and immediately chage the password, so
nobody can access your GitLab by using this login information later on.

**Enjoy!**

Valery Sizov's avatar
Valery Sizov committed
263

randx's avatar
randx committed
264 265
- - -

Valery Sizov's avatar
Valery Sizov committed
266

randx's avatar
randx committed
267 268
# Advanced setup tips:

Riyad Preukschas's avatar
Riyad Preukschas committed
269
## Custom Redis connections
270 271

If you'd like Resque to connect to a Redis server on a non-standard port or on
Riyad Preukschas's avatar
Riyad Preukschas committed
272 273
a different host, you can configure its connection string via the
`config/resque.yml` file.
274

Riyad Preukschas's avatar
Riyad Preukschas committed
275 276
    # example
    production: redis.example.tld:6379