Merge branch '2076-check-config-at-boot'
[arvados.git] / doc / install / install-api-server.html.md.liquid
1 ---
2 layout: default
3 navsection: installguide
4 title: Install the API server
5 navorder: 1
6 ...
7
8 # API server setup
9
10 ## Prerequisites:
11
12 1. A GNU/Linux (virtual) machine
13 2. A domain name for your api server
14 3. Ruby >= 2.0.0
15 4. Bundler
16
17 ## Download the source tree
18
19     git clone https://github.com/curoverse/arvados.git
20
21 See also: [Downloading the source code](https://arvados.org/projects/arvados/wiki/Download) on the Arvados wiki.
22
23 ## Configure the API server
24
25 First install the gems:
26
27     cd arvados/services/api
28     bundle install
29
30 Next, configure the database:
31
32     cp -i config/database.yml.sample config/database.yml
33
34 Edit `database.yml` to your liking and make sure the database and db user exist.
35 Then set up the database:
36  
37     RAILS_ENV=production rake db:setup
38
39 Then set up omniauth:
40
41     cp -i config/initializers/omniauth.rb.example config/initializers/omniauth.rb
42
43 Edit `config/initializers/omniauth.rb`. Choose an *APP_SECRET* and
44 *APP_ID*. Also set *CUSTOM_PROVIDER_URL*.
45
46 Make sure your Omniauth provider knows about your *APP_ID* and *APP_SECRET*
47 combination.
48
49 You also need to update `config/initializers/secret_token.rb`.
50 Generate a new secret with
51
52     rake secret
53
54 and put it in `config/initializers/secret_token.rb`:
55
56     Server::Application.config.secret_token = 'your-new-secret-here'
57
58 Edit the main configuration:
59
60     cp -i config/config.yml.example config/config.yml
61
62 First, you want to make sure that
63
64     uuid_prefix
65
66 is set to a unique 5-character alphanumeric string. An example is
67 given that generates a 5-character string based on a hash of your
68 hostname.
69
70 The `uuid_prefix` is a unique identifier for your API server. It also
71 serves as the first part of the hostname for your API server, for
72 instance
73
74     {{ site.arvados_api_host }}
75
76 For a development site, use your own domain instead of arvadosapi.com.
77
78 You will also want to change `compute_node_nameservers` to suit your
79 environment.
80
81 Consult `config.defaults.yml` for a full list of configuration
82 options. Always put your local configuration in `config.yml` instead
83 of editing `config.defaults.yml`.
84
85 ## Apache/Passenger
86
87 Set up Apache and Passenger. Point them to the services/api directory in the source tree.
88
89 To enable streaming so users can monitor crunch jobs in real time, add
90 to your Apache configuration:
91
92     PassengerBufferResponse off
93
94 ## Add an admin user
95
96 Point browser to the API endpoint. Log in with a google account.
97
98 In the rails console:
99
100     Thread.current[:user] = User.find(1)
101     Thread.current[:user].is_admin = true
102     User.find(1).update_attributes is_admin: true, is_active: true
103     User.find(1).is_admin
104
105 This should be
106
107      => true
108
109 ## Create a token
110
111 In rails console
112
113      a = ApiClient.new(owner_uuid:'0'); a.save!
114      x = ApiClientAuthorization.new(api_client_id:a.id, user_id:1); x.save; x.api_token
115