Installation en
From MapbenderWiki
Lesen Sie die Installationsanleitung in Deutsch
One of the mayor changes to Mapbender in version 2.2 is native PostgreSQL support. The instructions for installing Mapbender 2.1 (the previous version) can still be found here.
Contents |
Update Mapbender
- to update a running Mapbender installation have a look at Update Mapbender
Prerequisite
To be able to install and operate your own copy of Mapbender you need:
- Webserver (Apache, MS IIS)
- an installation of PHP (scripting language, version > 5.1.x)
- Database (PostgreSQL >7.3 or MySQL > 4k)
The following instructions only describe the configuration process for these packages, please follow the installation instructions for your operating system individually as the paths to files will vary on your systems.
Notice
Read about the Client capabilities to learn what is required to work with Mapbender online.
Download of the package
Download the newest Mapbender OSGeo installation package. For further details see Download Mapbender.
Extracting the package
Mapbender consists of multiple PHP-files in different directories which can be downloaded in one ZIP-file. To extract the ZIP-file you will need archiving software like unzip (commandline) or FileZip (Windows).
Directories
After downloading and unpacking Mapbender you find the following directories:
- conf - directory for the configuration file mapbender.conf
- http - directory for the application. Within this directory the modules are sorted by type in subdirectories. Some modules are pure JavaScript applications, even though they have .php as suffix.
- license - license information files
- log - logfiles will be saved here
- owsproxy
- resource - directory for the SQL-Dump to build up the Mapbender database or update the database; also contains translation files
Apache virtual directory
After installation create a virtual directory. Edit /etc/apache/httpd.conf (path varies, for apache2 /etc/apache2/sites-available/default):
Alias /mapbender /path/to/mapbender2/http/
<Directory /path/to/mapbender2/http> Options MultiViews DirectoryIndex index.php Order allow,deny Allow from all </Directory>
For example using Ubuntu edit: /etc/apache2/sites-available/default
Alias /mapbender /var/www/apache2-default/mapbender_2.4.3/http/
<Directory /var/www/apache2-default/mapbender_2.4.3/http> Options MultiViews DirectoryIndex index.php Order allow,deny Allow from all </Directory>
You must reload (or stop and restart) the Apache program after making changes to the configuration file to make them take effect. If you want to enable directory browsing, e.g. for debugging purposes add Indexes to the Options line.
Apache output compression
For optimal performance, enable output compression of your web server. Here's an instruction for Apache (see http://httpd.apache.org/docs/2.0/mod/mod_deflate.html for more details). Just append the content in bold to your Directory settings
<Directory /var/www/apache2-default/mapbender_2.4.3/http>
Options Indexes MultiViews FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
Allow from 127.0.0.0/255.0.0.0 ::1/128
# Insert filter
SetOutputFilter DEFLATE
# Netscape 4.x has some problems...
BrowserMatch ^Mozilla/4 gzip-only-text/html
# Netscape 4.06-4.08 have some more problems
BrowserMatch ^Mozilla/4\.0[678] no-gzip
# MSIE masquerades as Netscape, but it is fine
# BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
# NOTE: Due to a bug in mod_setenvif up to Apache 2.0.48
# the above regex won't work. You can use the following
# workaround to get the desired effect:
BrowserMatch \bMSI[E] !no-gzip !gzip-only-text/html
# Don't compress images
SetEnvIfNoCase Request_URI \
\.(?:gif|jpe?g|png)$ no-gzip dont-vary
# Make sure proxies don't deliver the wrong content
Header append Vary User-Agent env=!dont-vary
</Directory>
Make sure you have loaded the required modules (for example, Ubuntu and Apache2)
a2enmod deflate a2enmod headers
For Windows and Apache2, you have to activate the modules at httpd.conf.
LoadModule deflate_module modules/mod_deflate.so LoadModule headers_module modules/mod_headers.so
Mapbender will load almost twice as fast!
PHP Configuration
You might have to make some adjustments to the file php.ini. Changes in the php.ini also become operative only after restarting the Apache web server !
1. During the test and installation phase of Mapbender it can be helpful to display error messages. To see error messages displayed configure the file php.ini as follows:
error_reporting = E_ALL & ~E_NOTICE display_errors = On
2. After testing and installing, error messages should not be displayed anymore, turn this setting off again:
display_errors = Off
3. Check the following details in php.ini allow_url_fopen parameter:
extension_dir = (path to extensions-directory) allow_url_fopen = On
4. Mapbender manages access authorization in SESSIONS. Check the following details:
session.save_handler = files session.save_path = (Path to SESSIONS-Directory). (Check authorisation!)
5. Further details of session management should be customized according to server load (see 'garbage collection' in php.ini)
6. With regard to other modules the extension gd2 should be included in the installation and configuration process.
extension=php_gd2.dll (Windows) extension=gd.so (Linux)
On a Debian-System you find this lib in /usr/lib/libgd.so. If it is not installed zou can do that using the command (or use Synaptic Packet Manager or similar):
# apt.get install lbgd2-dev
7. For some Mapbender modules access to a PostgreSQL database is required. If these modules should be used, you have to check the availability of the required extension in the php.ini file:
extension=php_pgsql.dll (Windows) extension=pgsql.so (Linux)
8. from Mapbender 2.5 on we need gettext and mbstring
extension=php_gettext.dll (Windows) extension=php_mbstring.dll (Windows)
Furthermore check, whether the database information in ./conf/mapbender.conf is correct.
MySQL Settings for PHP
1. Mapbender requires read permission on a MySQL-Database. PHP normally contains this extension already (see php.ini).
Configuration: Add read permission to the file ./conf/mapbender.conf.
2. Depending on the operating system you might miss InnoDB in MySQL! Check this out prior to doing anything else if you experience trouble when deleting anything in the administration GUI.
3.Edit the file ./conf/mapbender.conf. The URL points to the login script so that it can be found from any exit point of Mapbender (sessions ran out of time, log off, no permission, etc.).
$login = 'http://SERVERNAME_OR_IP/mapbender/frames/login.php';
4. If you see a login but no connect to the database check whether the server can find the adress defined in ./conf/mapbender.conf
$server="localhost"
This will work only when Mapbender is installed on the same machine as MySQL. If not, insert the IP-adress instead of localhost.
Mapbender Database
Notice: From Version 2.2.3 (2006-03-10) Mapbender can run with encoding ISO-8859-1 or UTF-8!
To get an overview about the database structure of Mapbender have a look at database-structure. An overview on the changes in the database you find at dbchanges.
MySQL database
Create a database
- database with UTF-8 encoding
create database mapbender CHARACTER SET utf8 COLLATE utf8_general_ci ;
- select the database mapbender
use mapbender
- database with ISO-8859-1 encoding
CREATE DATABASE mapbender DEFAULT CHARACTER SET utf8 COLLATE utf8_bin;
load first the Mapbender tables and constraints and afterwards the mapbender data (/mapbender/resources/db/):
- utf8
source mysql_schema.sql (path to the mysql/mysql_schema.sql) source mysql_data.sql (path to the mysql/utf8/mysql_data.sql)
- ISO-8859-1
source mysql_schema.sql (path to the mysql/mysql_schema.sql) source mysql_data.sql (path to the mysql/iso/mysql_data.sql)
Password encryption
As of Mapbender version 2.4 the password is converted into a MD5 string by a PHP function instead of the corresponding database function. See also Lost Password.
- Migration Notice
For older installations of Mapbender that use the MySQL and password() function the mb_user_password needs to be converted to an MD5 hash.
- In the file mapbender/frames/login.php there is a variable $setEncPw.
- Set $setEncPw = true to transform the password to md5 when the user logged in with the right password.
- This helps you to transform the passwords step by step from password() to md5().
PostgreSQL database
Notice: From Version 2.2.3 (2006-03-10) Mapbender can run with encoding ISO-8859-1 or UTF-8! Please observe that you might need to install PostGIS before starting Mapbender.
The user under which you load the database must have Postgres superuser rights during inserting the psql_*.sql files below so it can temporarily disable constraint triggers during insert.
Notices for Notices Ubuntu PostgreSQL users.
You have to decide to either use UTF-8 or ISO-8859-1 character encoding.
- database with UTF-8 encoding
createdb -E UTF8 mapbender
- database with ISO-8859-1 encoding
createdb -E Latin1 mapbender
First load the empty Mapbender table definiton (schema)
psql -f pgsql_schema.sql <dbname>
Then load the data in mapbender/resources/db/postgresql/ - be sure to use the dump with the correct enconding!
- UTF-8
psql -f pgsql_data.sql <dbname> (in subfolder utf8/)
- ISO-8859-1
psql -f pgsql_data.sql <dbname> (in subfolder iso/)
At the end set the constraints and sequences. Here you have to check which PostgreSQL version you are using:
- pgsql_serial_set_sequences_7x.sql
- pgsql_serial_set_sequences.sql (for 8.x)
psql -f pgsql_serial_set_sequences.sql <dbname>
Notice: Reprojecting on the fly and transforming geometries is only possible with a PostgeSQL-DB and PostGIS extension.
You can install PostGIS as follows (as User postgres (su postgres)):
- createlang plpgsql <dbname> (already installed in Mapbender >= 2.5)
- psql -f lwpostgis.sql -d <dbname> (change into the PostGIS directory!)
- psql -f spatial_ref_sys.sql -d <dbname> (change into the PostGIS directory!)
How to load the sqls in PostgreSQL:
You find the SQL: /mapbender/resources/db/postgresql/
Notice: There is a difference between the ISO-8859-1 or UTF-8 data-files. Make sure you choose the right folder (iso or utf8)
psql -f pgsql_schema.sql mapbender psql -f pgsql_data.sql mapbender psql -f pgsql_serial_set_sequences.sql mapbender
Check the PostgreSQL log file for any errors during insert.
If you want to update from Mapbender Version 2.2.2 to Mapbender Version 2.2.3 load the sqls in the folder update
- one column var_name in table gui_element_vars has changed
- new table mb_user_wmc
- update of the mapbender guis (admin1, admin2_de, admin2_en, gui and gui1. Notice, that gui_de und gui1_de are not longer part of the standard guis. We want to solve the multilanguage problem with element vars in the following versions)
Mapbender Configuration File mapbender.conf
The Mapbender Configuration File is found in the directory "conf". Here you find the file mapbender.conf-dist. Rename the file to mapbender.conf. You won't loose your configuration at the next update of Mapbender.
Choose the database you want to use. As of Mapbender 2.2 you can choose between MySQL and PostgreSQL:
# define("SYS_DBTYPE", "mysql");
define("SYS_DBTYPE", "pgsql");
Fill in the information for the database connection.
If you use MySQL type your database information here:
if(SYS_DBTYPE=="mysql")
{
define("DBSERVER", "<HOST>");
define("PORT", "3306");
define("DB", "<database>");
define("OWNER", "<owner>");
define("PW", "<password>");
include_once("../../http/php/database-mysql.php");
# --------------------------------------------
# database with geos functions
# --------------------------------------------
define("GEOS_DBSERVER", "<HOST>");
define("GEOS_PORT", "5432");
define("GEOS_DB", "<database with geos functions>");
define("GEOS_OWNER", "<owner>");
define("GEOS_PW", "<password>");
}
If you use PostgreSQL type your database information here:
else {
define("DBSERVER", "<HOST>");
define("PORT", "5432");
define("DB", "<database>");
define("OWNER", "<owner>");
define("PW", "<password>");
include_once("../../http/php/database-pgsql.php");
}
Notice: The Mapbender Security Proxy needs another directory level in the include path. Instead use this path:
include_once("../../http/php/database-pgsql.php");
perpared statements (PHP > 5.1.x, PostgreSQL > 7.4) define("PREPAREDSTATEMENTS",false);
encoding - default characterset UTF-8 / ISO-8859-1
define("CHARSET","UTF-8");
Have a look at Apache
Define a directory for temporary files, this directory must be writable
define("TMPDIR", "../tmp");
URL to login
define("LOGIN", "http://localhost/mapbender/frames/login.php");
define("MAXLOGIN", 3);
$login = LOGIN;
URL to owsproxy (no terminating slash)
define("OWSPROXY", "http://<ip or name>/owsproxy");
type of server-connection curl, socket, http
#define("CONNECTION", "curl");
define("CONNECTION", "http");
#define("CONNECTION", "socket");
define("CONNECTION_PROXY", "<ip>");
define("CONNECTION_PORT", "<port>");
define("CONNECTION_USER", "<user>");
define("CONNECTION_PASSWORD", "<password>");
security: path to modules
define("CHECK", false);
mail settings for internal mapbender mails
From now on, mapbender is also able to communicate with its users by email. For example, when a user lost his/her password, mapbender can send an email to this person with a new password. Another example: Whenever a WMS is updated, the users using this WMS are notified by mapbender via email.
To enable mapbender to send emails, the administrator must specify a mail server (and set up a mail account on this server) in mapbender.conf. Please notice: mapbender only features SMTP mailing!
For further settings check 'class_administration.php', or please check phpmailer (http://sourceforge.net/projects/phpmailer) for more information. Currently, phpmailer 1.72 is in use.
define("USE_PHP_MAILING", "false");
define("MAILHOST", "<host>");
define("MAILUSERNAME", "<user>");
define("MAILPASSWORD", "<password>");
define("MAILADMIN", "<mailaddress of the mailadmin>");
define("MAILADMINNAME", "<mailadminname>");
$mailHost = MAILHOST;
$mailUsername = MAILUSERNAME;
$mailPassword = MAILPASSWORD;
Mapbender error logging
- Set Mapbender error logging (see possible options below)
define("LOG_LEVEL", "error"); //"off","error","warning","notice" or "all"
define("LOG_JS", "on"); // "on", "alert", "console" or "off"
Internationalisation
- Set USE_I18N to true in mapbender.conf.
define("USE_I18N", true);
- Define default language
define("LANGUAGE", "en"); // "en", "de", "bg", "gr", "nl", "it", es"
- Compile the .po files into .mo files via msgfmt, see gettext.
msgfmt resources/locale/bg_BG/LC_MESSAGES/Mapbender.po -o resources/locale/bg_BG/LC_MESSAGES/Mapbender.mo msgfmt resources/locale/de_DE/LC_MESSAGES/Mapbender.po -o resources/locale/de_DE/LC_MESSAGES/Mapbender.mo msgfmt resources/locale/fr_FR/LC_MESSAGES/Mapbender.po -o resources/locale/fr_FR/LC_MESSAGES/Mapbender.mo msgfmt resources/locale/gr_GR/LC_MESSAGES/Mapbender.po -o resources/locale/gr_GR/LC_MESSAGES/Mapbender.mo msgfmt resources/locale/it_IT/LC_MESSAGES/Mapbender.po -o resources/locale/it_IT/LC_MESSAGES/Mapbender.mo
Change the Permission of log Folder
In Linux : change the permission of log folder to 777 so that php script can write logs in it.
$ chmod -R 777 log
Checking the Setup
You can check your setup with the script mapbender_setup.php. The script mapbender_setup.php moved the directory:
/mapbender/tools/mapbender_setup.php
To run the script you have to move it to mapbender/http/tools/mapbender_setup.php verschieben, as it can't be acceded at /mapbender/tools/mapbender_setup.php.
- Notice
Please notice that for security reasons the directory tools should not be available for external users, as f.e. the mapbender_setup.php displays internal information about your system (PHP version, databasename, database user...). You can protect the directory by htaccess or just remove the tools-directory again after testing.
Run the mapbender_setup.php:
http://localhost/mapbender/tools/mapbender_setup.php
The mapbender_setup.php checks wether all configurations of the mapbender.conf are right and checks some system settings.
After the installation - first Login
For login you can use the user account with username root and the inital password root. Make sure to change this password asap in order to secure your Mapbender installation. Go to admin2_en Create and edit user to change the password.

