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

3
Please read [`doc/install/requirements.md`](./requirements.md) for hardware and platform requirements.
V
Valery Sizov 已提交
4

D
Dmitriy Zaporozhets 已提交
5

6
**Important Note:**
R
Riyad Preukschas 已提交
7 8 9
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.
10
For things like AWS installation scripts, init scripts or config files for
11 12
alternative web server have a look at the [`Advanced Setup
Tips`](./installation.md#advanced-setup-tips) section.
13 14 15 16


**Important Note:**
If you find a bug/error in this guide please submit an issue or pull request
17
following the [`contribution guide`](../../CONTRIBUTING.md).
D
Dmitriy Zaporozhets 已提交
18

R
randx 已提交
19
- - -
D
Dmitriy Zaporozhets 已提交
20

R
Riyad Preukschas 已提交
21
# Overview
V
Valery Sizov 已提交
22

P
PaulWagener 已提交
23
The GitLab installation consists of setting up the following components:
24

R
Riyad Preukschas 已提交
25
1. Packages / Dependencies
R
randx 已提交
26
2. Ruby
R
Riyad Preukschas 已提交
27
3. System Users
R
randx 已提交
28
4. Gitolite
R
Riyad Preukschas 已提交
29 30 31
5. Database
6. GitLab
7. Nginx
V
Valery Sizov 已提交
32 33


R
Riyad Preukschas 已提交
34
# 1. Packages / Dependencies
V
Valery Sizov 已提交
35

36 37
`sudo` is not installed on Debian by default. Make sure your system is
up-to-date and install it.
R
Robert Speicher 已提交
38

39
    # run as root
40 41 42
    apt-get update
    apt-get upgrade
    apt-get install sudo
V
Valery Sizov 已提交
43

44 45 46 47 48 49 50
**Note:**
Vim is an editor that is used here whenever there are files that need to be
edited by hand. But, you can use any editor you like instead.

    # Install vim
    sudo apt-get install -y vim

R
Riyad Preukschas 已提交
51
Install the required packages:
52

K
Koen Punt 已提交
53
    sudo apt-get install -y build-essential zlib1g-dev libyaml-dev libssl-dev libgdbm-dev libreadline-dev libncurses5-dev libffi-dev curl git-core openssh-server redis-server postfix checkinstall libxml2-dev libxslt-dev libcurl4-openssl-dev libicu-dev
54 55 56 57 58 59

Make sure you have the right version of Python installed.

    # Install Python
    sudo apt-get install python

R
Riyad Preukschas 已提交
60
    # Make sure that Python is 2.5+ (3.x is not supported at the moment)
61 62 63 64 65
    python --version

    # If it's Python 3 you might need to install Python 2 separately
    sudo apt-get install python2.7

66
    # Make sure you can access Python via python2
67 68 69 70
    python2 --version

    # If you get a "command not found" error create a link to the python binary
    sudo ln -s /usr/bin/python /usr/bin/python2
71 72


R
Riyad Preukschas 已提交
73
# 2. Ruby
V
Valery Sizov 已提交
74

75 76
Download and compile it:

77
    mkdir /tmp/ruby && cd /tmp/ruby
K
Koen Punt 已提交
78
    curl --progress http://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.3-p327.tar.gz | tar xz
R
Riyad Preukschas 已提交
79
    cd ruby-1.9.3-p327
V
Valery Sizov 已提交
80 81 82 83
    ./configure
    make
    sudo make install

84 85 86 87
Install the Bundler Gem:

    sudo gem install bundler

V
Valery Sizov 已提交
88

R
Riyad Preukschas 已提交
89 90
# 3. System Users

D
Dmitriy Zaporozhets 已提交
91
Create a `git` user for Gitlab:
92

D
Dmitriy Zaporozhets 已提交
93
    sudo adduser --disabled-login --gecos 'GitLab' git
V
Valery Sizov 已提交
94

D
Dmitriy Zaporozhets 已提交
95
# 4. GitLab shell
V
Valery Sizov 已提交
96

D
Dmitriy Zaporozhets 已提交
97 98
    # login as git 
    sudo su git
99

D
Dmitriy Zaporozhets 已提交
100
    # go to home directory 
101
    cd /home/git
102

D
Dmitriy Zaporozhets 已提交
103
    # clone gitlab shell
J
James Newton 已提交
104
    git clone https://github.com/gitlabhq/gitlab-shell.git
105

D
Dmitriy Zaporozhets 已提交
106 107 108 109
    # setup
    cd gitlab-shell
    cp config.yml.example config.yml
    ./bin/install 
V
Valery Sizov 已提交
110

D
Dmitriy Zaporozhets 已提交
111

112
# 5. Database
R
randx 已提交
113

114
To setup the MySQL/PostgreSQL database and dependencies please see [`doc/install/databases.md`](./databases.md).
R
randx 已提交
115 116


R
randx 已提交
117
# 6. GitLab
V
Valery Sizov 已提交
118

D
Dmitriy Zaporozhets 已提交
119 120
    # We'll install GitLab into home directory of the user "git"
    cd /home/git
121

R
Riyad Preukschas 已提交
122
## Clone the Source
R
randx 已提交
123

D
Dmitriy Zaporozhets 已提交
124
    # Clone GitLab repository
D
Dmitriy Zaporozhets 已提交
125
    sudo -u git -H git clone https://github.com/gitlabhq/gitlabhq.git gitlab
D
Dmitriy Zaporozhets 已提交
126 127

    # Go to gitlab dir 
D
Dmitriy Zaporozhets 已提交
128
    cd /home/git/gitlab
D
Dmitriy Zaporozhets 已提交
129 130
   
    # Checkout to stable release
131
    sudo -u git -H git checkout 5-0-stable
132

133
**Note:**
134
You can change `5-0-stable` to `master` if you want the *bleeding edge* version, but
R
Riyad Preukschas 已提交
135
do so with caution!
136

R
Riyad Preukschas 已提交
137
## Configure it
R
randx 已提交
138

D
Dmitriy Zaporozhets 已提交
139
    cd /home/git/gitlab
140

R
Riyad Preukschas 已提交
141
    # Copy the example GitLab config
D
Dmitriy Zaporozhets 已提交
142
    sudo -u git -H cp config/gitlab.yml.example config/gitlab.yml
V
Valery Sizov 已提交
143

144 145
    # Make sure to change "localhost" to the fully-qualified domain name of your
    # host serving GitLab where necessary
D
Dmitriy Zaporozhets 已提交
146
    sudo -u git -H vim config/gitlab.yml
147

R
Riyad Preukschas 已提交
148
    # Make sure GitLab can write to the log/ and tmp/ directories
149 150
    sudo chown -R git log/
    sudo chown -R git tmp/
R
Riyad Preukschas 已提交
151 152 153
    sudo chmod -R u+rwX  log/
    sudo chmod -R u+rwX  tmp/

154
    # Make directory for satellites
D
Dmitriy Zaporozhets 已提交
155
    sudo -u git -H mkdir /home/git/gitlab-satellites
156

R
Riyad Preukschas 已提交
157
    # Copy the example Unicorn config
D
Dmitriy Zaporozhets 已提交
158
    sudo -u git -H cp config/unicorn.rb.example config/unicorn.rb
A
Andrey Kumanyaev 已提交
159

160
**Important Note:**
R
Riyad Preukschas 已提交
161 162
Make sure to edit both files to match your setup.

163 164 165
## Configure GitLab DB settings

    # Mysql
D
Dmitriy Zaporozhets 已提交
166
    sudo -u git cp config/database.yml.mysql config/database.yml
167 168

    # PostgreSQL
D
Dmitriy Zaporozhets 已提交
169
    sudo -u git cp config/database.yml.postgresql config/database.yml
170 171 172

Make sure to update username/password in config/database.yml.

R
Riyad Preukschas 已提交
173
## Install Gems
174

D
Dmitriy Zaporozhets 已提交
175
    cd /home/git/gitlab
176

177
    sudo gem install charlock_holmes --version '0.6.9'
178

179
    # For MySQL (note, the option says "without")
D
Dmitriy Zaporozhets 已提交
180
    sudo -u git -H bundle install --deployment --without development test postgres
181

182
    # Or for PostgreSQL
D
Dmitriy Zaporozhets 已提交
183
    sudo -u git -H bundle install --deployment --without development test mysql
184

185

R
Riyad Preukschas 已提交
186
## Initialise Database and Activate Advanced Features
187 188 189
    
    sudo -u git -H bundle exec rake db:setup RAILS_ENV=production
    sudo -u git -H bundle exec rake db:seed_fu RAILS_ENV=production
D
Dmitriy Zaporozhets 已提交
190
    sudo -u git -H bundle exec rake gitlab:setup RAILS_ENV=production
191 192


193 194 195 196
## Install Init Script

Download the init script (will be /etc/init.d/gitlab):

K
Koen Punt 已提交
197
    sudo curl --output /etc/init.d/gitlab https://raw.github.com/gitlabhq/gitlab-recipes/master/init.d/gitlab
198 199 200 201 202 203 204
    sudo chmod +x /etc/init.d/gitlab

Make GitLab start on boot:

    sudo update-rc.d gitlab defaults 21


R
Riyad Preukschas 已提交
205
## Check Application Status
R
Robert Speicher 已提交
206

207
Check if GitLab and its environment is configured correctly:
208

D
Dmitriy Zaporozhets 已提交
209
    sudo -u git -H bundle exec rake gitlab:env:info RAILS_ENV=production
210 211

To make sure you didn't miss anything run a more thorough check with:
212

D
Dmitriy Zaporozhets 已提交
213
    sudo -u git -H bundle exec rake gitlab:check RAILS_ENV=production
V
Valery Sizov 已提交
214

215 216
If all items are green, then congratulations on successfully installing GitLab!
However there are still a few steps left.
V
Valery Sizov 已提交
217

218
## Start Your GitLab Instance
V
Valery Sizov 已提交
219

R
randx 已提交
220
    sudo service gitlab start
R
Riyad Preukschas 已提交
221 222
    # or
    sudo /etc/init.d/gitlab restart
223

V
Valery Sizov 已提交
224

R
randx 已提交
225
# 7. Nginx
226

227 228
**Note:**
If you can't or don't want to use Nginx as your web server, have a look at the
229
[`Advanced Setup Tips`](./installation.md#advanced-setup-tips) section.
230

R
Riyad Preukschas 已提交
231
## Installation
232
    sudo apt-get install nginx
233

R
Riyad Preukschas 已提交
234 235 236 237
## Site Configuration

Download an example site config:

K
Koen Punt 已提交
238
    sudo curl --output /etc/nginx/sites-available/gitlab https://raw.github.com/gitlabhq/gitlab-recipes/master/nginx/gitlab
239
    sudo ln -s /etc/nginx/sites-available/gitlab /etc/nginx/sites-enabled/gitlab
V
Valery Sizov 已提交
240

R
Riyad Preukschas 已提交
241 242
Make sure to edit the config file to match your setup:

243 244
    # Change **YOUR_SERVER_IP** and **YOUR_SERVER_FQDN**
    # to the IP address and fully-qualified domain name
R
Riyad Preukschas 已提交
245
    # of your host serving GitLab
246
    sudo vim /etc/nginx/sites-enabled/gitlab
D
Dmitriy Zaporozhets 已提交
247

R
Riyad Preukschas 已提交
248 249
## Restart

250
    sudo /etc/init.d/nginx restart
D
Dmitriy Zaporozhets 已提交
251

252

R
Riyad Preukschas 已提交
253
# Done!
254

R
Riyad Preukschas 已提交
255 256
Visit YOUR_SERVER for your first GitLab login.
The setup has created an admin account for you. You can use it to log in:
V
Valery Sizov 已提交
257

258 259
    admin@local.host
    5iveL!fe
260

261
**Important Note:**
R
Riyad Preukschas 已提交
262 263 264 265 266
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!**

V
Valery Sizov 已提交
267

R
randx 已提交
268 269
- - -

V
Valery Sizov 已提交
270

271
# Advanced Setup Tips
R
randx 已提交
272

273
## Custom Redis Connection
274 275

If you'd like Resque to connect to a Redis server on a non-standard port or on
R
Riyad Preukschas 已提交
276 277
a different host, you can configure its connection string via the
`config/resque.yml` file.
278

R
Riyad Preukschas 已提交
279 280
    # example
    production: redis.example.tld:6379
281

282 283
## Custom SSH Connection

284
If you are running SSH on a non-standard port, you must change the gitlab user'S SSH config.
285
    
D
Dmitriy Zaporozhets 已提交
286
    # Add to /home/git/.ssh/config
287 288 289 290
    host localhost          # Give your setup a name (here: override localhost)
        user git            # Your remote git user
        port 2222           # Your port number
        hostname 127.0.0.1; # Your server name or IP
291

292
You also need to change the corresponding options (e.g. ssh_user, ssh_host, admin_uri) in the `config\gitlab.yml` file.
293 294 295 296 297

## User-contributed Configurations

You can find things like  AWS installation scripts, init scripts or config files
for alternative web server in our [recipes collection](https://github.com/gitlabhq/gitlab-recipes/).