Skip to content

Latest commit

 

History

History
267 lines (194 loc) · 9.48 KB

File metadata and controls

267 lines (194 loc) · 9.48 KB

Configuration

After installing the OpenStreetMap website, you may need to carry out some configuration steps depending on your development tasks.

Table of Contents

  1. Prerequisites
  2. Basic Application Configuration
  3. Database Population
  4. User Management
  5. OAuth Setup
  6. Development Tools
  7. Production Deployment
  8. Troubleshooting

Prerequisites

Before proceeding with configuration, ensure you have:

Basic Application Configuration

Application Settings

Many settings are available in config/settings.yml. You can customize your installation of openstreetmap-website by overriding these values using config/settings.local.yml.

Database Population

Your installation comes with no geographic data loaded. Before adding any data using one of the editors (iD, JOSM etc), you can optionally prepopulate the database using an OSM extract.

Loading Data with Osmosis (Optional)

Note

This step is entirely optional. You can start using the editors immediately to create new data, or if you prefer to work with existing data, you can import an extract with Osmosis and the --write-apidb task.

To import an extract, run:

osmosis --read-pbf greater-london-latest.osm.pbf \
  --write-apidb host="localhost" database="openstreetmap" \
  user="openstreetmap" password="" validateSchemaVersion="no"

Important

  • Loading an apidb database with Osmosis is about twenty times slower than loading the equivalent data with osm2pgsql into a rendering database
  • --log-progress may be desirable for status updates
  • To be able to edit the data you have loaded, you will need to use this yet-to-be-written script

User Management

After creating a user through the web interface at http://localhost:3000/user/new, you may need to perform additional user management tasks.

Tip

If you don't want to set up your development box to send emails, you can manually confirm users and grant permissions through the Rails console.

Managing Users via Rails Console

  1. Enter the Rails console:

    $ bundle exec rails console
  2. Find the user:

    >> user = User.find_by(:display_name => "My New User Name")
    => #[ ... ]
  3. Modify the user as desired:

    Activate/confirm the user:

    >> user.activate!
    => true

    Grant moderator role:

    >> user.roles.create(:role => "moderator", :granter_id => user.id)
    => #[ ... ]

    Grant administrator role:

    >> user.roles.create(:role => "administrator", :granter_id => user.id)
    => #[ ... ]
  4. Exit the Rails console:

    >> quit

OAuth Setup

There are two built-in applications which communicate via the API, and therefore need to be registered as OAuth 2 applications. These are:

  • iD - the web-based editor
  • The website itself - for the Notes functionality

You need to register these applications with one of the users you created. After that iD and Notes functionality becomes available to every user of the website.

Automated OAuth Setup (Recommended)

Tip

You can register both applications automatically by running the following rake task:

bundle exec rails oauth:register_apps["My New User Name"]

This task registers the applications with the "My New User Name" user as the owner and saves their keys to config/settings.local.yml. When logged in, the owner should be able to see the apps on the OAuth 2 applications page.

Alternatively you can register the applications manually, as described in the next section.

Setting up OAuth for iD

  1. Navigate to OAuth applications:

  2. Register new application:

    • Click on "Register new application"
    • Name: "Local iD"
    • Redirect URIs: "http://localhost:3000" (unless you have set up alternatives)
  3. Select permissions: Check boxes for the following:

    • ✅ 'Read user preferences'
    • ✅ 'Modify user preferences'
    • ✅ 'Modify the map'
    • ✅ 'Read private GPS traces'
    • ✅ 'Upload GPS traces'
    • ✅ 'Modify notes'
  4. Configure the application:

    • Copy the "Client ID" from the next page
    • Edit config/settings.local.yml in your rails tree
    • Add the "id_application" configuration with the "Client ID" as the value
    • Restart your rails server

Tip

Example configuration in settings.local.yml:

# Default editor
default_editor: "id"
# OAuth 2 Client ID for iD
id_application: "Snv…OA0"

Setting up OAuth for Notes and Changeset Discussions

To allow Notes and changeset discussions to work:

  1. Register OAuth application for the website:

  2. Select permissions: Check boxes for:

    • ✅ 'Modify the map'
    • ✅ 'Modify notes'
  3. Configure the application:

    • Copy both the "Client Secret" and "Client ID"
    • Edit config/settings.local.yml
    • Add both configurations
    • Restart your rails server

Tip

Example configuration in settings.local.yml:

# OAuth 2 Client ID for the web site
oauth_application: "SGm8QJ6tmoPXEaUPIZzLUmm1iujltYZVWCp9hvGsqXg"
# OAuth 2 Client Secret for the web site
oauth_key: "eRHPm4GtEnw9ovB1Iw7EcCLGtUb66bXbAAspv3aJxlI"

Development Tools

Viewing Rails Logs

Rails has its own log. To inspect the log during development:

tail -f log/development.log

Email Previews

We use ActionMailer Previews to generate previews of the emails sent by the application. Visit http://localhost:3000/rails/mailers to see the list of available previews.

Maintaining Your Installation

Tip

If your installation stops working for some reason:

  • Update gems: Sometimes the bundle has been updated. Go to your openstreetmap-website directory and run:

    bundle install
  • Update Node.js modules: If Node.js modules have been updated, run:

    bundle exec bin/yarn install
  • Run database migrations: The OSM database schema is changed periodically. To keep up with improvements:

    bundle exec rails db:migrate

Production Deployment

If you want to deploy openstreetmap-website for production use, you'll need to make several changes:

Web Server Configuration

Warning

Don't use rails server in production. Our recommended approach is to use Phusion Passenger.

  • Instructions are available for setting it up with most web servers
  • Passenger will, by design, use the Production environment and therefore the production database - make sure it contains the appropriate data and user accounts

Performance Optimizations

Tip

Consider using CGIMap: The included version of the map call is quite slow and eats a lot of memory. You should consider using CGIMap instead.

Asset Compilation

  • Generate i18n files and precompile assets:
    RAILS_ENV=production bundle exec i18n export
    bundle exec rails assets:precompile

File Permissions

Important

Make sure the web server user as well as the rails user can read, write and create directories in tmp/.

Testing on the OSM Dev Server

For example, after developing a patch for openstreetmap-website, you might want to demonstrate it to others or ask for comments and testing. To do this you can set up an instance of openstreetmap-website on the dev server in your user directory.

Troubleshooting

If you have problems with your configuration:

  • Check the Rails log: Use tail -f log/development.log to see what's happening
  • Verify database connectivity: Ensure PostgreSQL is running and accessible
  • Check file permissions: Make sure the Rails application can read/write necessary files
  • Review OAuth settings: Ensure Client IDs and secrets are correctly configured

Getting Help

If you need additional assistance:

Contributing

For information on contributing changes to the code, see CONTRIBUTING.md