Pacific-Design.com

    
Home Index

1. Linux

2. Tomcat

+ Proxy

+ Service

+ Start On Boot

Linux / Tomcat /

Install Tomcat on Ubuntu 12.04

$ apt-get install tomcat7
$ apt-get install tomcat7-admin 
$ apt-get install tomcat7-examples

Create Private Instance

$ apt-get install tomcat7-user
$ tomcat7-instance-create /home/nitra/instance

* New Tomcat instance created in /home/nitra/instance
* You might want to edit default configuration in /home/nitra/instance/conf
* Run /home/nitra/instance/bin/startup.sh to start your Tomcat instance

Security

$ chgrp -R tomcat7 /etc/tomcat7
$ chmod -R g+w /etc/tomcat7/

Configure .bashrc

$ vi ~/.bashrc

export JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64
export CATALINA_HOME=/var/lib/tomcat7

Java Tomcat Memory Settings & Status

#!/bin/sh
#------------------------------------------------------------------------------------------------#
# https://www.unidata.ucar.edu/software/thredds/current/tds/tds4.3/reference/JavaOptsSummary.html
#------------------------------------------------------------------------------------------------#

NORMAL="-d64 -Xms8192m -Xmx8192m  -server"
MAX_NEW_SIZE="-XX:MaxNewSize=512m"
PERM_SIZE=" -XX:PermSize=128m"
MAX_PERM_SIZE="-XX:MaxPermSize=256m"
HEADLESS="-Djava.awt.headless=true"
JAVA_PREFS_SYSTEM_ROOT="-Djava.util.prefs.systemRoot=$CATALINA_HOME/content/thredds/javaUtilPrefs"

JAVA_OPTS="$NORMAL $MAX_NEW_SIZE $PERM_SIZE $MAX_PERM_SIZE $HEADLESS $JAVA_PREFS_SYSTEM_ROOT"
export JAVA_OPTS

#!/bin/bash

pid=`ps -eaf | grep '/home/tomcat/' | awk '{ print $2 }' | head -1`
jstat -gcutil $pid 1500 20


    public void line() {
        char[] chars = new char[80];
        Arrays.fill(chars, '-');
        System.out.println(String.valueOf(chars));
    }


Tomcat user admin

By default, Tomcat does not enable admin or manager access. vi $TOMCAT_FOLDER/conf/tomcat-users.xml

<tomcat-users> <role rolename="manager-gui"/> <user password="manager" roles="manager-gui" username="manager"/> <user password="admin" roles="manager-script,admin" username="admin"/> </tomcat-users>