Section author: Emanuele Disco <>

PMIS - Linux Server Configuration


#. Update System Packages

# for Centos
yum update

# for Ubuntu
apt-get update && apt-get upgrade

1. Create User sangah and folder SAPP

# create the user
useradd sangah

# make sure the folder has been created
cd /home/sangah

# create the SAPP folder
mkdir /home/sangah/SAPP

2. Install PDF Conversion Tool (wkhtmltopdf)

Checkout on your local computer the folder STND_PMIS_util/htmltopdf from the SVN.


Copy the right version on the server and install it with:

# for Centos
rpm -i wkhtmltox-

# for Ubuntu
dpkg --install wkhtmltox-

Find the location of the executable for later use with:

which wkhtmltopdf

3. Server LOCALE Setting

Fix the locale on the server and make sure is set as UTF-8:

locale charmap

echo $LANG

If the locale doesn’t match modify the LANG variable for the user:

printf '\nexport LC_ALL=ko_KR.UTF-8' >> .bashrc
printf '\nexport LANG=$LC_ALL' >> .bashrc

To test the change log out and log in again and do the test again.

4. Install Chinese/Japanese/Korean Support Packages

Install some language packages

For Centos

yum groupinstall "Chinese Support"
yum groupinstall "Japanese Support"
yum groupinstall "Korean Support"
yum groupinstall "Kannada Support"
yum groupinstall "Hindi Support"

For Ubuntu

# Japanese
apt-get install fonts-takao-mincho fonts-takao

# Other
apt-get install language-pack-zh \
msttcorefonts \
xfonts-intl-chinese \
xfonts-intl-chinese-big \
fonts-arphic-uming \

5. Install MS fonts and PMIS fonts for PDF Conversion

We need to install some common Microsoft fonts:

# for Centos
yum install curl cabextract xorg-x11-font-utils fontconfig
rpm -i

# for Ubuntu
apt-get install msttcorefonts

We also need to install some Korean fonts that we use in PMIS Document:

Checkout the folder STND_PMIS_util/etc/fonts on your computer.


Make a new directory on the server where we will put the fonts:

mkdir /usr/share/fonts/pmisfonts

Place all the *tff files in the new directory using WinSCP.

Then execute the following command to update the font cache:

fc-cache -f -v

6. Download & Install Apache Tomcat

We are going to take Apache Tomcat 7 from the official website

Make an util folder inside the sangah home if you didn’t already:

mkdir /home/sangah/util
cd /home/sangah/util

Download Tomcat and extract the archive:

tar -xvf apache-tomcat-7.0.68.tar.gz

We will place the tomcat folder in /usr/local leaving a copy of the directory for future use:

sudo cp -r apache-tomcat-7.0.68 /usr/local/

Rename the folder that we moved to /usr/local to reflect the project name ( ex. tomcat7-LGSP ):

cd /usr/local
sudo mv apache-tomcat-7.0.68 tomcat7-PROJECT_CODE

We need to add the file inside the bin folder of the new Tomcat to set some memory settings:

cd tomcat7-PROJECT_CODE/bin

Put this line inside the file and edit it accordingly:

export JAVA_OPTS="-Dfile.encoding=UTF-8 -Xms128m -Xmx2G -XX:PermSize=64m -XX:MaxPermSize=512m -Djava.awt.headless=true -Xloggc:$CATALINA_BASE/logs/gc.log -XX:+PrintGCDetails -XX:+PrintGCDateStamps -XX:+PrintGCTimeStamps"

Edit -Xmx parameter in case you need to change the Max Heap Size memory and leave the rest unchanged.

7. Tomcat server.xml settings

We need to configure the server.xml inside conf directory. Replace all the content of the file with the following and modify it accordingly

<?xml version="1.0" encoding="UTF-8"?>
<Server port="8005" shutdown="SHUTDOWN">

        <!--APR library loader. Documentation at /docs/apr.html -->
        <Listener SSLEngine="on" className="org.apache.catalina.core.AprLifecycleListener"/>
        <!--Initialize Jasper prior to webapps are loaded. Documentation at /docs/jasper-howto.html -->
        <Listener className="org.apache.catalina.core.JasperListener"/>
        <!-- Prevent memory leaks due to use of particular java/javax APIs-->
        <Listener className="org.apache.catalina.core.JreMemoryLeakPreventionListener"/>
        <Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener"/>
        <Listener className="org.apache.catalina.core.ThreadLocalLeakPreventionListener"/>

                <Resource auth="Container" description="User database that can be updated and saved"
                name="UserDatabase" pathname="conf/tomcat-users.xml" type="org.apache.catalina.UserDatabase"/>

        <Service name="STND">

                <!-- you don't need this if you use AJP with Apache HTTP
                <Connector URIEncoding="UTF-8"

                <Connector URIEncoding="UTF-8" enableLookups="false" port="9007" protocol="AJP/1.3" redirectPort="443"/>

                <Engine defaultHost="localhost" jvmRoute="ajp13" name="STND">
                        <Realm className="org.apache.catalina.realm.UserDatabaseRealm" resourceName="UserDatabase"/>
                        <Host appBase="C:\Users\Disco\workspace_4.5\STND_PMIS_comm_branch"
                        autoDeploy="false" deployOnStartup="false" name="localhost"
                        unpackWARs="false" xmlNamespaceAware="false" xmlValidation="false">

                                <Context docBase="web" path="" reloadable="false"  />


8. Create Project folder

Create the project folder under /home/sangah/SAPP:

mkdir /home/sangah/SAPP
cd /home/sangah/SAPP
mkdir web

9. Deploy the web folder under the new project folder

Use WinSCP to upload all the files (jsp, class, ecc...) inside the new web under the project directory

10. Create log, thumb, temp and edms folder under project folder

Create some folders under the project directory required for the execution:

cd /home/sangah/SAPP/PROJECT_FOLDER
mkdir log
mkdir thumb
mkdir temp
mkdir edms

Create a symbolic link to edms folder under the web/data folder:

cd /home/sangah/SAPP/PROJECT_FOLDER
cd web/data
ln -s /home/sangah/SAPP/PROJECT_FOLDER/edms .

12. Deploy, and

Using WinSCP upload the following files inside the project folder ~/WEB-INF/classes:


    Struts configuration file


    Log4j Logging configuration file


    System configuration file

13. Configure

Good time for editing


Take a look at System Properties for more information.

TODO Check the following properties:

  • fix all the path to the web folder
  • fix all the url & domain
  • fix the temporary folder
  • fix the thumbnail folder
  • fix the path to the pdf converter
  • fix db instance
  • fix login page
  • fix email service
  • ecc...

14. Download mod_jk (Tomcat Connector for Apache HTTP)

Before starting you should know the location of the apache configuration folder. Usually it should be /etc/httpd for Centos or /etc/apache2 for Ubuntu server.

Check if the server has already mod_jk installed:

# for Ubuntu
ls /usr/lib/apache2/modules/

# for Centos
ls /usr/lib64/httpd/modules/

If the module is already present just skip to the configuration; you do NOT need to install the connector again if is already present.

Install dependencies for compiling the connector, we need the Apache Development libraries and gcc*:

# for Centos
yum install httpd-devel
yum install gcc*

# for Ubuntu
apt-get install apache2-dev gcc*

Download the tomcat connector from here

tar -xvf tomcat-connectors-1.2.41-src.tar.gz

15. Compile and install mod_jk

Make sure you have apxs with:

ls /usr/bin/apxs

Compile and install:

cd tomcat-connectors-1.2.41-src
cd native
./configure --with-apxs=/usr/bin/apxs
sudo make install

Check that the module has been placed in the modules folder of apache.

# for Ubuntu
ls /usr/lib/apache2/modules/

# for Centos
ls /usr/lib64/httpd/modules/

16. Load module mod_jk for Apache HTTP

We need to tell apache about the new module or he will not load it.

In a Centos server do the following:

cd /etc/httpd/cond.d
touch jk.conf
nano jk.conf

Place the following content inside the file jk.conf:

LoadModule jk_module modules/
<IfModule jk_module>
        JkWorkersFile    conf/
        JkLogFile        logs/mod_jk.log
        JkLogLevel       info

Create a file inside the conf directory where you will need to put the AJP configuration:



17. Create a conf file for the project under the folder conf.d of Apache

From the apache folder create a new configuration file for the project inside the conf.d folder:

cd conf.d
touch project.conf

Place into the file the VirtualHost settings similar to the following:

Apache Configuration


To make all of this working inside the httpd.conf there should be a line like this:

Include conf.d/*.conf

18. Change permission of /home/sangah to 755

Make sure every users can access the web directory or you will get an access denied.

Change the permissions to 755 for the folders until the web if necessary.

19. [Centos] Change Enforcement on SAPP folder

This step is only for Centos server!

SELinux Enforcement is a problem for web application and to prevent a Permission Denied error we need to fix it.

# install dependencies
yum install policycoreutils-python

# disable enforcement for SAPP folder
semanage fcontext -a -t public_content_t '/home/sangah/SAPP(/.*)?'

# update permissions
restorecon -R /home/sangah/SAPP

We just told to Centos that the SAPP folder is a directory that contains web content and so the enforcement will be disabled for this directory and all the subdirectories.

Install PhantomJS HTML builder & loader

PhantomJS is required for the Document module in order to create the PDF version, so is important to install it correctly on the server.

  1. Get the phantomjs folder from the SVN

The executable can be get from the SVN following this address:

Inside the folder there are three versions, one for Windows, one for Linux 32bit and for Linux 64bit.

2. Locate the folder util on the server (/home/sangah/util or /home/sangah/SAPP/util), if not exists just create it and then copy the phantomjs folder inside it.

3. Assuming the server is linux and the phantomjs folder is located in /home/sangah/SAPP/util/phantomjs add the executable flag to the files to make them executable:

cd /home/sangah/SAPP/util/phantomjs
chmod +x phantomjs*
  1. Test the executable to see if run correctly:

    ./phantomjs_x64 -v
  2. Two new properties need to be added to the file:



Change the paths to the right location of the phantomjs executable and to the right location of the pmis_doc_export.js script

[Extra] Install Nginx File Upload Server

Nginx File Upload Handler Install & Configuration