Installation of the WPS in a Linux environment¶
This tutorial explains how to set up the WPS application on Tomcat in a Linux environment, and how to setup multiple Tomcat instances since it may be to prefer when you have several web applications. Moreover, Apache will be connected to Tomcat with JK Connectors so the users may access the WPS application through Apache (port 80) instead of Tomcat (8080).
For more information, please read the following manuals and guides
Tomcat 5.5
Tomcat 6
Apache
Apache Tomcat Connectors
This tutorial is based on following guides
Connecting Apache's Web Server to Multiple Instances of Tomcat
Apache 2.2 and Tomcat 6 Integration
How to install many instances of Tomcat 6 on Ubuntu server 8.0.4
- Multiple Tomcat instances
- WPS installation
- Apache and JK connectors
Multiple Tomcat instances¶
Install Java 6 (Sun or OpenJDK).
In this case, Java 6 Sun will be installed.
Sudo apt-get install sun-java6-jdk
Make Java 6 as default
Sudo update-java-alternatives –s java-6-sun
Install tomcat 5.5 or 6.
Here, Tomcat 5.5 is installed
Sudo apt-get install tomcat5.5
Configure tomcat default settings
Sudo vi /etc/default/tomcat5.5
and change:
JAVA_HOME=/usr/lib/jvm/java-6-sun (or where your java 6 installation is stored)
TOMCAT5_SECURITY=no
Start setting up multiple Tomcat instances
Create folders where the instances should be located. Two instances are created in this case, but more, or less, can of course be created. Here, the instances’ folders are located within the tomcat5.5 directory, but other places may also be used.
Sudo mkdir /usr/share/tomcat5.5/inst/wpsinst
Sudo mkdir /usr/share/tomcat5.5/inst/inst2
Sudo mkdir /usr/share/tomcat5.5/inst/wpsinst/conf
Sudo mkdir /usr/share/tomcat5.5/inst/inst2/conf
Sudo mkdir /usr/share/tomcat5.5/inst/wpsinst/webapps
Sudo mkdir /usr/share/tomcat5.5/inst/inst2/webapps
Sudo mkdir /usr/share/tomcat5.5/inst/wpsinst/work
Sudo mkdir /usr/share/tomcat5.5/inst/inst2/work
Sudo mkdir /usr/share/tomcat5.5/inst/wpsinst/data
Sudo mkdir /usr/share/tomcat5.5/inst/inst2/data
Sudo mkdir /usr/share/tomcat5.5/inst/wpsinst/logs
Sudo mkdir /usr/share/tomcat5.5/inst/inst2/logs
Sudo mkdir /usr/share/tomcat5.5/inst/wpsinst/temp
Sudo mkdir /usr/share/tomcat5.5/inst/inst2/temp
Go to your Tomcat directory (/usr/share/tomcat5.5) and copy the following configuration files
Sudo cp conf/server.xml /usr/share/tomcat5.5/inst/wpsinst/conf
Sudo cp conf/server.xml /usr/share/tomcat5.5/inst/inst2/conf
Sudo cp conf/web.xml /usr/share/tomcat5.5/inst/wpsinst/conf
Sudo cp conf/web.xml /usr/share/tomcat5.5/inst/inst2/conf
Sudo cp conf/tomcat-users.xml /usr/share/tomcat5.5/inst/wpsinst/conf
Sudo cp conf/web.xml /usr/share/tomcat5.5/inst/inst2/conf
Sudo cp –R conf/Catalina /usr/share/tomcat5.5/inst/wpsinst/conf
Sudo cp –R conf/Catalina /usr/share/tomcat5.5/inst/inst2/conf
Configure the ports for the Tomcat instances
Find the ports for shutdown, HTTP and JK connectors and change them to the ports described below. The original ports should be 8001 or 8005, 8080 and 8009. If you will not use your original Tomcat instance, you can leave the ports unchanged for one of the instances.
Sudo vi /usr/share/tomcat5.5/inst/wpsinst/conf/server.xml
#shutdown port
‹Server port="8105" shutdown=" …›
#port listens to HTTP
‹Connector … port=8180›
#port listens to JK
‹Connector … port=8109›
Sudo vi /usr/share/tomcat5.5/inst/inst2/conf/server.xml>
#shutdown port
‹Server port="8205" shutdown=" …›'
#port listens to HTTP
‹Connector … port=8280›
#port listens to JK
‹Connector … port=8209›
Setup startups for the server instances
We will use CATALINA_BASE as the directory for the instance and the original Tomcat 5.5 directory as CATALINA_HOME. This means that most of the basic Tomcat configurations are shared by the instances. The instances will also share startup.sh and shutdown.sh. JAVA_HOME is where your java installation directory is located and JAVA_OPTS configure e.g. the memory settings for Java.
Sudo vi /etc/init.d/wpsinst
Fill in the information below. For other instances, for example inst2, just replace “wpsinst” with “inst2” or some preferred name.
export JAVA_HOME=/usr/lib/jvm/java-6-sun
export CATALINA_BASE=/usr/share/tomcat5.5/inst/wpsinst
export CATALINA_HOME=/usr/share/tomcat5.5
export JAVA_OPTS="-Xmx2048M -Xms64M -Dfile.encode=UTF-8 -XX:MaxPermSize=256M"
case $1 in
start)
sh /usr/share/tomcat5.5/bin/startup.sh
;;
stop)
sh /usr/share/tomcat5.5/bin/shutdown.sh
;;
restart)
sh /usr/share/tomcat5.5/bin/shutdown.sh
sh /usr/share/tomcat5.5/bin/startup.sh
;;
esac
exit 0
Enable possible to execute the scripts
Sudo chmod 755 /etc/init.d/wpsinst
Sudo chmod 755 /etc/init.d/inst2
Setup relative paths for the instances
Sudo ln -s /etc/init.d/wpsinst /etc/rc1.d/K99wpsinst
Sudo ln -s /etc/init.d/wpsinst /etc/rc2.d/S99wpsinst
Sudo ln -s /etc/init.d/inst2 /etc/rc1.d/K99inst2
Sudo ln -s /etc/init.d/inst2 /etc/rc2.d/S99inst2
Test to start the servers
If errors occur, check catalina.out in the log directory of your Tomcat instance.
Sudo /etc/init.d/wpsinst start
Sudo /etc/init.d/inst2 start
WPS installation¶
Unpack WPS-Webapp-0.0.1.war
For example, to /usr/local/
sudo unzip WPS-Webapp-0.0.1.war -d /usr/local/WPS-Webapp-0.0.1
Make tomcat5.5 owner of the folder
Sudo chown –R tomcat5.5 /usr/local/WPS-Webapp-0.0.1
Create wps.xml in the instances' localhost
mkdir /usr/share/tomcat5.5/inst/wpsinst/conf/Catalina/localhost/wps.xml
Fill it with:
‹?xml version='1.0' encoding='utf-8'?›
‹Context path="/WPS-Webapp-0.0.1" privileged="true" docBase="/usr/local/WPS-Webapp-0.0.1" debug="1"/›
Edit wps_config.xml
Sudo vi /usr/local/WPS-Webapp-0.0.1/config/wps_config.xml
Scroll down to the end and check that your Server hostport and hostname is correct. Since the Tomcat instance for the WPS earlier has been configured to port 8180, change server hostport to this. For the hostname, change to the name of your host. In this example, it is the localhost.
‹Server hostport="8180" includeDataInputsInResponse="false" hostname="localhost" computationTimeoutMilliSeconds="50" cacheCapabilites="true" webappPath="wps"›
Apache and JK connectors¶
Install Apache 2 and mod_jk
sudo apt-get install apache2 libapache2-mod-jk
Edit Apache default site
sudo vi /etc/apache2/sites-available/default
Add
JkMountCopy On
Restart the virtual host
Sudo a2dissite default
Sudo a2ensite default
Configure jk.conf
sudo vi /etc/apache2/mods-available/jk.conf
Add:
JkWorkersFile /etc/apache2/workers.properties
JkLogFile /var/log/apache2/mod_jk.log
JkShmFile /var/log/apache2/mod_jk.shm
JkLogLevel /info
Configure jk.load
sudo vi /etc/apache2/mods-available/jk.load
Add:
LoaModule jk_module /usr/lib/apache2/modules/mod_jk.so
Configure workers
sudo vi /etc/apache2/workers.properties
Add the following.
worker.list=worker1,worker2
worker.worker1.type=ajp13
worker.worker1.host=localhost
worker.worker1.port=8109
worker.worker2.type=ajp13
worker.worker2.host=localhost
worker.worker2.port=8209
Restart mod_jk
sudo a2dismod jk
sudo a2enmod jk
Create site configuration for the WPS
sudo vi /etc/apache2/sites-available/default
Add:
‹IfModule mod_jk.c›
JkMountCopy On
JkMount /WPS-Webapp-0.0.1/* worker1
JkMount /wps/* worker1
Alias /wps "/usr/local/ WPS-Webapp-0.0.1"
‹Directory "/usr/local/ WPS-Webapp-0.0.1"›
Options Indexes MultiViews FollowSymLinks
AllowOverride None
Allow from all
‹/Directory›
‹/IfModule›
Enable site
sudo a2ensite wps
Stop Apache
sudo /etc/init.d/apache2 stop
Restart your WPS Tomcat instance
sudo /etc/init.d/wpsinst restart
Start Apache
sudo /etc/init.d/apache2 start
Check in your web browser that the WPS work
localhost/wps