Install JDK and tomcat in centos 64-bit and set the Tomcat Startup Procedure

Source: Internet
Author: User

The preparation file is as follows:

1. CentOS-6.4-x86_64-bin-DVD1.iso

2. jdk-7u67-linux-x64.rpm

3.apache-tomcat-7.0.55.tar.gz

The installation procedure is as follows:

1. Install JDK

[[Email protected]/] # Java-version
Bash: Java: Command not found

[[Email protected]/] # rpm-IVH/soft/jdk-7u67-linux-x64.rpm.
Preparing... ######################################## ### [100%]
1: JDK ####################################### #### [100%]
Unpacking jar files...
Rt. jar...
JSSE. jar...
Charsets. jar...
Tools. jar...
Localedata. jar...
Jfxrt. jar...
[[Email protected]/] #

[[Email protected]/] # Java-version
Java version "1.7.0 _ 67"
Java (TM) se Runtime Environment (build 1.7.0 _ 67-b01)
Java hotspot (TM) 64-bit server VM (build 24.65-b04, mixed mode)

[[Email protected]/] # cd/usr/Java
[[Email protected] Java] # ls
Default jdk1.7.0 _ 67 latest
[[Email protected] Java] #



Ii. install Tomcat

Rm-RF/usr/local/tomcat7
CD/usr
CD/usr/local/tomcat7
Ls
Ls

CD/
Tar zxvf/soft/apache-tomcat-7.0.55.tar.gz
MV/Apache-Tomcat-7.0.55/usr/local/tomcat7
Chmod + x/usr/local/tomcat7

3. Set Environment Variables

Run the vim/etc/profile command and add the environment variable Code as follows:

# JDK config
Export java_home =/usr/Java/jdk1.7.0 _ 67
Export calsspath = $ java_home/lib /*.*
# Tomcat config
Export tomcat_home =/usr/local/tomcat7
Export catalina_home =/usr/local/tomcat7
# Path config
Export Path = $ path: $ java_home/bin: $ tomcat_home/bin

Execute Command source/etc/profile to refresh environment variable

4. start Tomcat

SH/usr/local/tomcat7/bin/startup. Sh

Open the URL http: // localhost: 8080 in Firefox to test

Disable Tomcat commands
SH/usr/local/tomcat7/bin/shutdown. Sh

V. start Tomcat script upon startup


5.1 run the command VI/etc/rc. d/init. d/tomcat to generate the script file. The content is as follows:

#! /Bin/bash

#

#/Etc/rc. d/init. d/tomcat

# Init script for Tomcat precesses

#

# Processname: Tomcat

# Description: Tomcat is a j2se Server

# Chkconfig: 2345 86 16

# Description: start up the Tomcat Servlet Engine.

If [-F/etc/init. d/functions]; then

./Etc/init. d/functions

Elif [-F/etc/rc. d/init. d/functions]; then

./Etc/rc. d/init. d/functions

Else

Echo-e "\ atomcat: unable to locate functions Lib. cannot continue ."

Exit-1

Fi

Retval =$?

Catalina_home = "/usr/local/tomcat7" # tomcat installation directory

Case "$1" in

Start)

If [-F $ catalina_home/bin/startup. Sh];

Then

Echo $ "Starting Tomcat"

$ Catalina_home/bin/startup. Sh

Fi

;;

Stop)

If [-F $ catalina_home/bin/shutdown. Sh];

Then

Echo $ "Stopping Tomcat"

$ Catalina_home/bin/shutdown. Sh

Fi

;;

*)

Echo $ "Usage: $0 {START | stop }"

Exit 1

;;

Esac

Exit $ retval



5.2 Add the CHMOD 755/etc/rc. d/init. d/tomcat permission to make the script file executable

5.3 run: chkconfig -- add/etc/rc. d/init. d/tomcat # add it to the service

5.4 Add the following statement to the vim/usr/local/tomcat7/bin/Catalina. Sh file:

# Auto startup Tomcat config
Export java_home =/usr/Java/jdk1.7.0 _ 67
Export catalina_home =/usr/local/tomcat7
Export catalina_base =/usr/local/tomcat7
Export catalina_tmpdir =/usr/local/tomcat7/temp

Start Tomcat service: Service Tomcat start
Stop Tomcat service: Service Tomcat stop

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.