Pages

Wednesday, April 7, 2010

Mapbender Installation Instructions fo Ubuntu 9.10(Karmic Koala)




Mapbender (2.6+) is shipped with an install script, located at
/mapbender_2.6/resources/db/install_2.6.sh 
(currently for unix-like and windows OS). You will be asked to input several bits of information, after that the installation will proceed automatically. Some of the things mentioned on this page, still apply. Especially all the prerequisites need to be fulfilled, the webserver configuration is not done automatically [Apache configuration, php configuration]. Installation of gettext. And also a final customization of the mapbender.conf has to be done.


Contents

Prerequisites: To be able to install and operate your own copy of Mapbender you need:
  • Webserver (sudo apt-get install apache2)
  • an installation of PHP (sudo apt-get install php5 ; sudo apt-get install php5-pgsql)
    • php-mbstring
    • php-gettext
    • php-gd2
    • php5-imagick
  • Database :Postgresql (sudo apt-get install postgresql-client-8.4 ; sudo apt-get install postgresql-server-dev-8.4)
  • Installation of gettext (sudo apt-get install gettext)

Directories

  • conf - directory for configuration files.
  • http - directory for the application.
  • license - licensing information files
  • log - logfiles will be saved here.
  • resource/db - directory for the SQL-Dump to build up the Mapbender database or update the database.
  • resources/locales - directory contains translation files for different languages (Mapbender.po files, they are basically object files).

Run the install-Script

Database required by Mapbender needs administrative privileges. There is an install-script that creates the database and creates tables and content
  • install_2.6.sh.
./mapbender/resources/db/install_2.6.sh



Apache virtual directory

After installation create a virtual directory. Edit  /etc/apache2/sites-available/default:


Alias /mapbender /var/www/apache2-default/mapbender_2.4.3/http/

       
          Options MultiViews
          DirectoryIndex index.php
          Order allow,deny
          Allow from all
       


You must reload (or stop and restart) the Apache program after making changes to the configuration file to make them take effect.


sudo /etc/init.d/apache2 stop
sudo /etc/init.d/apache2 restart


If you want to enable directory browsing, e.g. for debugging purposes add Indexes to the Options line. 



Make sure you have loaded the required modules (for example, Ubuntu and Apache2)
a2enmod deflate
a2enmod headers
a2enmod setenvif (for BrowserMatch)

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 !


sudo /etc/init.d/apache2 restart


1. During the test and installation phase of Mapbender it can be helpful log php-errors. Configure the file php.ini as follows:


error_reporting  =  E_ALL & ~E_NOTICE
log_errors = On
error_log = "/var/log/php.log"
 
2. Check the following details in php.ini allow_url_fopen parameter:
extension_dir = (path to extensions-directory)
allow_url_fopen = On
 
3. Mapbender manages access authorization in SESSIONS. Check the following details:
session.save_handler = files
session.save_path = (Path to SESSIONS-Directory). (Check authorisation!)

4. Further details of session management should be customized according to server load (see 'garbage collection' in php.ini)

5. With regard to other modules the extension gd2 should be included in the installation and configuration process.
extension=gd.so              (Linux)



# sudo apt-get install lbgd2-dev 

6. 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=pgsql.so           (Linux)


7. short_open_tag
short_open_tag = OFF


8. Mapbender requires simplexml and dom for XML parsing. If not installed, this will lead to some hard-to-find bugs, because PHP fails to throw exceptions! These modules should be already installed if you are using a Linux distribution, but if you compile PHP yourself you need to include these as well

Mapbender Database

Mapbender offers an install-script (install.sh) that sets up the database for you. The following descriptions shows what is happening.
Mapbender offers an update script (update.sh) that keeps your database upoto-date

PostgreSql Database

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.

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 
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  (in subfolder utf8/)
  • ISO-8859-1
psql -f pgsql_data.sql  (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.sql (for 8.x)
psql -f pgsql_serial_set_sequences.sql  
You can install PostGIS as follows (as User postgres (su postgres)):
  • createlang plpgsql (already installed in Mapbender >= 2.5)
  • psql -f lwpostgis.sql -d (change into the PostGIS directory!)
  • psql -f spatial_ref_sys.sql -d (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

You find the Mapbender Configuration File in the directory "conf". Here you find the file mapbender.conf-dist. Rename the file to mapbender.conf.
Choose the database you want to use (from Mapbender 2.7 on only PostgreSQL is supported):
define("SYS_DBTYPE", "pgsql"); 
If you use PostgreSQL type your database information here (here is an example):
else {
   define("DBSERVER", "localhost");
   define("PORT", "5432");
   define("DB", "mapbender");
   define("OWNER", "mb");
   define("PW", "mb");
}


perpared statements (PHP > 5.1.x, PostgreSQL > 7.4) define("PREPAREDSTATEMENTS",true);
encoding - default characterset UTF-8 / ISO-8859-1
define("CHARSET","UTF-8");




Define a directory for temporary files, this directory must have write access
define("TMPDIR", "../tmp");
URL for login (test this link to know if your mapbender software is running )
define("LOGIN", "http://localhost/mapbender/frames/login.php");
 define("MAXLOGIN", 3);
 $login = LOGIN;


URL to owsproxy (no terminating slash)
define("OWSPROXY", "http://localhost/owsproxy");


type of server-connection curl, socket, http
#define("CONNECTION", "curl");
 define("CONNECTION", "http");
 #define("CONNECTION", "socket");
define("CONNECTION_PROXY", "");
 define("CONNECTION_PORT", "");
 define("CONNECTION_USER", "");
 define("CONNECTION_PASSWORD", "");


security: path to modules
define("CHECK", false);


mail settings for internal mapbender mails Mapbender can 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.


define("USE_PHP_MAILING", "false");
define("MAILHOST", "");
define("MAILUSERNAME", "");
define("MAILPASSWORD", "");
define("MAILADMIN", "");
define("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
define("USE_I18N", true);
  • Define default language
define("LANGUAGE", "de");   // "en", "de", "bg", "gr", "nl", "it", es" 
  • you can change the translations in the Mapbender.po (mapbender/resources/locale/de_DE/Mapbender.po files if you prefer a different translation.
    • You can edit the Mapbender.po files with an editor
    • or with poedit
    • after changing Mapbender.po you have to compile the Mapbender.mo files again, see gettext (make sure that gettext is installed).
Example - How to compile the Mapbender.mo files
msgfmt resources/locale/de_DE/LC_MESSAGES/Mapbender.po -o resources/locale/de_DE/LC_MESSAGES/Mapbender.mo


Change the Permission of log Folder

  • Linux : change the permission of log folder to 777 so that php script can write logs in it.
chmod -R 777 log


Check the Setup

You can check your setup with the script mapbender_setup.php. The script mapbender_setup.php moved to the directory:
/mapbender/tools/mapbender_setup.php
To access the script you have to move it temporary to /mapbender/http/tools/mapbender_setup.php. 

Please notice that for security reasons the directory tools should not be available for external users, as e.g. 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
After the installtion you can login with the user account 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.
You should not delete the user root. To administrate your applications you should create a new user f.e. admin which you use instead if user root.



If you feel any installation instruction that is causing trouble to you, then feel free to comment on this post. I will surely try to answer them when I get some time :)