Install Project.net Amazon EC2


The installation of Project.net is covered extremly well in the wiki of the site. There are some slight changes required for installation on Amazon mainly around the host name.

If you use the standard Amazon AMI Linux image, this comes with JAVA pre-installed and saves you the pain of installing JAVA on Linux.

This as per usual is not complete and therefore should be used carefully and it is still unproven and could be full of errors.

Install a Linux server and install Oracle as per the Survival Guides Install Oracle Express on Amazon AWS

Once this has been done you can no start on the installation as per the wiki. project.net wiki

Download the project.net software.

cd ~

cd software

mkdir projectnet

cd projectnet

wget http://downloads.sourceforge.net/project/projectnet/Project.net%20Production/Project.net%209.2.5/Custom_Installation_925.zip?r=http%3A%2F%2Fsourceforge.net%2Fprojects%2Fprojectnet%2F&ts=1331395530&use_mirror=heanet

unzip Custom_Installation_925.zip

cd ~

cd software

To make this easier for the instructions we will move the folder to /tmp

mv projectnet /tmp/

cd /tmp/projectnet/database/create-scripts/versions/9.2.0/new

yum install dos2unix

find . -type f -exec dos2unix {} \;

 vi pnetMasterDBBuild.sh

Change the following

PNET_BUILD_DB_SCRIPTS_PATH=/tmp/projectnet/database/create-scripts/versions/9.2.0/new

PNET_BUILD_DB_DATABASE_NAME = XE (XE is for because we are using the express database)

PNET_BUILD_DB_DATAFILE_PATH=/usr/lib/oracle/xe/oradata/XE/

PNET_BUILD_SYSTEM_ACCOUNT=system
PNET_BUILD_SYSTEM_PASSWORD=xxxxxxxxx

PNET_BUILD_USER_NAME=pnet
PNET_BUILD_USER_PASSWORD=xxxxx

PNET_BUILD_APP_USER_NAME=pnet_user
export PNET_BUILD_APP_USER_PASSWORD=xxxxxxx

chmod 755 pnetMasterDBBuild.sh

./pnetMasterDBBuild.sh

To monitor the installation use the following command. It is assumed that you did not change the location and name of the log file in the pnetMasterDBBuild.sh file.

tail -f /tmp/pnet_test_db_build.log

Towards the end of the script it appears to stall when it gets to the entry

=====================================
Applying 9.2.0 upgrade patch
=====================================

If you tail the log file you will see that the script requires some entries, pressing enter forces the script to run

You need to press enter until you get the Done message.

This is direct from the Wiki for a little bit until I say otherwise, the wiki is good but it does have the assumption that you know you way around Linux. These instructions blend the two together.

Copy /tmp/pnet/v9.2.0_OS/lib/jce6/*.jar to the jre/lib/security directory of the Java runtime location.

cp /tmp/projectnet/lib/jce6/*.jar /usr/lib/jvm/jre/lib/security

Apache tomcat needs to be installed now

cd ~

cd software

wget http://apache.mirrors.timporter.net/tomcat/tomcat-6/v6.0.35/bin/apache-tomcat-6.0.35.tar.gz

tar xzvf apache-tomcat-6.0.35.tar.gz

mv apache-tomcat-6.0.35 /opt/

ln -s /opt/apache-tomcat-6.0.35 /opt/tomcat

ln -s /opt/apache-tomcat-6.0.35 /opt/apache-tomcat

We need to set the paths for the CATALINA_HOME

vi /etc/profile

and this to the bottom of the file

export CATALINA_HOME=/opt/tomcat

export PATH=$PATH:$CATALINA_HOME

You can also change the .bashrc file in the home directory

To test the starting of Tomcat use the following

cd $CATALINA_HOME/bin

./startup.sh

./shutdown.sh

You should get no errors.

The Tomcat server needs configuring now.

cd $CATALINA_HOME/conf

vi tomcat-users.xml

Add a new user named “manager” and “manager” role associated with it (Note: it is strongly recommended that you use secure passwords in place of those listed below):

TAKE A NOTE OF THE MANAGER PASSWORD as it is needed later on in the configuration

The file should look like this

<role rolename=”tomcat”/>
<role rolename=”role1″/>
<role rolename=”manager”/>
<user username=”tomcat” password=”tomcat” roles=”tomcat”/>
<user username=”both” password=”tomcat” roles=”tomcat,role1″/>
<user username=”role1″ password=”tomcat” roles=”role1″/>
<user username=”manager” password=”manager” roles=”manager”/>

cp /tmp/projectnet/lib/mail.jar $CATALINA_HOME/lib

cp /tmp/projectnet/lib/activation.jar $CATALINA_HOME/lib

cp /tmp/projectnet/lib/jdbc/ojdbc14.jar $CATALINA_HOME/lib

mkdir $CATALINA_HOME/endorsed

cp /tmp/projectnet/lib/endorsed/serializer.jar $CATALINA_HOME/endorsed

cp /tmp/projectnet/lib/endorsed/xalan.jar $CATALINA_HOME/endorsed

cp /tmp/projectnet/lib/endorsed/xercesImpl.jar $CATALINA_HOME/endorsed

cp /tmp/projectnet/lib/endorsed/xml-apis.jar $CATALINA_HOME/endorsed

cd $CATALINA_HOME/conf

vi server.xml

Find the port that are marker 8080 and change them to 9090

/8080 and n will find all the entries in the file

Be careful as the file is full of commented lines and there is only one live line

This is taken directly from the wiki

Instructions (Linux systems)

  • Add the following lines near the top of TOMCAT_HOME/bin/catalina.sh
  if [ -z "$JAVA_OPTS" ]
  then
  JAVA_OPTS="-Xms256m -Xmx<see above>m -XX:MaxPermSize=384m -Xss<see
  above>k -Djava.awt.headless=true"
  else
  JAVA_OPTS=${JAVA_OPTS}" -Xms256m -Xmx<see above>m -XX:MaxPermSize=384m
  -Xss<see above>k -Djava.awt.headless=true"
  fi

You need to use this line if you are using following java versions “1.6.0_26, 1.6.0_27 ….. 1.6.0_31″

JAVA_OPTS=”-server -Djava.awt.headless=true -Xms256m -Xmx<>m -XX:MaxPermSize=384m -Xss<>k”

To start tomcat automatically you need to use the following script. This was lifted directly from the wiki, I would suggest using the wiki version for the latest code. This one works though

vi /etc/inin.d/tomcat

 
#!/bin/sh
#
# Startup script for Tomcat 6.0, the Apache Servlet Engine
#
# chkconfig: - 80 20
# description: Tomcat 6
# processname: tomcat
# pidfile: /var/run/tomcat6.pid
# config:
#

# Source function library.
if [ -x /etc/rc.d/init.d/functions ]; then
. /etc/rc.d/init.d/functions
fi

# Get Tomcat config

# PID_FILE - must match CATALINA_PID in catalina.sh
PID_FILE=/opt/apache-tomcat/bin/startstop.pid

# Path to the tomcat launch script (direct don't use wrapper)
TOMCAT_SCRIPT=/opt/apache-tomcat/bin/catalina.sh

# Tomcat name
TOMCAT_PROG=tomcat

# SYSTEM lock file
SYSTEM_LOCK_FILE=/opt/apache-tomcat/bin/startstop.lock

# How long to wait for shutdowns
SHUTDOWN_WAIT=15

# if TOMCAT_USER is not set
if [ -z "$TOMCAT_USER" ]; then
    TOMCAT_USER="pnet"
fi

# Since the daemon function will sandbox $tomcat
# no environment stuff should be defined here anymore.

RETVAL=0

# See how we were called.
start() {
    echo -n "Starting $TOMCAT_PROG: "

        if [ -f $SYSTEM_LOCK_FILE ] ; then
                if [ -f $PID_FILE ]; then
                        read kpid < $PID_FILE
                        if checkpid $kpid 2>&1; then
                                echo "process allready running"
                                return -1
                        else
                                echo "lock file found but no process running for pid $kpid, continuing"
                                /bin/rm -f $SYSTEM_LOCK_FILE $PID_FILE
                        fi
                fi
        fi

        export CATALINA_PID=$PID_FILE

        if [ -x /etc/rc.d/init.d/functions ]; then
                daemon --user $TOMCAT_USER $TOMCAT_SCRIPT start
        else
                su - $TOMCAT_USER -c "$TOMCAT_SCRIPT start"
        fi

        RETVAL=$?
        echo
        [ $RETVAL = 0 ] && touch $SYSTEM_LOCK_FILE
        return $RETVAL
}

stop() {
    echo -n "Stopping $TOMCAT_PROG: "

    if [ -f $SYSTEM_LOCK_FILE ] ; then
      if [ -x /etc/rc.d/init.d/functions ]; then
          daemon --user $TOMCAT_USER $TOMCAT_SCRIPT stop
      else
          su - $TOMCAT_USER -c "$TOMCAT_SCRIPT stop"
      fi
      RETVAL=$?

      if [ $RETVAL = 0 ]; then
        count=0;

        if [ -f $PID_FILE ]; then

            read kpid < $PID_FILE
            let kwait=$SHUTDOWN_WAIT

            until [ `ps --pid $kpid | grep -c $kpid` = '0' ] || [ $count -gt $kwait ]
            do
                echo "waiting for processes to exit";
                sleep 1
                let count=$count+1;
            done

            if [ $count -gt $kwait ]; then
                echo "killing processes which didn't stop after $SHUTDOWN_WAIT seconds"
                kill -9 $kpid
            fi
        fi

        rm -f $SYSTEM_LOCK_FILE $PID_FILE
    fi

    fi
}

# See how we were called.
case "$1" in
  start)
        start
        ;;
  stop)
        stop
        ;;
  restart)
        stop
        sleep 2
        start
        ;;
  condrestart)
        if [ -f $PID_FILE ] ; then
                stop
                start
        fi
        ;;
  *)
        echo "Usage: $TOMCAT_PROG {start|stop|restart|condrestart}"
        exit 1
esac

exit $RETVAL

The user that starts tomcat in the script is pnet, I have changed this to root just to get it working. I will go back and create pnet as a user and then make it work. One thing I always do in Linux and many think, use the most privileged user as this eliminates the whole authority issues and allows you to concentrate on the scripting errors.

To get this script working make sure that you have don the ln steps above

service start tomact

If it starts successfully

chkconfig –add tomcat

chkconfig tomcat on

Now download ActiveMQ

wget http://mirror.ox.ac.uk/sites/rsync.apache.org/activemq/apache-activemq/5.6.0/apache-activemq-5.6.0-bin.tar.gz

tar xvzf apache-activemq-5.6.0-bin.tar.gz

cd apache-activemq-5.6.0

mv apache-activemq-5.6.0 /opt/ 

cd /opt

ln -s apache-activemq-5.6.0/ apache-activemq

cd apache-activemq

The assumption is that you are running 32 bit Linux, I will leave you to guess what the 64 bit directory is called 🙂

/opt/apache-activemq/bin/linux-x86-32

vi wrapper.conf

Look for the following lines

set.default.ACTIVEMQ_HOME=../..
set.default.ACTIVEMQ_BASE=../..

And change them to

set.default.ACTIVEMQ_HOME=/opt/apache-activemq
set.default.ACTIVEMQ_BASE=/opt/apache-activemq

cd /opt/

ln -s /opt/apache-activemq/bin/linux-x86-32/activemq /etc/init.d/activemq

service activemq start

If the service starts correctly

chkconfig –add activemq

chkconfig activemq on

We now have all of the environment set up 🙂 To test if it works browse to

http://domainname.com:9090/manager/html

the username is manager and the password is the password that was set in the tomcat-user.xml file above

 

Installing project.net is next.

There are a few ways to do this according to the wiki, this is the way I have done it, it is your preference. I don’t claim to be a tomcat expert and therefore can not give an opinion on the best way to deploy the packages. I think though not overwriting the ROOT is good practice though.

I am sure that there is a way to install the pnet.war file directly from the EC2 server, but again my lack of

 

 

 

Last thing to setup, is to serve the site via Apache, this should speed the site up considerably.

yum install httpd

service httpd start

If it starts OK

chkconfig –add httpd

chkconfig httpd on

Advertisements


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s