Configuring the Tomcat Service

Source: Internet
Author: User


There are many Web sites using JSP program to write, so the process of parsing JSP must have the relevant software to complete. Tomcat is a software used to parse a JSP program, and the JDK is the equivalent of a container.


First, install the JDK

Go directly to the JDK website and choose the correct version: http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html

1. Download

[Email protected] ~]# CD/USR/LOCAL/SRC

[Email protected] src]# wget "http://download.oracle.com/otn-pub/java/jdk/8u60-b27/jdk-8u60-linux-i586.tar.gz? authparam=1442413303_f3baa045ae67f2f82baa37af55bf1d8e "

2. Decompression

[Email protected] src]# tar-zxvf jdk-8u60-linux-i586.tar.gz\? authparam\=1442413303_f3baa045ae67f2f82baa37af55bf1d8e

3. Mobile

[[Email protected] src]# mv jdk1.8.0_60/usr/local///JDK and Tomcat do not compile, just move the folder.

4. Configure Environment variables

[[email protected] src]# vim/etc/profile.d/java.sh//new write to content below

java_home=/usr/local/jdk1.8.0_60/

Java_bin=/usr/local/jdk1.8.0_60/bin

Jre_home=/usr/local/jdk1.8.0_60/jre

Path= $PATH:/usr/local/jdk1.8.0_60/bin:/usr/local/jdk1.8.0_60/jre/bin

classpath=/usr/local/jdk1.8.0_60/jre/lib:/usr/local/jdk1.8.0_60/lib:/usr/local/jdk1.8.0_60/jre/lib/ Charsets.jar

Export Java_home java_bin jre_home PATH CLASSPATH

5. Save and make it effective

[Email protected] src]#. /etc/profile.d/java.sh//dots with spaces

[Email protected] src]# java-version

Java version "1.7.0_45"

OpenJDK Runtime Environment (rhel-2.4.3.3.el6-i386 u45-b15)

OpenJDK Client VM (build 24.45-b08, mixed mode, sharing)

Note : found that the JDK version is not the 1.8.0_60 version that was just configured because I checked the installation development environment before minimizing the installation system. So the system installed the JDK, we found the previously installed and then uninstalled.

[[email protected] src]# Yum list |grep JDK//Find out which Java packages are installed

[[email protected] src]# Yum remove java-1.6.0-openjdk* java-1.7.0-openjdk*//Uninstall other Java packages

[Email protected] src]#. /etc/profile.d/java.sh

[Email protected] src]# java-version

Java version "1.8.0_60"

Java (TM) SE Runtime Environment (build 1.8.0_60-b27)

Java HotSpot (TM) Client VM (build 25.60-b23, Mixed mode)




Ii. installation of Tomcat

go to Tomcat official website Select the correct version: http://tomcat.apache.org/  

1. Download
[Email protected] src]# wget http://apache.fayea.com/tomcat/tomcat-7/v7.0.64/bin/apache-tomcat-7.0.64.tar.gz

2. Decompression

[Email protected] src]# TAR-ZXVF apache-tomcat-7.0.64.tar.gz

3. Mobile

[Email protected] src]# MV Apache-tomcat-7.0.64/usr/local/tomcat

[Email protected] src]# cd/usr/local/tomcat/

[[email protected] tomcat]# cp-v Bin/catalina.sh/etc/init.d/tomcat//Mobile startup script

4. Edit the startup script

[[email protected] tomcat]# vim/etc/init.d/tomcat//Add the following on the second line

# chkconfig:112 63 37//112 Start level, 63 boot order, 37 off order (all custom)
# Description:tomcat Server init script
# Source Function Library
. /etc/init.d/functions

java_home=/usr/local/jdk1.8.0_60/
Catalina_home=/usr/local/tomcat

5. Boot start

[Email protected] tomcat]# chmod 755/etc/init.d/tomcat

[Email protected] tomcat]# chkconfig--add Tomcat

[[email protected] tomcat]# chkconfig Tomcat on

6. Start Tomcat Service

[[Email protected] tomcat]# service Tomcat start//start

or execute the following command to start

[[email protected] tomcat]#/etc/init.d/tomcat start

View Yes all started successfully

[[Email protected] tomcat]# PS aux |grep Tomcat

We can also use the browser to enter the address: 192.168.0.109:8080 view, you will see Tomcat's default page. (Check to turn off the firewall before)

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/73/6B/wKioL1X9WBuQAp2wAAKsZIAXd1o526.jpg "title=" Qq20150919202938.jpg "alt=" Wkiol1x9wbuqap2waaksziaxd1o526.jpg "/>





Iii. configuration and optimization of Tomcat

1. Configure the access port of the Tomcat service

Tomcat starts with port 8080 by default, and if you want to change to 80, you need to modify the Server.xml file

[Email protected] tomcat]# cd/usr/local/tomcat/conf/

[Email protected] conf]# vim Server.xml

Found it:

<connector port= "8080" protocol= "http/1.1"

Modified to:

<connector port= "protocol=" http/1.1 "

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/73/6D/wKiom1X9WbTS-J57AACatZw0fN8478.jpg "title=" Qq20150919204749.jpg "alt=" Wkiom1x9wbts-j57aacatzw0fn8478.jpg "/>

Restart the Tomcat service

[[Email protected] conf]# service Tomcat stop

[[Email protected] conf]# service Tomcat start

Note: This script does not support restart, so you can only stop and start.

View Lower Port

[Email protected] conf]# NETSTAT-NLP

Note : Because I have previously installed the nginx,80 port is nginx occupied, so first to kill the Nginx service, and then restart the Tomcat service.

in the end, we'll be in the browser . enter 192.168.0.109 directly to access the Tomcat home page.


2. Configure a new virtual host
Typically, we configure multiple virtual hosts on a single Web server. Also edit the configuration file

[[email protected] conf]# vim Server.xml//Insert a new

Unpackwars= "false" autodeploy= "true"

Xmlvalidation= "false" Xmlnamespaceaware= "false" >

<context path= "" docbase= "./" debug= "0" reloadable= "true" crosscontext= "true"/>

</Host>

[[email protected] conf]# mkdir-p/data/tomcatweb//Create Web site file storage directory

Restart the Tomcat service

[[Email protected] conf]# service Tomcat stop

[[Email protected] conf]# service Tomcat start


3. Test Tomcat

Create a test file for Tomcat first:

[Email protected] conf]# vim/data/tomcatweb/111.jsp//Add the following:

<body>

<center>

Now time is: <%=new java.util.Date ()%>

</center>

</body>

After saving, use the Curl test:

[[email protected] conf]# curl-xlocalhost:80 www.123.com/111.jsp//operation results are as follows

<body>

<center>

Now time is: Sun Sep 02:59:04 CST

</center>

</body>

Alternatively, you can bind hosts on your real machine and test them with a browser.

192.168.0.109 www.123.com

650) this.width=650; "Src=" http://s3.51cto.com/wyfs02/M01/73/6E/wKiom1X9ZiXQkdLSAACJvi89cNc054.jpg " Title= "Qq20150919214136.jpg" alt= "Wkiom1x9zixqkdlsaacjvi89cnc054.jpg"/>

The result is as shown above, which indicates that Tomcat was built successfully.




This article is from the "M April Days" blog, please be sure to keep this source http://1015489314.blog.51cto.com/8637744/1696388

Configuring the Tomcat Service

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.