After installing the OpenStreetMap website, you may need to carry out some configuration steps depending on your development tasks.
- Prerequisites
- Basic Application Configuration
- Database Population
- User Management
- OAuth Setup
- Development Tools
- Production Deployment
- Troubleshooting
Before proceeding with configuration, ensure you have:
- Completed the installation steps
- Successfully started the Rails server
- Verified the website loads at http://localhost:3000
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.
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.
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-progressmay 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
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.
-
Enter the Rails console:
$ bundle exec rails console -
Find the user:
>> user = User.find_by(:display_name => "My New User Name") => #[ ... ]
-
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) => #[ ... ]
-
Exit the Rails console:
>> quit
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.
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.
-
Navigate to OAuth applications:
- Go to "OAuth 2 applications" on the My settings page
-
Register new application:
- Click on "Register new application"
- Name: "Local iD"
- Redirect URIs: "http://localhost:3000" (unless you have set up alternatives)
-
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'
-
Configure the application:
- Copy the "Client ID" from the next page
- Edit
config/settings.local.ymlin 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"To allow Notes and changeset discussions to work:
-
Register OAuth application for the website:
- Go to "OAuth 2 applications" on the My settings page
- Click on "Register new application"
- Name: "OpenStreetMap Web Site"
- Redirect URIs: "http://localhost:3000"
-
Select permissions: Check boxes for:
- ✅ 'Modify the map'
- ✅ 'Modify notes'
-
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"Rails has its own log. To inspect the log during development:
tail -f log/development.logWe 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.
Tip
If your installation stops working for some reason:
-
Update gems: Sometimes the bundle has been updated. Go to your
openstreetmap-websitedirectory 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
If you want to deploy openstreetmap-website for production use, you'll need to make several changes:
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
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.
- Generate i18n files and precompile assets:
RAILS_ENV=production bundle exec i18n export bundle exec rails assets:precompile
Important
Make sure the web server user as well as the rails user can read, write and create directories in tmp/.
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.
If you have problems with your configuration:
- Check the Rails log: Use
tail -f log/development.logto 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
If you need additional assistance:
- Mailing list: Ask on the rails-dev@openstreetmap.org mailing list
- IRC: Join the #osm-dev IRC Channel
For information on contributing changes to the code, see CONTRIBUTING.md