Project

General

Profile

Support #735

Updated by Daniel Curtis almost 9 years ago

This is a guide on installing a local OpenStreetMap server on FreeBSD 9. 

 h2. Prepare the Environment 

 * Make sure the system is up to date: 
 <pre> 
 pkg update && pkg upgrade 
 </pre> 

 * Install a few dependencies: 
 <pre> 
 pkg install git ruby ruby21-gems rubygem-bundler rubygem-rake ImageMagick-nox11 python2 gmake 
 </pre> 

 * Create an osm user 
 <pre> 
 pw add user -n osm -m -s /bin/sh -c "OpenStreetMap" 
 </pre>  

 h2. Install PostgreSQL 9.4 

 * Install PostgreSQL: 
 <pre> 
 pkg install postgresql94-{server,client,contrib} 
 </pre> 

 * Enable PostgreSQL at boot: 
 <pre> 
 echo 'postgresql_enable="YES"' >> /etc/rc.conf 
 echo 'postgresql_flags="-w -s -m fast"' >> /etc/rc.conf 
 echo 'postgresql_initdb_flags="--encoding=utf-8 --lc-collate=C"' >> /etc/rc.conf 
 </pre> 

 * Edit the @login.conf@ file: 
 <pre> 
 vi /usr/local/etc/login.conf 
 </pre> 
 #* And add the following to the end of the file: 
 <pre> 
 postgres:\ 
         :lang=en_US.UTF-8:\ 
         :setenv=LC_COLLATE=C:\ 
         :tc=default: 
 </pre> 

 * Then run to apply the changes: 
 <pre> 
 cap_mkdb login.conf 
 </pre> 

 * Initialize the database: 
 <pre> 
 service postgresql initdb 
 </pre> 

 * Start PostgreSQL: 
 <pre> 
 service postgresql start 
 </pre> 

 * Edit the postgres config file: 
 <pre> 
 vi /usr/local/pgsql/data/postgresql.conf 
 </pre> 
 #* And modify the following: 
 <pre> 
 listen_addresses = '*' 
 </pre> 

 * Edit the pg_hba config file: 
 <pre> 
 vi /usr/local/etc/pgsql/data/pg_hba.conf 
 </pre> 
 #* And modify the following: 
 <pre> 
 # TYPE    DATABASE      USER          CIDR-ADDRESS            METHOD only 

 # Local connections 
 local     all           all                                 trust 

 # IPv4 local connections: 
 host      all           all           127.0.0.1/32            trust 

 # IPv6 local connections: 
 host      all           all           ::1/128                 trust 

 # IPv4 connections: 
 host      all           all           192.168.10.0/24         md5 
 </pre> 

 * Restart postgresql: 
 <pre> 
 service postgresql restart 
 </pre> 

 h2. Create a new user and database 

 * Switch to the pgsql user and enter into the psql prompt: 
 <pre> 
 su pgsql 
 psql -d template1 
 </pre> 
 #* Create the *osmuser* user and *osmdb* database: 
 <pre> 
 CREATE USER osmuser WITH PASSWORD 'SuperSecretPassword'; 

 ALTER USER osmuser CREATEDB; 

 CREATE DATABASE openstreemap OWNER osmuser ENCODING 'UTF8'; 
 CREATE DATABASE osm OWNER osmuser ENCODING 'UTF8'; 
 CREATE DATABASE osm_test OWNER osmuser ENCODING 'UTF8'; 

 GRANT ALL PRIVILEGES ON DATABASE "osmdb" to osmuser; 
 </pre> 
 #* Exit from the postgres user 
 <pre> 
 \q 
 exit 
 </pre> 

 * Import the btree_gist.sql file: 
 <pre> 
 psql -d openstreetmap < /usr/local/share/postgresql/extension/btree_gist--1.0.sql 
 </pre> 

 h2. Install OpenStreetMap 

 * Switch to the osm user: 
 <pre> 
 su - osm 
 </pre> 

 * Get the current OpenStreetMap code: 
 <pre> 
 git clone git://git.openstreetmap.org/rails.git 
 </pre> 

 * Copy and edit the configuration files 
 <pre> 
 cd rails 
 cp config/example.application.yml config/application.yml 
 cp config/example.database.yml config/database.yml 
 </pre>  

 * Install the gems: 
 <pre> 
 bundle install --path vendor/bundle 
 </pre> 

 h2. Resources 

 * http://www.openstreetmap.org/ 
 * http://wiki.openstreetmap.org/wiki/User:S-s-s_wiki/Creating_a_local_OSM_server_under_FreeBSD 
 * https://git.openstreetmap.org/rails.git/

Back