Quantcast
Channel: David Ghedini
Viewing all articles
Browse latest Browse all 21

Install MapFig Studio on CentOS

$
0
0
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.

Step 1: Install Apache


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


Step 2: Install PostgreSQL and EPEL Repositories


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


Step 3: Install PostgreSQL


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




Step 4: Create the MapFig Database


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;


Step 5: Install GDAL


Install GDAL using yum, this will pull in deps from the epel repo.
[root@demos opt]#  yum install gdal gdal-devel gdal-libs


Step 6: Add Web User


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.


Step 7: Install PHP


Install PHP via yum.
[root@demos opt]#  yum install php php-devel php-pgsql


Step 7a: Enable Short Tags


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


Restart Apache:

[root@demos opt]#  service httpd restart


Step 8: Install SuPHP


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


Step 8a: Update /etc/suphp.conf


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


to

[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
Step 8b: Get rid of DSO/mod_php:


[root@demos opt]# mv /etc/httpd/conf.d/php.conf /etc/httpd/conf.d/php.conf.disable


Step 8c: Add index and handlers:


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


Step 8d: Restart Apache


[root@demos opt]# service httpd restart


Step 9: Grant Ownership of Installation Directory to Web User


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


Step 10: Add VHOST


In your httpd.conf, uncomment the line below
NameVirtualHost *:80


At the bottom of your httpd.conf, add your vhost as shown below

<VirtualHost *:80>
    ServerAdmin me@mydomain.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>


Bounce Apache:

[root@demos opt]# service httpd restart


Step 11: Download MapFig Studio


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.3s
Unzip 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


Step 12: Install MapFig


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", "verify@yourdomain.com");
define("MAIL_PASSWORD", "YourPassword");
define("MAIL_FROM", "verify@yourdomain.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 = 'me@myemail.com';



Viewing all articles
Browse latest Browse all 21

Trending Articles