3 After [installing](INSTALL.md) the OpenStreetMap website, you may need to carry out some configuration steps depending on your development tasks.
7 1. [Prerequisites](#prerequisites)
8 2. [Basic Application Configuration](#basic-application-configuration)
9 3. [Database Population](#database-population)
10 4. [User Management](#user-management)
11 5. [OAuth Setup](#oauth-setup)
12 6. [Development Tools](#development-tools)
13 7. [Production Deployment](#production-deployment)
14 8. [Troubleshooting](#troubleshooting)
18 Before proceeding with configuration, ensure you have:
19 - Completed the [installation steps](INSTALL.md)
20 - Successfully started the Rails server
21 - Verified the website loads at [http://localhost:3000](http://localhost:3000)
23 ## Basic Application Configuration
25 ### Application Settings
27 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`.
29 ## Database Population
31 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.
33 ### Loading Data with Osmosis (Optional)
36 > 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](https://wiki.openstreetmap.org/wiki/Osmosis) and the [`--write-apidb`](https://wiki.openstreetmap.org/wiki/Osmosis/Detailed_Usage#--write-apidb_.28--wd.29) task.
38 After installing but before creating any users or data, import an extract with [Osmosis](https://wiki.openstreetmap.org/wiki/Osmosis) and the [`--write-apidb`](https://wiki.openstreetmap.org/wiki/Osmosis/Detailed_Usage#--write-apidb_.28--wd.29) task.
41 osmosis --read-pbf greater-london-latest.osm.pbf \
42 --write-apidb host="localhost" database="openstreetmap" \
43 user="openstreetmap" password="" validateSchemaVersion="no"
47 > - Loading an apidb database with Osmosis is about **twenty** times slower than loading the equivalent data with osm2pgsql into a rendering database
48 > - [`--log-progress`](https://wiki.openstreetmap.org/wiki/Osmosis/Detailed_Usage#--log-progress_.28--lp.29) may be desirable for status updates
49 > - To be able to edit the data you have loaded, you will need to use this [yet-to-be-written script](https://github.com/openstreetmap/openstreetmap-website/issues/282)
53 After creating a user through the web interface at [http://localhost:3000/user/new](http://localhost:3000/user/new), you may need to perform additional user management tasks.
56 > 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.
58 ### Managing Users via Rails Console
60 1. **Enter the Rails console:**
62 $ bundle exec rails console
67 >> user = User.find_by(:display_name => "My New User Name")
71 3. **Modify the user as desired:**
73 **Activate/confirm the user:**
79 **Grant moderator role:**
81 >> user.roles.create(:role => "moderator", :granter_id => user.id)
85 **Grant administrator role:**
87 >> user.roles.create(:role => "administrator", :granter_id => user.id)
91 4. **Exit the Rails console:**
98 There are two built-in applications which communicate via the API, and therefore need to be registered as OAuth 2 applications. These are:
100 * **iD** - the web-based editor
101 * **The website itself** - for the Notes functionality
103 ### Setting up OAuth for iD
105 1. **Navigate to OAuth applications:**
106 - Go to "[OAuth 2 applications](http://localhost:3000/oauth2/applications)" on the My settings page
108 2. **Register new application:**
109 - Click on "Register new application"
110 - **Name:** "Local iD"
111 - **Redirect URIs:** "http://localhost:3000" (unless you have set up alternatives)
113 3. **Select permissions:**
114 Check boxes for the following:
115 - ✅ 'Read user preferences'
116 - ✅ 'Modify user preferences'
118 - ✅ 'Read private GPS traces'
119 - ✅ 'Upload GPS traces'
122 4. **Configure the application:**
123 - Copy the "Client ID" from the next page
124 - Edit `config/settings.local.yml` in your rails tree
125 - Add the "id_application" configuration with the "Client ID" as the value
126 - Restart your rails server
129 > **Example configuration in `settings.local.yml`:**
132 > default_editor: "id"
133 > # OAuth 2 Client ID for iD
134 > id_application: "Snv…OA0"
137 ### Setting up OAuth for Notes and Changeset Discussions
139 To allow [Notes](https://wiki.openstreetmap.org/wiki/Notes) and changeset discussions to work:
141 1. **Register OAuth application for the website:**
142 - Go to "[OAuth 2 applications](http://localhost:3000/oauth2/applications)" on the My settings page
143 - Click on "Register new application"
144 - **Name:** "OpenStreetMap Web Site"
145 - **Redirect URIs:** "http://localhost:3000"
147 2. **Select permissions:**
152 3. **Configure the application:**
153 - Copy both the "Client Secret" and "Client ID"
154 - Edit `config/settings.local.yml`
155 - Add both configurations
156 - Restart your rails server
159 > **Example configuration in `settings.local.yml`:**
161 > # OAuth 2 Client ID for the web site
162 > oauth_application: "SGm8QJ6tmoPXEaUPIZzLUmm1iujltYZVWCp9hvGsqXg"
163 > # OAuth 2 Client Secret for the web site
164 > oauth_key: "eRHPm4GtEnw9ovB1Iw7EcCLGtUb66bXbAAspv3aJxlI"
169 ### Viewing Rails Logs
171 Rails has its own log. To inspect the log during development:
174 tail -f log/development.log
177 ### Maintaining Your Installation
180 > If your installation stops working for some reason:
182 > - **Update gem dependencies:** Sometimes gem dependencies change. Go to your `openstreetmap-website` directory and run:
187 > - **Run database migrations:** The OSM database schema is changed periodically. To keep up with improvements:
189 > bundle exec rails db:migrate
192 ## Production Deployment
194 If you want to deploy `openstreetmap-website` for production use, you'll need to make several changes:
196 ### Web Server Configuration
199 > Don't use `rails server` in production. Our recommended approach is to use [Phusion Passenger](https://www.phusionpassenger.com/).
201 - Instructions are available for [setting it up with most web servers](https://www.phusionpassenger.com/documentation_and_support#documentation)
202 - Passenger will, by design, use the Production environment and therefore the production database - make sure it contains the appropriate data and user accounts
204 ### Performance Optimizations
207 > **Consider using CGIMap:** The included version of the map call is quite slow and eats a lot of memory. You should consider using [CGIMap](https://github.com/zerebubuth/openstreetmap-cgimap) instead.
209 ### Asset Compilation
211 - **Generate i18n files and precompile assets:**
213 RAILS_ENV=production bundle exec i18n export
214 bundle exec rails assets:precompile
220 > Make sure the web server user as well as the rails user can read, write and create directories in `tmp/`.
222 ### Testing on the OSM Dev Server
224 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](https://wiki.openstreetmap.org/wiki/Using_the_dev_server#Rails_Applications).
228 If you have problems with your configuration:
230 - **Check the Rails log:** Use `tail -f log/development.log` to see what's happening
231 - **Verify database connectivity:** Ensure PostgreSQL is running and accessible
232 - **Check file permissions:** Make sure the Rails application can read/write necessary files
233 - **Review OAuth settings:** Ensure Client IDs and secrets are correctly configured
237 If you need additional assistance:
238 - **Mailing list:** Ask on the [rails-dev@openstreetmap.org mailing list](https://lists.openstreetmap.org/listinfo/rails-dev)
239 - **IRC:** Join the [#osm-dev IRC Channel](https://wiki.openstreetmap.org/wiki/IRC)
243 For information on contributing changes to the code, see [CONTRIBUTING.md](CONTRIBUTING.md)