These instructions are designed for setting up openstreetmap-website development enviroment. If you want to deploy the software for your own project, then see the Production Deployment Notes.
You can setup development enviroment by:
These options provide consistent development environments and may avoid installation difficulties:
- 🐳 Docker - Uses containerization. See DOCKER.md for complete instructions.
- 📦 Vagrant - Installs in a virtual machine. See VAGRANT.md for complete instructions.
Install dependencies directly on your machine (traditional approach, covered in this guide). This gives you the most control and is often preferred by experienced developers on Linux systems.
Platform Support: These instructions are based on Ubuntu 24.04 LTS, though the OSMF servers are currently running Debian 12. The instructions also work, with only minor amendments, for all other current Ubuntu releases, Fedora and macOS.
Warning
Windows Note: We don't recommend using this approach for development and deployment on Windows. Some Ruby gems may not be supported. If you are using Windows, we recommend containerized setup using Docker(preferred) or Vagrant.
Many of the dependencies are managed through the standard Ruby on Rails mechanisms - i.e. ruby gems specified in the Gemfile and installed using bundler. However, there are some packages required before you can get the various gems installed.
Minimum requirements:
- Ruby 3.2+
- PostgreSQL 13+
- Bundler (see note below about developer Ruby setup)
- JavaScript Runtime
sudo apt-get update
sudo apt-get install ruby ruby-dev ruby-bundler \
libvips-dev libxml2-dev libxslt1-dev nodejs \
build-essential git-core \
postgresql postgresql-contrib libpq-dev libsasl2-dev \
libffi-dev libgd-dev libarchive-dev libyaml-dev libbz2-dev npm
sudo npm install --global yarnTip
On Ubuntu 24.04, you may need to start PostgreSQL:
sudo systemctl start postgresql.servicesudo dnf install ruby ruby-devel rubygem-rdoc rubygem-bundler rubygems \
libxml2-devel nodejs \
gcc gcc-c++ git \
postgresql postgresql-server postgresql-contrib libpq-devel \
perl-podlators libffi-devel gd-devel libarchive-devel \
libyaml-devel bzip2-devel nodejs-yarn vips-develOn Fedora, if you didn't already have PostgreSQL installed then create a PostgreSQL instance and start the server:
sudo postgresql-setup initdb
sudo systemctl start postgresql.serviceOptionally set PostgreSQL to start on boot:
sudo systemctl enable postgresql.serviceFor macOS, you will need Xcode Command Line Tools; OS X 10.7 (Lion) or later; and some familiarity with Unix development via the Terminal.
Installing PostgreSQL:
- Install Postgres.app from https://postgresapp.com/
- Make sure that you've initialized and started Postgresql from the app (there should be a little elephant icon in your systray).
- Add PostgreSQL to your path, by editing your profile:
nano ~/.profileand adding:
export PATH=/Applications/Postgres.app/Contents/Versions/latest/bin:$PATHAfter this, you may need to start a new shell window, or source the profile again by running . ~/.profile.
Installing other dependencies:
- Install Homebrew from https://brew.sh/
- Install the latest version of Ruby:
brew install ruby - Install other dependencies:
brew install libxml2 gd yarn pngcrush optipng pngquant jhead jpegoptim gifsicle svgo advancecomp vips - Install Bundler:
gem install bundler(you might need tosudo gem install bundlerif you get an error about permissions - or see note below about developer Ruby setup)
You will need to tell bundler that libxml2 is installed in a Homebrew location. If it uses the system-installed one then you will get errors installing the libxml-ruby gem later on.
bundle config build.libxml-ruby --with-xml2-config=/usr/local/opt/libxml2/bin/xml2-configIf you want to run the tests, you need geckodriver as well:
brew install geckodriverNote
OS X does not have a /home directory by default, so if you are using the GPX functions, you will need to change the directories specified in config/application.yml.
The repository is reasonably large (~150MB) and it's unlikely that you need the full history. If you are happy to wait for it all to download, run:
git clone https://github.com/openstreetmap/openstreetmap-website.gitTip
To clone only the most recent version (~23MB), instead use a 'shallow clone':
git clone --depth=1 https://github.com/openstreetmap/openstreetmap-website.gitIf you want to add in the full history later on, perhaps to run git blame or git log, run git fetch --depth=1000000
We use Bundler to manage the rubygems required for the project.
cd openstreetmap-website
bundle installWe use Yarn to manage the Node.js modules required for the project.
bundle exec bin/yarn installNote
This is a workaround. See issues/2185 for details.
touch config/settings.local.ymlopenstreetmap-website needs to be configured with an object storage facility - for development and testing purposes you can use the example configuration:
cp config/example.storage.yml config/storage.ymlopenstreetmap-website uses three databases - one for development, one for testing, and one for production. The database-specific configuration options are stored in config/database.yml, which we need to create from the example template.
cp config/example.database.yml config/database.ymlImportant
PostgreSQL is configured to, by default, accept local connections without requiring a username or password. This is fine for development. If you wish to set up your database differently, then you should change the values found in the config/database.yml file, and amend the instructions below as appropriate.
We need to create a PostgreSQL role (i.e. user account) for your current user, and it needs to be a superuser so that we can create more databases.
sudo -u postgres -i
createuser -s <username>
exitTo create the three databases - for development, testing and production - run:
bundle exec rails db:createTo create all the tables, indexes and constraints, run:
bundle exec rails db:migrateTo ensure that everything is set up properly, you should now run:
bundle exec rails test:allThis test will take a few minutes, reporting tests run, assertions, and any errors. If you receive no errors, then your installation is successful.
Note
The unit tests may output parser errors related to "Attribute lat redefined." These can be ignored.
Rails comes with a built-in webserver, so that you can test on your own machine without needing a server. Run
bundle exec rails serverYou can now view the site in your favourite web-browser at http://localhost:3000/
Note
The OSM map tiles you see aren't created from your local database - they are just the standard map tiles.
🎉 Congratulations! You have successfully installed the OpenStreetMap website.
Next steps:
- Configuration: See CONFIGURE.md for populating the database with data, creating users, setting up OAuth, and other configuration tasks.
- Contributing: Check out CONTRIBUTING.md for coding style guidelines, testing procedures, and how to submit your contributions.
For simplicity, this document explains how to install all the website dependencies as "system" dependencies. While this is simpler, and usually faster, you might want more control over the process or the ability to install multiple different versions of software alongside each other. For many developers, rbenv is the easiest way to manage multiple different Ruby versions on the same computer - with the added advantage that the installs are all in your home directory, so you don't need administrator permissions.
If you choose to install Ruby and Bundler via rbenv, then you do not need to install the system libraries for Ruby:
- For Ubuntu, you do not need to install the following packages:
ruby ruby-dev ruby-bundler, - For Fedora, you do not need to install the following packages:
ruby ruby-devel rubygem-rdoc rubygem-bundler rubygems - For macOS, you do not need to
brew install ruby
Important
On macOS, make sure you've installed a version of Ruby using rbenv before running gem install bundler!
After installing a version of Ruby with rbenv (the latest stable version is a good place to start), you will need to make that the default. From inside the openstreetmap-website directory, run:
rbenv local $VERSIONWhere $VERSION is the version you installed. Then install bundler:
gem install bundlerYou should now be able to proceed with the rest of the installation. If you're on macOS, make sure you set up the config override for the libxml2 location after installing bundler.
Warning
Production deployment requires careful configuration and is significantly different from development setup.
If you want to deploy openstreetmap-website for production use, you'll need to make a few changes:
Important
It's not recommended to 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
The included version of the map call is quite slow and eats a lot of memory. You should consider using CGIMap instead.
- Make sure you generate the i18n files and precompile the production assets:
RAILS_ENV=production bundle exec i18n export; bundle exec rails assets:precompile - Make sure the web server user as well as the rails user can read, write and create directories in
tmp/.