Home > Joyent SmartOSPlus (Server) > Setup Tomcat on Solaris 11

Setup Tomcat on Solaris 11

Here are my steps for installing Tomcat 6 on Solaris 11 server. Begin by securely logging into the server via SSH with administrative control. I am able to login using “admin” user. Admin user has ability to perform most operations without being root. I have chosen to install Tomcat 6 with java 6. I was fortunate to have Apache Web Server already installed when my machine was imaged.

ssh admin@MyIPAddress

Part 1: Find Java on the server

Check Java Version:
java -version

This command simply checks the version of Java. For example, my output looks like:

java version "1.6.0_26" Java(TM) SE Runtime Environment (build 1.6.0_26-b03) Java HotSpot(TM) Client VM (build 20.1-b02, mixed mode, sharing)

Find Java Location:
find / -name java 2>/dev/null

This command searches the file system for files with the name java in it. All other output is sent to null. So only the results you are interested in are printed to the terminal screen. I find where java is located on my server:

/opt/local/java/sun6/bin/java

therefore, JAVA_HOME=/opt/local/java/sun6

Confirm Java Location:
For fun, confirm this is correct by running the java -version command using the absolute path. Since the java binary should be located in the bin directory we should be able to check the version and get the output. If successful, we have what we are looking for. This step probably isn’t necessary. Its nice to have the confirmation.

/opt/local/java/sun6/bin/java -version

The results are:

java version "1.6.0_26" Java(TM) SE Runtime Environment (build 1.6.0_26-b03) Java HotSpot(TM) Client VM (build 20.1-b02, mixed mode, sharing)

Write down the path to our java directory. We will add this to the Manifest entry later as an environment variable.

Download Tomcat 6

Now download Tomcat 6.
Using firefox browser: go to Tomcat website and pick a download location. Here is one for example: http://apache.cs.utah.edu/tomcat/tomcat-6/v6.0.35/bin/apache-tomcat-6.0.35.tar.gz

Copy the link. Return to SSH terminal and wget to download the compressed zipped tarball file. Type wget command. Right click and paste the url.

wget http://apache.cs.utah.edu/tomcat/tomcat-6/v6.0.35/bin/apache-tomcat-6.0.35.tar.gz

The apache-tomcat-6.0.35.tar.gz tarball should be in the user home directory.

Checksum – validate the download
Verify your download has not been tampered with using the checksum. I will use the md5 encryption key. The checksum keys are found beside your binary download link on the tomcat website. For example, when running the md5sum command; we should have a matching checksum value.

md5sum apache-tomcat-6.0.35.tar.gz

The output from the command above is:

171d255cd60894b29a41684ce0ff93a8  apache-tomcat-6.0.35.tar.gz

When comparing this against the checksum value saved in the md5 link on the tomcat website we see these match. So it is safe to install software on our server.

Extract and move tomcat directory to permanent location
Its time to move tomcat directory to a meaningful location. Note I am new to Linux and Solaris so I may take additional (and unnecessary) installation steps. For example, I extract and move the tomcat directory as root user. Then I change the ownership of the directory. This may be an extra step. That is ok with me at this time. Please do as you see fit.

Different sources on the Internet say to put tomcat directory here or there. I chose to put in with java directory. I figure its just a location. You chose what makes sense to you please.

I will store in the directory: /opt/local/java

sudo mv apache-tomcat-6.0.35.tar.gz /opt/local/java/apache-tomcat-6.0.35.tar.gz

Verify it moved:

cd /opt/local/java; ls;

Extract it.

sudo tar xzvf apache-tomcat-6.0.35.tar.gz

The switches for the tar command are:
x – Extract the contents of the archive.
z – Decompress the files using gzip utility.
v – Verbose, display the output of stdout so you can see what is happening.
f – Filename, specifices that we are providing a file name.

Rename directory:
Once extracted, rename the directory to something meaningful. I choose tomcat6.

sudo mv apache-tomcat-6.0.35 tomcat6; ls

The tomcat directory should now be /opt/local/java/tomcat6.

Create Tomcat User and Group

Now its time to create the tomcat user who belongs to the tomcat group.

Create a tomcat group:

groupadd tomcat

Create a tomcat user:

useradd -s /bin/bash -g tomcat -m tomcat

The switches for the useradd command are:
s – Specifices the absolute pathname to the shell used for the user account.
g – Specifies a new primary group for the user account.
m -Specifies that a home directory should be created for the user account.

Assign a password to tomcat user:

passwd tomcat

To edit the tomcat user settings using /etc/passwd file:

sudo vi /etc/passwd

Change ownership of Tomcat directory:

Go to the directory where tomcat6 is stored. I am logged in as admin so i will run sudo commands to change ownership (chown and chgrp).  Note the -R switch is used to change permissions recursively throughout the tomcat6 directory tree.

cd /opt/local/java
sudo chown -R tomcat6 tomcat
sudo chgrp -R tomcat6 tomcat

Tomcat is ready.

Verify Tomcat Server is running:

Turn on Tomcat 6:
sudo /opt/local/java/tomcat6/bin/startup.sh

If you’ve setup environment variable for CATALINA_HOME:

sudo $CATALINA_HOME/bin/startup.sh

Immediate output might resemble:

sudo sh startup.sh
Using CATALINA_BASE:   /opt/local/java/tomcat6
Using CATALINA_HOME:   /opt/local/java/tomcat6
Using CATALINA_TMPDIR: /opt/local/java/tomcat6/temp
Using JRE_HOME:        /opt/local
Using CLASSPATH:       /opt/local/java/tomcat6/bin/bootstrap.jar

View in browser: http://localhost:8080.

To shutdown Tomcat Server.

sudo sh shutdown.sh

Now its time to create a service to start/stop Tomcat Server when the Joyent Server is rebooted.

Advertisements
  1. No comments yet.
  1. No trackbacks yet.

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

%d bloggers like this: