Intro
ADAGUC is a WMS-based implementation, made by KNMI. Its distinct feature is to serve time-enabled raster data, from NetCDF file or OPeNDAP server, to (web) clients using the WMS protocol.
For more information on ADAGUC and its features please visit KNMI's ADAGUC pages http://dev.knmi.nl/projects/adaguc
ADAGUC consists of
- a server part
- a client/viewer part
This Tech Note describes how to setup ADAGUC on CentOS 6.4 Linux. This was performed on a local Virtual Machine as an exercise before setting up a production machine for ADAGUC.
ADAGUC Server setup
CentOS (http://www.centos.org) is based on the same sources as Red Hat Enterprise Linux.
KNMI describes installation on Red Hat Linux here: http://dev.knmi.nl/projects/adagucserver/wiki/Installation
This recipe has been followed. In short it is repeated here.
Note: unless otherwise stated, the commands are (Bash) shell commands.
Setup prerequisites
- Verify yum configuration for EPEL repository:
<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="fce3a6f1-9a11-4f75-b2d1-cff30d870a9f"><ac:plain-text-body><![CDATA[
[mylocalhost]# yum repolist
]]></ac:plain-text-body></ac:structured-macro>
- Install from EPEL repository (compiling netcdf and hdf5 is not needed in this case):
<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="739da278-9107-475f-86c4-e2efdd166c9d"><ac:plain-text-body><![CDATA[
[mylocalhost]# yum install gcc gcc-c++ mercurial libpng-devel zlib-devel libxml2-devel gd-devel netcdf-devel hdf5-devel proj-devel postgresql-devel udunits2-devel gdal-devel cairo-devel httpd postgresql-server
]]></ac:plain-text-body></ac:structured-macro>
Note: somehow this install was not completed successfully because later on the compiler complained about missing dependencies. I just re-executed this yum install (with all packges listed) and after that all worked fine.
Compile ADAGUC server
- Setup a directory structure for ADAGUC in /opt:
/opt/adagucviewer
stores ADAGUC client/viewer related files and components
/opt/services
stores ADAGUC server runtime related configuration, logs and optionally data
/opt/software
tree with ADAGUC server source files; should not be present on a production environment
CentOS has a default Apache installation and this will be used for ADAGUC. Hence ownership of all files and directories involved is assigned explicitly to OS-user apache and OS-group apache (apache:apache).
- get ADAGUC server source components from KNMI's Mercurial repository:
<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="04534265-295c-4844-9d90-d41e3b9c1453"><ac:plain-text-body><![CDATA[
[mylocalhost]# hg clone http://dev.knmi.nl/hg/adagucserver /opt/adaguc/software
]]></ac:plain-text-body></ac:structured-macro>
- start compile by executing compile.sh from /opt/adaguc/software directory. It could be necessary to set the executbale flag first:
<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="9c78de98-3bdf-461f-b200-a09b5d07d13b"><ac:plain-text-body><![CDATA[
[mylocalhost]# chmod +x compile.sh
]]></ac:plain-text-body></ac:structured-macro>
<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="dbcb95a4-43c6-448f-81a2-40701a6a81b1"><ac:plain-text-body><![CDATA[
[mylocalhost]# ./compile.sh
]]></ac:plain-text-body></ac:structured-macro>
The compilation results in a binary in the /opt/ADAGUC/software/adagucserverEC directory.
Apache setup
ADAGUC server requires a Web Sever. The ADAGUC server operates as a CGI-bin executable, triggered by the Web Server. CentOS has the Apache Web Server installed by default.
mod_php installation
The ADAGUC viewer uses some PHP scripts. For this the Apache mod_php is needed. This is not installed by default on CentOS. To install:
<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="c3aacb2b-1229-409b-bcdd-f5d6d6b88c8f"><ac:plain-text-body><![CDATA[ |
[mylocalhost]# yum install mod_php |
]]></ac:plain-text-body></ac:structured-macro> |
---|
This yum installation suffices; Apache on CentOS is set up in such a way that there is no need for explicit changes to configuration in order to enable this new module. An Apache restart is required afterwards.
Apache configuration
The Apache configuration needs some adaption. On CentOS the Apache configuration definition can be found in /etc/httpd/conf/httpd.conf. Adaptions/changes were made in the VirtualHost-section:
<VirtualHost *:80> ServerAdmin webmaster@localhost DocumentRoot /opt/adaguc/adagucviewer/ <Directory /> Options FollowSymLinks AllowOverride None </Directory> <Directory /opt/adaguc/adagucviewer/> Options Indexes FollowSymLinks MultiViews AllowOverride None Order allow,deny allow from all </Directory> ScriptAlias /cgi-bin/ /var/www/cgi-bin/ <Directory "/var/www/cgi-bin"> AllowOverride None Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch Order allow,deny Allow from all </Directory> AddHandler cgi-script .cgi ErrorLog /var/log/httpd/adaguc_error.log # Possible values include: debug, info, notice, warn, error, crit, # alert, emerg. LogLevel warn CustomLog /var/log/httpd/adaguc_access.log combined </VirtualHost>
Some explaination: ADAGUC server is a CGI-bin executable. The executable is called from a bash-script. SELinux constraints demand that CGI-scripts are executed from /var/www/cgi-bin.
For now the scripts are to be located in /opt/adaguc/services/cgi-bin; however this could be revised.
User and Group ownsership of scripts is set to apache:apache
PostgreSQL setup
ADAGUC server requires a PostgreSQL RDBMS. PostgreSQL is not installed by default on CentOS. It should have been installed by the Setup prerequisites actions. I'm not sure why I (re)installed PostgreSQL here.
- Install PostgreSQL
<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="1d11c349-2706-4916-a6df-0459e885f34b"><ac:plain-text-body><![CDATA[
[mylocalhost]# yum install postgresql.x86_64
]]></ac:plain-text-body></ac:structured-macro>
- Initialise database
(PostgreSQL data directory : /var/lib/pgsql/data)<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="52b6a350-20ef-481a-a601-73abb9f1e922"><ac:plain-text-body><![CDATA[
[mylocalhost]# service postgresql initdb
]]></ac:plain-text-body></ac:structured-macro>
- If necessary change connection constraints in /var/lib/pgsql/data/pg_hba.conf.
After making changes, perform:<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="1aec992e-d013-4598-828f-3b895f15dd31"><ac:plain-text-body><![CDATA[
[mylocalhost]# service postgresql reload
]]></ac:plain-text-body></ac:structured-macro>
- Enable PostgreSQL service startup at boot time
<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="5be9222d-ce56-4dd1-adef-87864f5231c3"><ac:plain-text-body><![CDATA[
[mylocalhost]# chkconfig postgresql on
]]></ac:plain-text-body></ac:structured-macro>
- Create ADAGUC database
Start psql client:
<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="6a71e210-bfcb-4639-a4da-6e46d1785ac2"><ac:plain-text-body><![CDATA[
[mylocalhost]# su - postgres
]]></ac:plain-text-body></ac:structured-macro>
and execute these SQL statements:<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="0998cf64-5110-475e-a6a2-662f26814151"><ac:plain-text-body><![CDATA[
[mylocalhost]# psql
]]></ac:plain-text-body></ac:structured-macro>
create user adaguc password adaguc; create database mydemo with owner=adaguc; grant connect on database mydemo; grant all on database mydemo to adaguc;
In essence the ADAGUC server is now ready to use. http://dev.knmi.nl/projects/adagucserver/wiki/Tutorials shows by examples how to setup and configure WMS with ADAGUC.
SELinux
It was the initial idea to setup ADAGUC in a directory structure under /opt. Then here you will have the WMS configurations, the related CGI-script and optionally local data files close together. By means of file system privileges it is possible to allow non-root users to add, configure ADAGUC WMS.
However SELinux does not allow for Apache to execute CGI-bin scripts that are outside of /var/www/cgi-bin. The use of symbolic links in /var/www/cgi-bin does not change this.
On top of that it is also not allow to call executables from CGI-bin scripts that are located outside of this path.
These SELinux constraints are configurable. However this has not been changes yet. A shortcut was followed in slacking the SELinux constraints from enforcing to permissive in /etc/sysconfig/selinux:
# This file controls the state of SELinux on the system. # SELINUX= can take one of these three values: # enforcing - SELinux security policy is enforced. # permissive - SELinux prints warnings instead of enforcing. # disabled - No SELinux policy is loaded. SELINUX=permissive # SELINUXTYPE= can take one of these two values: # targeted - Targeted processes are protected, # mls - Multi Level Security protection. SELINUXTYPE=targeted
So for the ADAGUC setup a neat solution should be thought of which:
- fully enables SELinux security
- allow non-root users to setup ADAGUC WMS services
This is still to do before a production environment for ADAGUC could be deployed.
ADAGUC Viewer
The ADAGUC Viewer is a mix of JavaScript and PHP coding. Setup of the viewer on a web server is done as follows:
- get ADAGUC viewer components from KNMI's Mercurial repository:
<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="8eae4924-c193-4a67-98d6-050f59164b42"><ac:plain-text-body><![CDATA[
[mylocalhost]# hg clone http://dev.knmi.nl/hg/adagucviewer /opt/adaguc
]]></ac:plain-text-body></ac:structured-macro>
- Apache's mod_php should be installed and functional. This is already described in de ADAGUC Server setup previously.
- Apache configuration
The DocumentRoot setting in de VirtualHost section in /etc/httpd/conf/httpd.conf is directed to /opt/adaguc/adagucviewer/
If this is setup then the ADAGUC viewer will load in the web browser when it is pointed to the web server.