1 # Select Version to Install
2 Make sure you view this installation guide from the branch (version) of GitLab you would like to install. In most cases
3 this should be the highest numbered stable branch (example shown below).
5 ![capture](https://f.cloud.github.com/assets/1192780/564911/2f9f3e1e-c5b7-11e2-9f89-98e527d1adec.png)
7 If this is unclear check the [GitLab Blog](http://blog.gitlab.org/) for installation guide links by version.
11 This installation guide was created for and tested on **Debian/Ubuntu** operating systems. Please read [`doc/install/requirements.md`](./requirements.md) for hardware and operating system requirements.
13 This is the official installation guide to set up a production server. To set up a **development installation** or for many other installation options please consult [the installation section in the readme](https://github.com/gitlabhq/gitlabhq#installation).
15 The following steps have been known to work. Please **use caution when you deviate** from this guide. Make sure you don't violate any assumptions GitLab makes about its environment. For example many people run into permission problems because they changed the location of directories or run services as the wrong user.
17 If you find a bug/error in this guide please **submit a pull request** following the [contributing guide](../../CONTRIBUTING.md).
23 The GitLab installation consists of setting up the following components:
25 1. Packages / Dependencies
34 # 1. Packages / Dependencies
36 `sudo` is not installed on Debian by default. Make sure your system is
37 up-to-date and install it.
42 apt-get install sudo -y
45 During this installation some files will need to be edited manually.
46 If you are familiar with vim set it as default editor with the commands below.
47 If you are not familiar with vim please skip this and keep using the default editor.
49 # Install vim and set as default editor
50 sudo apt-get install -y vim
51 sudo update-alternatives --set editor /usr/bin/vim.basic
53 Install the required packages:
55 sudo apt-get install -y build-essential zlib1g-dev libyaml-dev libssl-dev libgdbm-dev libreadline-dev libncurses5-dev libffi-dev curl openssh-server redis-server checkinstall libxml2-dev libxslt-dev libcurl4-openssl-dev libicu-dev logrotate
57 Make sure you have the right version of Python installed.
60 sudo apt-get install -y python
62 # Make sure that Python is 2.5+ (3.x is not supported at the moment)
65 # If it's Python 3 you might need to install Python 2 separately
66 sudo apt-get install -y python2.7
68 # Make sure you can access Python via python2
71 # If you get a "command not found" error create a link to the python binary
72 sudo ln -s /usr/bin/python /usr/bin/python2
74 # For reStructuredText markup language support install required package:
75 sudo apt-get install -y python-docutils
77 Make sure you have the right version of Git installed
80 sudo apt-get install -y git-core
82 # Make sure Git is version 1.7.10 or higher, for example 1.7.12 or 1.8.4
85 Is the system packaged Git too old? Remove it and compile from source.
88 sudo apt-get remove git-core
90 # Install dependencies
91 sudo apt-get install -y libcurl4-openssl-dev libexpat1-dev gettext libz-dev libssl-dev build-essential
93 # Download and compile from source
95 curl --progress https://git-core.googlecode.com/files/git-1.8.4.1.tar.gz | tar xz
97 make prefix=/usr/local all
99 # Install into /usr/local/bin
100 sudo make prefix=/usr/local install
102 # When editing config/gitlab.yml (Step 6), change the git bin_path to /usr/local/bin/git
104 **Note:** In order to receive mail notifications, make sure to install a
105 mail server. By default, Debian is shipped with exim4 whereas Ubuntu
106 does not ship with one. The recommended mail server is postfix and you can install it with:
108 sudo apt-get install -y postfix
110 Then select 'Internet Site' and press enter to confirm the hostname.
114 Remove the old Ruby 1.8 if present
116 sudo apt-get remove ruby1.8
118 Download Ruby and compile it:
120 mkdir /tmp/ruby && cd /tmp/ruby
121 curl --progress ftp://ftp.ruby-lang.org/pub/ruby/2.0/ruby-2.0.0-p353.tar.gz | tar xz
123 ./configure --disable-install-rdoc
127 Install the Bundler Gem:
129 sudo gem install bundler --no-ri --no-rdoc
134 Create a `git` user for Gitlab:
136 sudo adduser --disabled-login --gecos 'GitLab' git
141 GitLab Shell is an ssh access and repository management software developed specially for GitLab.
143 # Go to home directory
147 sudo -u git -H git clone https://github.com/gitlabhq/gitlab-shell.git -b v1.7.9
151 sudo -u git -H cp config.yml.example config.yml
153 # Edit config and replace gitlab_url
154 # with something like 'http://domain.com/'
155 sudo -u git -H editor config.yml
158 sudo -u git -H ./bin/install
163 To setup the MySQL/PostgreSQL database and dependencies please see [`doc/install/databases.md`](./databases.md).
168 # We'll install GitLab into home directory of the user "git"
173 # Clone GitLab repository
174 sudo -u git -H git clone https://github.com/gitlabhq/gitlabhq.git -b 6-3-stable gitlab
180 You can change `6-3-stable` to `master` if you want the *bleeding edge* version, but never install master on a production server!
186 # Copy the example GitLab config
187 sudo -u git -H cp config/gitlab.yml.example config/gitlab.yml
189 # Make sure to change "localhost" to the fully-qualified domain name of your
190 # host serving GitLab where necessary
192 # If you installed Git from source, change the git bin_path to /usr/local/bin/git
193 sudo -u git -H editor config/gitlab.yml
195 # Make sure GitLab can write to the log/ and tmp/ directories
196 sudo chown -R git log/
197 sudo chown -R git tmp/
198 sudo chmod -R u+rwX log/
199 sudo chmod -R u+rwX tmp/
201 # Create directory for satellites
202 sudo -u git -H mkdir /home/git/gitlab-satellites
204 # Create directories for sockets/pids and make sure GitLab can write to them
205 sudo -u git -H mkdir tmp/pids/
206 sudo -u git -H mkdir tmp/sockets/
207 sudo chmod -R u+rwX tmp/pids/
208 sudo chmod -R u+rwX tmp/sockets/
210 # Create public/uploads directory otherwise backup will fail
211 sudo -u git -H mkdir public/uploads
212 sudo chmod -R u+rwX public/uploads
214 # Copy the example Unicorn config
215 sudo -u git -H cp config/unicorn.rb.example config/unicorn.rb
217 # Enable cluster mode if you expect to have a high load instance
218 # Ex. change amount of workers to 3 for 2GB RAM server
219 sudo -u git -H editor config/unicorn.rb
221 # Copy the example Rack attack config
222 sudo -u git -H cp config/initializers/rack_attack.rb.example config/initializers/rack_attack.rb
224 # Configure Git global settings for git user, useful when editing via web
225 # Edit user.email according to what is set in gitlab.yml
226 sudo -u git -H git config --global user.name "GitLab"
227 sudo -u git -H git config --global user.email "gitlab@localhost"
228 sudo -u git -H git config --global core.autocrlf input
231 Make sure to edit both `gitlab.yml` and `unicorn.rb` to match your setup.
233 ## Configure GitLab DB settings
236 sudo -u git cp config/database.yml.mysql config/database.yml
238 # Make sure to update username/password in config/database.yml.
239 # You only need to adapt the production settings (first part).
240 # If you followed the database guide then please do as follows:
241 # Change 'secure password' with the value you have given to $password
242 # You can keep the double quotes around the password
243 sudo -u git -H editor config/database.yml
248 sudo -u git cp config/database.yml.postgresql config/database.yml
251 # Make config/database.yml readable to git only
252 sudo -u git -H chmod o-rwx config/database.yml
258 # For MySQL (note, the option says "without ... postgres")
259 sudo -u git -H bundle install --deployment --without development test postgres aws
261 # Or for PostgreSQL (note, the option says "without ... mysql")
262 sudo -u git -H bundle install --deployment --without development test mysql aws
265 ## Initialize Database and Activate Advanced Features
267 sudo -u git -H bundle exec rake gitlab:setup RAILS_ENV=production
269 # Type 'yes' to create the database.
271 # When done you see 'Administrator account created:'
274 ## Install Init Script
276 Download the init script (will be /etc/init.d/gitlab):
278 sudo cp lib/support/init.d/gitlab /etc/init.d/gitlab
280 And if you are installing with a non-default folder or user copy and edit the defaults file:
282 sudo cp lib/support/init.d/gitlab.default.example /etc/default/gitlab
284 If you installed gitlab in another directory or as a user other than the default you should change these settings in /etc/default/gitlab. Do not edit /etc/init.d/gitlab as it will be changed on upgrade.
286 Make GitLab start on boot:
288 sudo update-rc.d gitlab defaults 21
292 sudo cp lib/support/logrotate/gitlab /etc/logrotate.d/gitlab
294 ## Check Application Status
296 Check if GitLab and its environment are configured correctly:
298 sudo -u git -H bundle exec rake gitlab:env:info RAILS_ENV=production
300 ## Start Your GitLab Instance
302 sudo service gitlab start
304 sudo /etc/init.d/gitlab restart
309 sudo -u git -H bundle exec rake assets:precompile RAILS_ENV=production
315 Nginx is the officially supported web server for GitLab. If you cannot or do not want to use Nginx as your web server, have a look at the
316 [GitLab recipes](https://github.com/gitlabhq/gitlab-recipes).
319 sudo apt-get install -y nginx
321 ## Site Configuration
323 Download an example site config:
325 sudo cp lib/support/nginx/gitlab /etc/nginx/sites-available/gitlab
326 sudo ln -s /etc/nginx/sites-available/gitlab /etc/nginx/sites-enabled/gitlab
328 Make sure to edit the config file to match your setup:
330 # Change YOUR_SERVER_FQDN to the fully-qualified
331 # domain name of your host serving GitLab.
332 sudo editor /etc/nginx/sites-available/gitlab
336 sudo service nginx restart
341 ## Double-check Application Status
343 To make sure you didn't miss anything run a more thorough check with:
345 sudo -u git -H bundle exec rake gitlab:check RAILS_ENV=production
347 If all items are green, then congratulations on successfully installing GitLab!
351 Visit YOUR_SERVER in your web browser for your first GitLab login.
352 The setup has created an admin account for you. You can use it to log in:
358 Please go over to your profile page and immediately change the password, so
359 nobody can access your GitLab by using this login information later on.
367 # Advanced Setup Tips
369 ## Custom Redis Connection
371 If you'd like Resque to connect to a Redis server on a non-standard port or on
372 a different host, you can configure its connection string via the
373 `config/resque.yml` file.
376 production: redis://redis.example.tld:6379
378 If you want to connect the Redis server via socket, then use the "unix:" URL scheme
379 and the path to the Redis socket file in the `config/resque.yml` file.
382 production: unix:/path/to/redis/socket
384 ## Custom SSH Connection
386 If you are running SSH on a non-standard port, you must change the gitlab user's SSH config.
388 # Add to /home/git/.ssh/config
389 host localhost # Give your setup a name (here: override localhost)
390 user git # Your remote git user
391 port 2222 # Your port number
392 hostname 127.0.0.1; # Your server name or IP
394 You also need to change the corresponding options (e.g. ssh_user, ssh_host, admin_uri) in the `config\gitlab.yml` file.
396 ## LDAP authentication
398 You can configure LDAP authentication in config/gitlab.yml. Please restart GitLab after editing this file.
400 ## Using Custom Omniauth Providers
402 GitLab uses [Omniauth](http://www.omniauth.org/) for authentication and already ships with a few providers preinstalled (e.g. LDAP, GitHub, Twitter). But sometimes that is not enough and you need to integrate with other authentication solutions. For these cases you can use the Omniauth provider.
406 These steps are fairly general and you will need to figure out the exact details from the Omniauth provider's documentation.
409 `sudo service gitlab stop`
411 * Add provider specific configuration options to your `config/gitlab.yml` (you can use the [auth providers section of the example config](https://github.com/gitlabhq/gitlabhq/blob/master/config/gitlab.yml.example) as a reference)
413 * Add the gem to your [Gemfile](https://github.com/gitlabhq/gitlabhq/blob/master/Gemfile)
414 `gem "omniauth-your-auth-provider"`
415 * If you're using MySQL, install the new Omniauth provider gem by running the following command:
416 `sudo -u git -H bundle install --without development test postgres --path vendor/bundle --no-deployment`
418 * If you're using PostgreSQL, install the new Omniauth provider gem by running the following command:
419 `sudo -u git -H bundle install --without development test mysql --path vendor/bundle --no-deployment`
421 > These are the same commands you used in the [Install Gems section](#install-gems) with `--path vendor/bundle --no-deployment` instead of `--deployment`.
424 `sudo service gitlab start`
429 If you have successfully set up a provider that is not shipped with GitLab itself, please let us know.
430 You can help others by reporting successful configurations and probably share a few insights or provide warnings for common errors or pitfalls by sharing your experience [in the public Wiki](https://github.com/gitlabhq/gitlab-public-wiki/wiki/Custom-omniauth-provider-configurations).
431 While we can't officially support every possible auth mechanism out there, we'd like to at least help those with special needs.