installation.md 8.3 KB
Newer Older
1
This installation guide was created for Debian/Ubuntu and tested on it. Please read [`doc/install/requirements.md`](./requirements.md) for hardware and platform requirements.
V
Valery Sizov 已提交
2

3
This installation guide is recommended to set up a production server. If you want a development environment please use the [Vargrant virtual machine](https://github.com/gitlabhq/gitlab-vagrant-vm) since it makes it much easier to set up all the dependencies for integration testing.
D
Dmitriy Zaporozhets 已提交
4

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


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

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

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

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

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


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

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

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

43 44 45 46 47 48 49
**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 已提交
50
Install the required packages:
51

K
Koen Punt 已提交
52
    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
53 54 55 56 57 58

Make sure you have the right version of Python installed.

    # Install Python
    sudo apt-get install python

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

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

65
    # Make sure you can access Python via python2
66 67 68 69
    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
70 71


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

74 75
Download and compile it:

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

83 84 85 86
Install the Bundler Gem:

    sudo gem install bundler

V
Valery Sizov 已提交
87

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

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

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

94

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

97 98
GitLab Shell is a ssh access and repository management software developed specially for GitLab.

99
    # Login as git
D
Dmitriy Zaporozhets 已提交
100
    sudo su git
101

102
    # Go to home directory
103
    cd /home/git
104

105
    # Clone gitlab shell
J
James Newton 已提交
106
    git clone https://github.com/gitlabhq/gitlab-shell.git
107

D
Dmitriy Zaporozhets 已提交
108 109
    cd gitlab-shell
    cp config.yml.example config.yml
110

111
    # Edit config and replace gitlab_url
112 113 114 115
    # with something like 'http://domain.com/'
    vim config.yml

    # Do setup
116
    ./bin/install
V
Valery Sizov 已提交
117

D
Dmitriy Zaporozhets 已提交
118

119
# 5. Database
R
randx 已提交
120

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


R
randx 已提交
124
# 6. GitLab
V
Valery Sizov 已提交
125

D
Dmitriy Zaporozhets 已提交
126 127
    # We'll install GitLab into home directory of the user "git"
    cd /home/git
128

R
Riyad Preukschas 已提交
129
## Clone the Source
R
randx 已提交
130

D
Dmitriy Zaporozhets 已提交
131
    # Clone GitLab repository
D
Dmitriy Zaporozhets 已提交
132
    sudo -u git -H git clone https://github.com/gitlabhq/gitlabhq.git gitlab
D
Dmitriy Zaporozhets 已提交
133

134
    # Go to gitlab dir
D
Dmitriy Zaporozhets 已提交
135
    cd /home/git/gitlab
136

D
Dmitriy Zaporozhets 已提交
137
    # Checkout to stable release
138
    sudo -u git -H git checkout 5-0-stable
139

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

R
Riyad Preukschas 已提交
144
## Configure it
R
randx 已提交
145

D
Dmitriy Zaporozhets 已提交
146
    cd /home/git/gitlab
147

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

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

R
Riyad Preukschas 已提交
155
    # Make sure GitLab can write to the log/ and tmp/ directories
156 157
    sudo chown -R git log/
    sudo chown -R git tmp/
R
Riyad Preukschas 已提交
158 159 160
    sudo chmod -R u+rwX  log/
    sudo chmod -R u+rwX  tmp/

161
    # Create directory for satellites
D
Dmitriy Zaporozhets 已提交
162
    sudo -u git -H mkdir /home/git/gitlab-satellites
163

164 165 166
    # Create directory for pids and make sure GitLab can write to it
    sudo -u git -H mkdir tmp/pids/
    sudo chmod -R u+rwX  tmp/pids/
167

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

171
**Important Note:**
R
Riyad Preukschas 已提交
172 173
Make sure to edit both files to match your setup.

174 175 176
## Configure GitLab DB settings

    # Mysql
D
Dmitriy Zaporozhets 已提交
177
    sudo -u git cp config/database.yml.mysql config/database.yml
178 179

    # PostgreSQL
D
Dmitriy Zaporozhets 已提交
180
    sudo -u git cp config/database.yml.postgresql config/database.yml
181 182 183

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

R
Riyad Preukschas 已提交
184
## Install Gems
185

D
Dmitriy Zaporozhets 已提交
186
    cd /home/git/gitlab
187

188
    sudo gem install charlock_holmes --version '0.6.9'
189

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

193
    # Or for PostgreSQL
D
Dmitriy Zaporozhets 已提交
194
    sudo -u git -H bundle install --deployment --without development test mysql
195

196

R
Riyad Preukschas 已提交
197
## Initialise Database and Activate Advanced Features
198

D
Dmitriy Zaporozhets 已提交
199
    sudo -u git -H bundle exec rake gitlab:setup RAILS_ENV=production
200 201


202 203 204 205
## Install Init Script

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

K
Koen Punt 已提交
206
    sudo curl --output /etc/init.d/gitlab https://raw.github.com/gitlabhq/gitlab-recipes/master/init.d/gitlab
207 208 209 210 211 212 213
    sudo chmod +x /etc/init.d/gitlab

Make GitLab start on boot:

    sudo update-rc.d gitlab defaults 21


R
Riyad Preukschas 已提交
214
## Check Application Status
R
Robert Speicher 已提交
215

216
Check if GitLab and its environment are configured correctly:
217

D
Dmitriy Zaporozhets 已提交
218
    sudo -u git -H bundle exec rake gitlab:env:info RAILS_ENV=production
219 220

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

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

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

227
## Start Your GitLab Instance
V
Valery Sizov 已提交
228

R
randx 已提交
229
    sudo service gitlab start
R
Riyad Preukschas 已提交
230 231
    # or
    sudo /etc/init.d/gitlab restart
232

V
Valery Sizov 已提交
233

R
randx 已提交
234
# 7. Nginx
235

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

R
Riyad Preukschas 已提交
240
## Installation
241
    sudo apt-get install nginx
242

R
Riyad Preukschas 已提交
243 244 245 246
## Site Configuration

Download an example site config:

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

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

252 253
    # Change **YOUR_SERVER_IP** and **YOUR_SERVER_FQDN**
    # to the IP address and fully-qualified domain name
R
Riyad Preukschas 已提交
254
    # of your host serving GitLab
255
    sudo vim /etc/nginx/sites-available/gitlab
D
Dmitriy Zaporozhets 已提交
256

R
Riyad Preukschas 已提交
257 258
## Restart

259
    sudo service nginx restart
D
Dmitriy Zaporozhets 已提交
260

261

R
Riyad Preukschas 已提交
262
# Done!
263

R
Riyad Preukschas 已提交
264 265
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 已提交
266

267 268
    admin@local.host
    5iveL!fe
269

270
**Important Note:**
R
Riyad Preukschas 已提交
271 272 273 274 275
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 已提交
276

R
randx 已提交
277 278
- - -

V
Valery Sizov 已提交
279

280
# Advanced Setup Tips
R
randx 已提交
281

282
## Custom Redis Connection
283 284

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

R
Riyad Preukschas 已提交
288
    # example
289
    production: redis://redis.example.tld:6379
290

291 292
## Custom SSH Connection

293
If you are running SSH on a non-standard port, you must change the gitlab user's SSH config.
294

D
Dmitriy Zaporozhets 已提交
295
    # Add to /home/git/.ssh/config
296 297 298 299
    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
300

301
You also need to change the corresponding options (e.g. ssh_user, ssh_host, admin_uri) in the `config\gitlab.yml` file.
302 303 304 305 306

## 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/).