--- layout: default navsection: installguide title: Install the API server ... h2. Prerequisites: # A GNU/Linux (virtual) machine # A domain name for your api server # Ruby >= 2.0.0 # Bundler: @gem install bundler@ # Curl libraries: @sudo apt-get install libcurl3 libcurl3-gnutls libcurl4-openssl-dev@ h2. Download the source tree
~$ git clone https://github.com/curoverse/arvados.git
See also: "Downloading the source code:https://arvados.org/projects/arvados/wiki/Download on the Arvados wiki. h2. Install gem dependencies
~$ cd arvados/services/api
~/arvados/services/api$ bundle install
h2. Configure the API server Configure the database:
~/arvados/services/api$ cp -i config/database.yml.sample config/database.yml
By default, the development database will use the sqlite3 driver, so no configuration is necessary. If you wish to use mysql or postgres, edit @config/database.yml@ to your liking and make sure the database and db user exist. Then initialize the database:
~/arvados/services/api$ RAILS_ENV=development bundle exec rake db:setup
Then set up omniauth:
~/arvados/services/api$ cp -i config/initializers/omniauth.rb.example config/initializers/omniauth.rb
Edit @config/initializers/omniauth.rb@. Set @APP_SECRET@ to the value of @app_secret@ from "installing the single sign on server":install-sso.html . Next, edit the main configuration:
~/arvados/services/api$ cp -i config/application.yml.example config/application.yml
First, choose a unique 5-character alphanumeric string to use as your @uuid_prefix@. An example is given that generates a 5-character string based on a hash of your hostname. The `uuid_prefix` is a unique identifier for your API server. It also serves as the first part of the hostname for your API server. For a development site, use your own domain instead of arvadosapi.com. You also need to install a secret_token for signing cookies. Generate a new secret:
~/arvados/services/api$ rake secret
zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz
Put it in @config/application.yml@ in the production or common section:
    secret_token: zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz
You will also want to change @compute_node_nameservers@ to suit your environment. Consult @application.default.yml@ for a full list of configuration options. Always put your local configuration in @application.yml@ instead of editing @application.default.yml@. You can now run the development server:
~/arvados/services/api$ rails server
h3. Apache/Passenger (optional) You can use "Passenger":https://www.phusionpassenger.com/ for deployment. Point it to the services/api directory in the source tree. To enable streaming so users can monitor crunch jobs in real time, add to your Passenger configuration in Apache:
PassengerBufferResponse off
h2. Add an admin user Point browser to the API endpoint. Log in with a google account. In the rails console:
~/arvados/services/api$ rails console
irb(main):001:0> Thread.current[:user] = User.find(1)
irb(main):002:0> Thread.current[:user].is_admin = true
irb(main):003:0> User.find(1).update_attributes is_admin: true, is_active: true
irb(main):004:0> User.find(1).is_admin
=> true
h2. Create an API token In rails console:
~/arvados/services/api$ rails console
irb(main):001:0> a = ApiClient.new(owner_uuid:'0')
irb(main):002:0> a.save!
irb(main):003:0> x = ApiClientAuthorization.new(api_client_id:a.id, user_id:1)
irb(main):004:0> x.save
irb(main):005:0> x.api_token