Você está na página 1de 2

4/7/2014

How to install Tomcat 7 + JDK 7 | RoseHosting.com Linux VPS Hosting Blog

How to install Tomcat 7 + JDK 7


Leave reply (/blog/how-to-install-tomcat-7-jdk-7/#respond)
June 7, 2012 Tutorials (http://www.rosehosting.com/blog/category/tutorials/)
Apache Tomcat (/blog/tag/apache-tomcat/) centos (/blog/tag/centos/) java
(/blog/tag/java/) Java Development Kit (/blog/tag/java-development-kit/) jdk
(/blog/tag/jdk/) tomcat (/blog/tag/tomcat/)
(http://www.rosehosting.com/blog/wp-content/uploads/2012/06/Java_logo_and_wordmark.svg_.png)This how-to will show you
how to install Tomcat 7.x and JDK 7.x (Java Development Kit) on a CentOS VPS (http://www.rosehosting.com/centos-vps.html).
You could get one of our Java Hosting (http://www.rosehosting.com/java-hosting/java-vps.html) plans and have everything
already installed and configured but if you want to do it yourself just follow the tutorial below.

1. Install JDK
Choose the correct version for your OS and download the latest JDK release from
http://www.oracle.com/technetwork/java/javase/downloads/index.html

READ MORE:

Create a new /usr/java directory, move the downloaded jdk file to /usr/java and change to the created directory:
1

# mkdir /usr/java && mv jdk-7u4-linux-i586.tar.gz /usr/java/ && cd /usr/java/

Unpack jdk-7u4-linux-i586.tar.gz file:


1

# tar -xzf jdk-7u4-linux-i586.tar.gz

This will create directory, in our case its jdk1.7.0_04


To set the JAVA_HOME path add the lines below to your .bash_profile file:
1
2
3

export JAVA_HOME=/usr/java/jdk1.7.0_04/
export PATH=$JAVA_HOME/bin:$PATH
export PATH=$PATH:$JAVA_HOME/bin

For the changes to take effect execute:


1

(http://www.rosehosting.com/blog/how-to-installphpbb-3-on-a-centos-6-vps/)
How to install phpBB 3 on a CentOS 6 VPS
(http://www.rosehosting.com/blog/how-to-install-phpbb3-on-a-centos-6-vps/)

Today's article will be about installing and configuring


phpBB3 on a CentOS 6 VPS. phpBB (PHP Bulletin
Board) is one of the most popular free...

# source .bash_profile

Check if the JAVA_HOME is set correctly:


1
2

# echo $JAVA_HOME
# /usr/java/jdk1.7.0_04/

2. Install Tomcat 7
Download the latest Tomcat release (currently 7.0.27) from http://tomcat.apache.org/download-70.cgi
1

# wget http://mirror.metrocast.net/apache/tomcat/tomcat-7/v7.0.27/bin/apache-tomcat-7.0.27.tar.gz (http://mirror.metrocast.net/apache/tomcat/tomcat-7/v7.0

Move the file and change to the /usr/share/ directory:


1

# mv apache-tomcat-7.0.27.tar.gz /usr/share/ && cd /usr/share/

Unpack apache-tomcat-7.0.27.tar.gz file:


1

# tar -xzf apache-tomcat-7.0.27.tar.gz

This will create /usr/share/apache-tomcat-7.0.27 directory. Optionally, you can rename this directory to tomcat7:
1

# mv /usr/share/apache-tomcat-7.0.27/ /usr/share/tomcat7

To configure Tomcat 7 to run as a service, change to the /etc/init.d/:


1

# cd /etc/init.d/

Using your favorite text editor, create a script called tomcat with the following text:
1
2
3
4
5
6
7
8
9

#!/bin/bash
# description: Tomcat Start - Stop - Restart
# processname: tomcat
# chkconfig: 234 20 80
JAVA_HOME=/usr/java/jdk1.7.0_04
export JAVA_HOME
PATH=$JAVA_HOME/bin:$PATH
export PATH
CATALINA_HOME=/usr/share/tomcat7

http://www.rosehosting.com/blog/how-to-install-tomcat-7-jdk-7/

1/4

4/7/2014
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30

How to install Tomcat 7 + JDK 7 | RoseHosting.com Linux VPS Hosting Blog


case $1 in
start)
echo "Starting Tomcat"
sh $CATALINA_HOME/bin/startup.sh
;;
stop)
echo "Stopping Tomcat"
sh $CATALINA_HOME/bin/shutdown.sh
;;
restart)
echo "Restarting Tomcat"
sh $CATALINA_HOME/bin/shutdown.sh
sh $CATALINA_HOME/bin/startup.sh
;;
*)
echo $"Usage: $0 {start|stop}"
exit 1
;;
esac
exit 0

Make your script executable:


1

# chmod +x tomcat

Make your Tomcat to start at boot time:


1
2

# chkconfig --add tomcat


# chkconfig --level 3 tomcat on

Check if it is setup correctly:


1

# chkconfig --list tomcat

The default Tomcat port is 8080, so you can try to access it at http://domain.com:8080 where you should see Tomcats default home page.
PS. If you liked this post please share it with your friends on the social networks using the buttons on the left or simply leave a reply below. Thanks.

(/) (/) (/)


(http://www.addtoany.com/share_save#url=http%3A%2F%2Fwww.rosehost
to%20will%20show%20you%20how%20to%20install%20Tomcat%207.x%20an
3 Responses to How to install Tomcat 7 + JDK 7
andrian (http://tomcatdefaultpagenotshow)
December 31, 2012 (/blog/how-to-install-tomcat-7-jdk-7/#comment-17327)
i have follow all the step as mentioned above. But when i access http://ip-address:8080 (http://ip-address:8080) the firefox connecting to the
address for sometimes and then Unable to connect show.
The output of netstat -an |grep 8080 is:
tcp 0 0 :::8080 :::* LISTEN
Reply (/blog/how-to-install-tomcat-7-jdk-7/?replytocom=17327#respond)

vinay
January 26, 2013 (/blog/how-to-install-tomcat-7-jdk-7/#comment-28006)
this is really good tutorial.
i am to setup tomcat in first go.. thanks
Reply (/blog/how-to-install-tomcat-7-jdk-7/?replytocom=28006#respond)

Eduardo
April 12, 2014 (/blog/how-to-install-tomcat-7-jdk-7/#comment-43287)
Thanks!
Reply (/blog/how-to-install-tomcat-7-jdk-7/?replytocom=43287#respond)

Leave a Reply
Name (required)

Email (will not be published) (required)

Website

Comment

http://www.rosehosting.com/blog/how-to-install-tomcat-7-jdk-7/

2/4

Você também pode gostar