installation.md 8.44 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.
Valery Sizov's avatar
Valery Sizov committed
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.
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
4

5
**Important Note:**
Riyad Preukschas's avatar
Riyad Preukschas committed
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).
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
17

randx's avatar
randx committed
18
- - -
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
19

Riyad Preukschas's avatar
Riyad Preukschas committed
20
# Overview
Valery Sizov's avatar
Valery Sizov committed
21

22
The GitLab installation consists of setting up the following components:
23

Riyad Preukschas's avatar
Riyad Preukschas committed
24
1. Packages / Dependencies
randx's avatar
randx committed
25
2. Ruby
Riyad Preukschas's avatar
Riyad Preukschas committed
26
3. System Users
Lele's avatar
Lele committed
27
4. GitLab shell
Riyad Preukschas's avatar
Riyad Preukschas committed
28 29 30
5. Database
6. GitLab
7. Nginx
Valery Sizov's avatar
Valery Sizov committed
31 32


Riyad Preukschas's avatar
Riyad Preukschas committed
33
# 1. Packages / Dependencies
Valery Sizov's avatar
Valery Sizov committed
34

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

38
    # run as root
39 40 41
    apt-get update
    apt-get upgrade
    apt-get install sudo
Valery Sizov's avatar
Valery Sizov committed
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

Riyad Preukschas's avatar
Riyad Preukschas committed
50
Install the required packages:
51

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

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


Riyad Preukschas's avatar
Riyad Preukschas committed
72
# 2. Ruby
Valery Sizov's avatar
Valery Sizov committed
73

74 75
Download and compile it:

76
    mkdir /tmp/ruby && cd /tmp/ruby
77
    curl --progress http://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.3-p327.tar.gz | tar xz
Riyad Preukschas's avatar
Riyad Preukschas committed
78
    cd ruby-1.9.3-p327
Valery Sizov's avatar
Valery Sizov committed
79 80 81 82
    ./configure
    make
    sudo make install

83 84 85 86
Install the Bundler Gem:

    sudo gem install bundler

Valery Sizov's avatar
Valery Sizov committed
87

Riyad Preukschas's avatar
Riyad Preukschas committed
88 89
# 3. System Users

90
Create a `git` user for Gitlab:
91

92
    sudo adduser --disabled-login --gecos 'GitLab' git
Valery Sizov's avatar
Valery Sizov committed
93

94

95
# 4. GitLab shell
Valery Sizov's avatar
Valery Sizov committed
96

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

99
    # Login as git
100
    sudo su git
101

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

105
    # Clone gitlab shell
106
    git clone https://github.com/gitlabhq/gitlab-shell.git
107

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
Valery Sizov's avatar
Valery Sizov committed
117

118

119
# 5. Database
randx's avatar
randx committed
120

121
To setup the MySQL/PostgreSQL database and dependencies please see [`doc/install/databases.md`](./databases.md).
randx's avatar
randx committed
122 123


randx's avatar
randx committed
124
# 6. GitLab
Valery Sizov's avatar
Valery Sizov committed
125

126 127
    # We'll install GitLab into home directory of the user "git"
    cd /home/git
128

Riyad Preukschas's avatar
Riyad Preukschas committed
129
## Clone the Source
randx's avatar
randx committed
130

Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
131
    # Clone GitLab repository
132
    sudo -u git -H git clone https://github.com/gitlabhq/gitlabhq.git gitlab
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
133

134
    # Go to gitlab dir
135
    cd /home/git/gitlab
136

Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
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
Riyad Preukschas's avatar
Riyad Preukschas committed
142
do so with caution!
143

Riyad Preukschas's avatar
Riyad Preukschas committed
144
## Configure it
randx's avatar
randx committed
145

146
    cd /home/git/gitlab
147

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

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

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

161
    # Create directory for satellites
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

Riyad Preukschas's avatar
Riyad Preukschas committed
168
    # Copy the example Unicorn config
169
    sudo -u git -H cp config/unicorn.rb.example config/unicorn.rb
Andrey Kumanyaev's avatar
Andrey Kumanyaev committed
170

171
**Important Note:**
Riyad Preukschas's avatar
Riyad Preukschas committed
172 173
Make sure to edit both files to match your setup.

174 175 176
## Configure GitLab DB settings

    # Mysql
177
    sudo -u git cp config/database.yml.mysql config/database.yml
178 179

    # PostgreSQL
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.

Riyad Preukschas's avatar
Riyad Preukschas committed
184
## Install Gems
185

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")
191
    sudo -u git -H bundle install --deployment --without development test postgres
192

193
    # Or for PostgreSQL
194
    sudo -u git -H bundle install --deployment --without development test mysql
195

196

Riyad Preukschas's avatar
Riyad Preukschas committed
197
## Initialise Database and Activate Advanced Features
198

199 200
    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
201
    sudo -u git -H bundle exec rake gitlab:setup RAILS_ENV=production
202 203


204 205 206 207
## Install Init Script

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

208
    sudo curl --output /etc/init.d/gitlab https://raw.github.com/gitlabhq/gitlab-recipes/master/init.d/gitlab
209 210 211 212 213 214 215
    sudo chmod +x /etc/init.d/gitlab

Make GitLab start on boot:

    sudo update-rc.d gitlab defaults 21


Riyad Preukschas's avatar
Riyad Preukschas committed
216
## Check Application Status
217

218
Check if GitLab and its environment are configured correctly:
219

220
    sudo -u git -H bundle exec rake gitlab:env:info RAILS_ENV=production
221 222

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

224
    sudo -u git -H bundle exec rake gitlab:check RAILS_ENV=production
Valery Sizov's avatar
Valery Sizov committed
225

226 227
If all items are green, then congratulations on successfully installing GitLab!
However there are still a few steps left.
Valery Sizov's avatar
Valery Sizov committed
228

229
## Start Your GitLab Instance
Valery Sizov's avatar
Valery Sizov committed
230

randx's avatar
randx committed
231
    sudo service gitlab start
Riyad Preukschas's avatar
Riyad Preukschas committed
232 233
    # or
    sudo /etc/init.d/gitlab restart
234

Valery Sizov's avatar
Valery Sizov committed
235

randx's avatar
randx committed
236
# 7. Nginx
237

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

Riyad Preukschas's avatar
Riyad Preukschas committed
242
## Installation
243
    sudo apt-get install nginx
244

Riyad Preukschas's avatar
Riyad Preukschas committed
245 246 247 248
## Site Configuration

Download an example site config:

249
    sudo curl --output /etc/nginx/sites-available/gitlab https://raw.github.com/gitlabhq/gitlab-recipes/master/nginx/gitlab
250
    sudo ln -s /etc/nginx/sites-available/gitlab /etc/nginx/sites-enabled/gitlab
Valery Sizov's avatar
Valery Sizov committed
251

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

254 255
    # Change **YOUR_SERVER_IP** and **YOUR_SERVER_FQDN**
    # to the IP address and fully-qualified domain name
Riyad Preukschas's avatar
Riyad Preukschas committed
256
    # of your host serving GitLab
257
    sudo vim /etc/nginx/sites-available/gitlab
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
258

Riyad Preukschas's avatar
Riyad Preukschas committed
259 260
## Restart

261
    sudo service nginx restart
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
262

263

Riyad Preukschas's avatar
Riyad Preukschas committed
264
# Done!
265

Riyad Preukschas's avatar
Riyad Preukschas committed
266 267
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
268

269 270
    admin@local.host
    5iveL!fe
271

272
**Important Note:**
Riyad Preukschas's avatar
Riyad Preukschas committed
273 274 275 276 277
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
278

randx's avatar
randx committed
279 280
- - -

Valery Sizov's avatar
Valery Sizov committed
281

282
# Advanced Setup Tips
randx's avatar
randx committed
283

284
## Custom Redis Connection
285 286

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
287 288
a different host, you can configure its connection string via the
`config/resque.yml` file.
289

Riyad Preukschas's avatar
Riyad Preukschas committed
290
    # example
291
    production: redis://redis.example.tld:6379
292

293 294
## Custom SSH Connection

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

297
    # Add to /home/git/.ssh/config
298 299 300 301
    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
302

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

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