This post will cover installing MapFig Studio on CentOS 6x64
MapFig Studio is a light-weight (12 MB), Open Source PHP application for creating, editing, managing, and deploying maps across the internet
MapFig Studio is not a GIS server like GeoServer (or MapServer, etc...), nor is it intended to be.
MapFig Studio is designed to provide users of any skill level with the ability to easily create, manage, and deploy leaflet maps on websites.
In addition to standard map deployment options of HTML, iframe, and URL, MapFig Studio also comes bundled with integrated plugins for WordPress, Drupal, Joomla, and Omeka so your maps can be easily imported, managed, and displayed in your CMS.
Before deciding if you want to install your own MapFig Studio, you may want to try it first using MapFig's Free Public Cloud Studio
The basic account is free and no credit card is required. The basic account also includes the plugins for WordPress, Drupal, and Joomla and all of the features that 99% of users will want in order to add some maps to their websites.
Here is a quick example I just made for this post (click the marker):
And below, moving from left to right, we can pop-up one marker with another, use a standard pop-up (with Google Directions), as well as modal pop-up. We've also switched our base layer to from MapQuest to Stamen Toner. You can use any map provider you wish to as well as create custom groups (the drop-down at top right of map)
OK, I'm a sysadmin, not a designer, I'm sure you can make something nicer.
I will be installing MapFig Studio on a VPS with 256 MB of RAM, but you can easily install MapFig Studio on a shared hosting or cPanel account.
MapFig Studio's resource requirements are similar to PHP application such as WordPress or Drupal.
We designed the application using SuPHP so MapFig Studio can be run on inexpensive shared hosting accounts as well as on dedicated environments.
If you prefer mod_ruid2 this can be used in place and you can skip the SuPHP section.
The only requirements for MapFig Studio are PHP 5.x, SuPHP, PostgreSQL 9, and GDAL.
MapFig does offer managed hosting, but you can get all of the same features and functionality hosting it yourself or with any provider.
In this tutorial I am going to use the CentOS 6.5 repo (and because I happen to like CentOS 6). For production, you should consider CentOS 7, which provides PHP 5.4, or installing/compiling PHP>=5.4 on your distribution.
The same procedure below can be followed on any RHEL/CentOS distribution.
Install Apache and start it. If you elected to use Webmin, you can do this via Servers > Apache Web Server
[root@demos opt]# yum install httpd httpd-tools [root@demos opt]# service httpd start
Unless you want to build from source, the PostgreSQL and EPEL repositories will be needed for PostgreSQL as well as GDAL.
[root@demos opt]# wget http://yum.pgrpms.org/9.4/redhat/rhel-6-x86_64/pgdg-centos94-9.4-1.noarch.rpm [root@demos opt]# rpm -i pgdg-centos94-9.4-1.noarch.rpm [root@demos opt]# wget https://dl.fedoraproject.org/pub/epel/epel-release-latest-6.noarch.rpm [root@demos opt]# rpm -i epel-release-latest-6.noarch.rpm
A full guide to installing and configuring PostgreSQL on CentOS is available here
[root@demos opt]# yum install postgresql94 postgresql94-devel postgresql94-libs postgresql94-server postgresql94-contrib
It's also a good idea to create some symlinks to the PostgreSQL pre-9.x locations as some libs still seem to look for it there:
[root@demos opt]# ln -s /usr/pgsql-9.4/bin/pg_config /usr/bin [root@demos opt]# ln -s /var/lib/pgsql/9.4/data /var/lib/pgsql [root@demos opt]# ln -s /var/lib/pgsql/9.4/backups /var/lib/pgsql
Create the MapFig database and user who will own the database:
postgres=# create user mapfig with password 'secret'; CREATE ROLE postgres=# create database mapfig owner=mapfig;
Install GDAL using yum, this will pull in deps from the epel repo.
[root@demos opt]# yum install gdal gdal-devel gdal-libs
Add the web user (I'll call mine 'mapfig') who will own installation:
[root@demos opt]# useradd mapfig [root@demos opt]# passwd mapfig Changing password for user mapfig. New password: Retype new password: passwd: all authentication tokens updated successfully.
Install PHP via yum.
[root@demos opt]# yum install php php-devel php-pgsql
Edit your php.ini file under /etc/php.ini to enable short tags (there are some short tags in the current download, we will remove these and update when completed.)
[root@demos opt]# vi /etc/php.ini short_open_tag = On
[root@demos opt]# service httpd restart
Install SuPHP using the centoshelp.org repo (or any other method you prefer):
If you are using mod_ruid2, you can skip these sections.
[root@demos opt]# rpm -ivh http://rpm.centoshelp.org/el6/mod_suphp/mod_suphp-0.7.1-1.el6.cosh.x86_64.rpm
In /etc/suphp.conf, change:
[handlers] ;Handler for php-scripts x-httpd-php=php:/usr/bin/php-cgi ;Handler for CGI-scripts x-suphp-cgi=execute:!self
[handlers] [handlers] ;Handler for php-scripts x-httpd-php="php:/usr/bin/php-cgi" ;Handler for CGI-scripts x-suphp-cgi="execute:!self"
:+1: Thank you to Kieran O’Shea
[root@demos opt]# mv /etc/httpd/conf.d/php.conf /etc/httpd/conf.d/php.conf.disable
Add the following lines to your httpd.conf and bounce Apache:
DirectoryIndex index.html index.html.var index.php AddType x-httpd-php .php .php3 .php4 .php5
[root@demos opt]# service httpd restart
To keep things simple, I am going to be installing MapFig Studio into /var/www/html
Chown the installation directory (/var/www/html) to the web user you created in step 6 above.
[root@demos opt]# chown -Rf mapfig:mapfig /var/www/html
In your httpd.conf, uncomment the line below
At the bottom of your httpd.conf, add your vhost as shown below
<VirtualHost *:80> ServerAdmin email@example.com DocumentRoot /var/www/html/ ServerName maps.mydomain.com ErrorLog logs/ maps.mydomain.com-error_log CustomLog logs/ maps.mydomain.com-access_log common
AccessFileName .htaccess ### suPHP ### suPHP_Engine on suPHP_UserGroup mapfig mapfig suPHP_AddHandler x-httpd-php AddHandler x-httpd-php .php .php3 .php4 .php5 <Directory /var/www/html/> Options +Indexes FollowSymlinks AllowOverride All Order allow,deny Allow from all </Directory> </VirtualHost>
[root@demos opt]# service httpd restart
Start an SSH session and su to the web user your created and use wget to pull down MapFig Studio:
[root@demos opt]# su - mapfig [root@demos opt]$ cd /var/www/html [mapfig@demos html]$ wget http://cdn.mapfig.com/MapFig-Studio/MapFig-Studio.zip Saving to: MapFig-Studio.zip 100%[======================================>] 12,754,146 3.79M/s in 3.3sUnzip MapFig Studio and move contents into our doc root at /var/www/html
[mapfig@demos html]$ unzip -q MapFig-Studio.zip [mapfig@demos html]$ mv /var/www/html/MapFigStudio/* /var/www/html
Before beginning the installation process, you must manually update the mail.config.php file located in the includes directory.
If you took my advice above and installed Webmin, you will have a working Postfix mail server.
Change the MAIL_HOST, MAIL_USERNAME, and MAIL_PASSWORD below to your own mail server.
NOTE: this does not to be an account on the local mail server, it can be an email account hosted anywhere.
[mapfig@demos html]$ cd includes [mapfig@demos html]$ vi mail.config.php
<?PHP define("MAIL_SMTPAUTH", true); define("MAIL_SMTPSECURE", "tls"); define("MAIL_HOST", "mail.yourdomain.com"); define("MAIL_PORT", 587); define("MAIL_USERNAME", "firstname.lastname@example.org"); define("MAIL_PASSWORD", "YourPassword"); define("MAIL_FROM", "email@example.com"); define("MAIL_FROM_NAME", "Verify Mapfig"); define("WELCOME_EMAIL_SUBJECT", "Mapfig Studio Registration Confirmation!"); define("MAIL_TEMPLATE_DIRECTORY", dirname(__FILE__)."/../templates/emails/"); ?>
Navigate to your vhost name (or IP) and begin installing:
Install Screen 1: Have your DB information and click "Let's Go"
Install Screen 2: Enter the DB user name and password from "Step 4: Create the MapFig Database" above.
Install Screen 3: Click "Run the Install"
Install Screen 4: Enter your information in the fields provided (these can be changed later)
Install Screen 6: Activate Email is sent to the address you entered in Screen 4 above.
Install Screen 7: Click on the "Verify Account" button to verify account and you will then be able to log into MapFig Studio.
If, for any reason you forgot to do this, you will get "Email not verified" when attempting log in for the first time.
To fix this, connect to your mapfig database as postgres (or as user you created) and update the activationkey field of the users table to '' as shown below, substituting your own email for the one below:
postgres=# \c mapfig You are now connected to database "mapfig" as user "postgres". mapfig=# update users set activationkey = '' where email = 'firstname.lastname@example.org';
PostgreSQL 9.2 has been released (9.2.0):
Update (September 16, 2012): Just update my blog to 9.2 using pg_upgrade.
So far, so good.
Refractions released PostGIS 2.0 in April.
You can see details here: http://postgis.refractions.net/news/20120403/
Devrim Gunduz has made the PostGIS 2.0 packages available
You can download the repo rpms here
If you are using the pg repos, installation of PostGIS has gone from trivial to, well... whatever is less than trivial.
Of course, you will need to have PostgreSQL installed.
On centOS, the required GDAL is not available via CentOS repo, so you can use EPEL.
You can view the EPEL repos here
Download and install the repo:
wget http://ftp.linux.org.tr/epel/6/i386/epel-release-6-6.noarch.rpm rpm -i epel-release-6-6.noarch.rpm
Issue yum list gdal* to view GDAL packages and install
yum list gdal* yum install gdal gdal-devel [gdal-java gdal-perl gdal-python]
With the PostgreSQL repo installed, you can now install either PostGIS 1.5 or 2.0
For PostGIS 2.0, the name is 'postgis2_91'
yum list postgis* yum install postgis2_91 postgis2_91-devel [postgis2_91-docs postgis2_91-utils]
With PostGIS 2.0, you can install using CREATE EXTENSION
Simply connect to the target database as postgres and issue 'CREATE EXTENSION postgis_topology' and 'CREATE EXTENSION postgis_topology'
Database Name: mydb
Database Owner: myuser
-bash-4.1$ psql Password: psql (9.1.3) Type "help" for help. postgres=# \c mydb postgres You are now connected to database "mydb" as user "postgres". mydb=# CREATE EXTENSION postgis; CREATE EXTENSION mydb=# CREATE EXTENSION postgis_topology; CREATE EXTENSION
You can now change ownership of the spatial_ref_sys table to the DB owner (if applicable):
mydb=# \dt List of relations Schema | Name | Type | Owner --------+-----------------+-------+---------- public | spatial_ref_sys | table | postgres (1 row) mydb=# alter table spatial_ref_sys owner to myuser; ALTER TABLE
Check if ownership is updated:
mydb=# \dt List of relations Schema | Name | Type | Owner --------+-----------------+-------+---------- public | spatial_ref_sys | table | myuser (1 row) mydb=#