Using the dev server

From OpenStreetMap Wiki
Jump to: navigation, search

The OSMF provides a development server to help contributors try things out. It's a general-purpose development machine, in contrast to the dedicated service machines such as the main database server, tile server, etc - which only the sysadmins have access to. This page gives some details to help OSM developers get up and running with a dev server account.

You don't need an account on the development server (a “dev account”) in order to help develop OpenStreetMap — all the software that powers OSM can be downloaded and run on your own machine. Having a dev account doesn't give you any special abilities when doing development. But for some tasks where your own resources aren't sufficient, you can request an account.

The Server

The Gorilla-server.svgDev/Tool Server is running Ubuntu 14.04 (Trusty Tahr). Major packages are updated from time to time. This will help ensure development packages remain compatible with recent software releases, and enable development against the newest and greatest software. On the other hand, expect packages to break!

Getting An Account

First you should read the Dev Server Account Policy, and then request an account at Dev Server Account. A sysadmin will then get in contact with you to sort things out and give you your password.

Using Your Account

SSH

You can login to the server using the SSH protocol. For Windows users, the Putty SSH Client is available at PuTTY download or if you prefer a command line ssh try the OpenSSH version from Cygwin

The server is at dev.openstreetmap.org.

The RSA host key fingerprint is 2c:a9:74:8c:46:d3:2a:50:09:86:3c:1d:f8:dd:8c:6b

Databases

Both PostgreSQL and MySQL are available - please contact the dev server administrator if you require access to either of these.

Databases can be administered using the psql and mysql command line tools or the phppgadmin and phpmyadmin web interfaces.

PostgreSQL

Postgres 8.3 and 9.1 are available, with 9.1 as the default. Command line tools such as psql can select which one to use with the "--cluster x.y/main" switch and network connections should use port 5432 for 8.3 and port 5433 for 9.1.

See pg_wrapper(1) for different ways to set your choice permanently. Also note that the contrib module isn't available for 8.3, so if you want e.g. hstore you'll need to use 9.1.

Apache User Directories

Every user on the dev server has web space at username.dev.openstreetmap.org

This is enabled by creating a directory named public_html in your home directory and placing files within.

CGI scripts can only be executed from the public_html/cgi-bin directory. Scripts will run with your own permissions, so there is no need to make files globally writeable (666).

If problems are experienced with CGI scripts, also try username.dev.openstreetmap.org/cgi-bin-d/script, to view debug output produced by the security wrapper script, which may prevent execution due to bad permissions or other security issues.

PHP scripts are currently executed from anywhere within the public_html tree, but this may change in the future.

Rails Applications

Rails applications can be run from your web space - the server is setup with passenger (aka mod_rails) and will detect correctly configured applications automatically. To run a rails application:

  • Place the application in a subdirectory under your home directory (eg: ~/myrailsapp) and configure the database. You will need to set the port number in your database.yml configuration, while commenting out the host section to enable correct authentication with postgresql.
  • Create a symbolic link under public_html that points to the public directory in the rails application (eg: ln -s ~/myrailsapp/public public_html/myrailsapp).
  • Add RailsBaseURI /path to public_html/.htaccess where path is the location of the link relative to the public_html directory.

You should then be able to visit username.dev.openstreetmap.org/path and you see your application.

To restart the application just touch tmp/restart.txt under the rails root directory.

WSGI Applications

Files in the public_html/wsgi-bin directory will be run as WSGI applications.

Flask (Python) example

To use a Flask application, first create a .wsgi file in ~/public_html/wsgi-bin/ that imports and runs your app (you may have to modify the sys.path to find your app module first). If you have an application installed at ~/my_application with the main file named site.py, you can create a file my_application.wsgi:

import sys

sys.path[0:0] = ['/path/to/your/python/app/module']  # this allows you to import your app below

from my_application import site

application = site.app

Custom trailing url

For the site to be visible at http://username.dev.openstreetmap.org/path_of_app, first add RewriteRule ^path(/?.*)$ /wsgi-bin/my_application.wsgi/$1 [P] to ~/public_html/.htaccess. Next, replace the application = site.app line from above with a class object that serves your app's pages with the correct trailing url:

class Serve(obj):
    def __init__(self, app):
        self.app = app

    def __call__(self, env, start):
        env['SCRIPT_NAME'] = '/path_of_app'
        return self.app(env, start)

application = Serve(site.app)

Pyramid (Python) example

A Pyramid application requires some additional modules to run. pyramid.paster should already be installed with Pyramid but paste may not be. Create a .wsgi file in ~/public_html/wsgi-bin/ (you may have to modify the sys.path to find your app module first). If you have the Pyramid application installed at ~/my_application, create the wsgi file like:

import sys

sys.path[0:0] = ['/path/to/your/python/app/module']  # this allows you to import your app below

from pyramid.paster import get_app


ini_path = '/home/you/my_application/production.ini'

application = get_app(ini_path, 'main')

Custom trailing url

For the site to be visible at http://username.dev.openstreetmap.org/path_of_app, first add RewriteRule ^path(/?.*)$ /wsgi-bin/my_application.wsgi/$1 [P] to ~/public_html/.htaccess. Next, append to the above .wsgi code the following:

from paste.deploy.config import PrefixMiddleware
application = PrefixMiddleware(application, ini_path, prefix='/path_of_app')

Dev Apis

For more details see http://apis.dev.openstreetmap.org/.