About Tomcat:
1.Tomcat is a software used to parse a JSP program. (JSP is a programming language, Java)
2.Tomcat is a core project of the Apache Software Foundation (Apache Software Foundation) Jakarta Project, developed by Apache, Sun, and other companies and individuals.
3.Tomcat is a lightweight application server , which is widely used in small and medium-sized systems and concurrent access users, and is the first choice for developing and debugging JSP programs.
The installation of Tomcat is divided into two steps: Installing the JDK and installing Tomcat.
Download The Java SE development to Oracle's website and select the version according to your system needs (http://211.161.151.150/files/A226000008F1B789/ download.oracle.com/otn-pub/java/jdk/8u111-b14/jdk-8u111-linux-x64.tar.gz)
[email protected] src]# wget http://211.161.151.148/files/9001000008F4E377/120.52.72.24/ download.oracle.com/c3pr90ntc0td/otn-pub/java/jdk/8u112-b15/jdk-8u112-linux-x64.tar.gz #下载
[Email protected] src]# tar zxvf jdk-8u112-linux-x64.tar.gz #解压
[[Email protected] src]# mv jdk1.8.0_112/usr/local/ #移动到/usr/local/
[Email protected] src]# ls/usr/local/
Bin etc games include jdk1.8.0_112 lib lib64 libexec man mysql nginx php pureftpd sbin share src
[Email protected] src]# vim/etc/profile.d/java.sh #需要做一个环境变量的设置
java_home=/usr/local/jdk1.8.0_112/#检查目录和版本, and variables have no problem
Java_bin=/usr/local/jdk1.8.0_112/bin
Jre_home=/usr/local/jdk1.8.0_112/jre
Path= $PATH:/usr/local/jdk1.8.0_112/bin:/usr/local/jdk1.8.0_112/jre/bin
classpath=/usr/local/jdk1.8.0_112/jre/lib:/usr/local/jdk1.8.0_112/lib:/usr/local/jdk1.8.0_112/jre/lib/ Charsets.jar
----------------------------------------------------
[Email protected] src]#. /ETC/PROFILE.D/JAVA.SH # Initialize java.sh
[[email protected] src]# java-version #验证初始化是否成功, output OK
Java version "1.8.0_112" #版本核对无误
Java (TM) SE Runtime Environment (build 1.8.0_112-b15)
Java HotSpot (TM) 64-bit Server VM (build 25.112-b15, Mixed mode)
The installation of the JDK is up to this.
------------------------------Split Line------------------------------
Installation of Tomcat
[Email protected] src]# wget http://mirrors.hust.edu.cn/apache/tomcat/tomcat-8/v8.5.8/bin/apache-tomcat-8.5.8.tar.gz
[Email protected] src]# tar zxvf apache-tomcat-8.5.8.tar.gz #解压
[Email protected] src]# mv Apache-tomcat-8.5.8/usr/local/tomcat #移动
[Email protected] src]# ls/usr/local/tomcat/ #查看
Bin conf lib LICENSE logs NOTICE release-notes RUNNING.txt temp WebApps work
[Email protected] src]# cd/usr/local/tomcat/#进入程序目录
[[email protected] tomcat]# ls
Bin conf lib LICENSE logs NOTICE release-notes RUNNING.txt temp WebApps work
[Email protected] tomcat]# cp-v bin/catalina.sh/etc/init.d/tomcat
' bin/catalina.sh ', '/etc/init.d/tomcat ' #移动启动脚本到/etc/init.d/tomcat
[email protected] tomcat]# chmod 755/etc/init.d/tomcat #加入到系统服务列表
[[email protected] tomcat]# chkconfig--add Tomcat #开机启动失败 because the Tomcat configuration file syntax is not very canonical
Service Tomcat does not support Chkconfig #服务不支持
[[email protected] tomcat]# vim/etc/init.d/tomcat #编译启动脚本, add the following code
#!/bin/sh
# chkconfig:2345 #2345: Start level 63: Start Sequence 37: Turn off order
. /etc/init.d/functions
java_home=/usr/local/jdk1.8.0_112/
Catalina_home=/usr/local/tomcat #家目录
------------------------------------------
[Email protected] tomcat]# chkconfig--add Tomcat #加入到服务列表
[Email protected] tomcat]# chkconfig tomcat on #开机启动
[[email protected] tomcat]#/etc/init.d/tomcat start #启动tomcat, Tomcat does not support Restart.stop&start
Using catalina_base:/usr/local/tomcat
Using Catalina_home:/usr/local/tomcat
Using Catalina_tmpdir:/usr/local/tomcat/temp
Using Jre_home:/usr/local/jdk1.8.0_112/
Using CLASSPATH:/usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/bin/tomcat-juli.jar
Tomcat started.
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/8B/51/wKioL1hJgS2DKkn4AAI0RQLZ2wo966.jpg "title=" t1.jpg "alt=" Wkiol1hjgs2dkkn4aai0rqlz2wo966.jpg "/>
[Email protected] tomcat]# NETSTAT-LNP #tomcat的端口
TCP 0 0:::8080 :::* LISTEN 1732/java
TCP 0 0:: ffff:127.0.0.1:8005 :::* LISTEN 1732/java
TCP 0 0:::8009 :::* LISTEN 1732/java
-------------------------------------------------------------------------------
In Windows Client access via IE:
650) this.width=650; "src=" http://s4.51cto.com/wyfs02/M00/8B/51/wKioL1hJhLHScf6UAAFk8bAmg6k836.jpg "title=" t2.jpg "alt=" Wkiol1hjhlhscf6uaafk8bamg6k836.jpg "/>
-------------------Split Line--------------------
Configuration and optimization of Tomcat
Tomcat starts with 8080 by default, and if you want to change to 80, you need to modify the Server.xml file:
[[email protected] ~]# cd/usr/local/tomcat/conf/ #进入到tomcat configuration file directory
[email protected] conf]# ls #查看
Catalina catalina.properties jaspic-providers.xml logging.properties tomcat-users.xml web. xml
Catalina.policy context.xml jaspic-providers.xsd server.xml tomcat-users.xsd
[Email protected] conf]# vim server.xml #编辑
<connector port= "8080" protocol= "http/1.1" # "8080" to "80"
connectiontimeout= "20000"
redirectport= "8443"/>
Find </Host> next line insert new <Host> content as follows:
appbase= "/data/tomcatweb" #网站的根目录
Unpackwars= "false" autodeploy= "true"
Xmlvalidation= "false" Xmlnamespaceaware= "false" >
<context path= "" docbase= "./" debug= "0" reloadable= "true" crosscontext= "true"/>
# "docbase="./"" The landlord here to copy some of the documents have been not experimental results
The path to the docBase is consistent with the Autodeploy path.
(You can also put the following 1.txt&1.jsp in this directory
" docbase="/usr/local/tomcat/webapps/docs ", can be parsed as normal access)
650) this.width=650; "src=" http://s1.51cto.com/wyfs02/M00/8B/5C/wKioL1hKzpPxFN6YAABu9fwT-bg964.jpg "title=" t4.jpg "alt=" Wkiol1hkzppxfn6yaabu9fwt-bg964.jpg "/> on the Internet to consult some alumni he said this docbase also called the publishing directory.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
find some explanations on the Internet
AppBase: Sets the base directory for the application, absolute path, or path name relative to%catalina_home%
Autodeploy: Indicates whether the Tomcat runtime, if a new Web program is opened appbase the specified directory, is automatic, and the default value is True
Deployxml: false will not resolve context.xml inside the Web application, the default value is True
unpackwars: The virtual host specifies the path name of the directory used for temporary read and write, and Tomcat will provide a suitable directory under the%catalina_home%/work directory.
docBase: The absolute path or relative path of the AppBase property relative to the host.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[Email protected] conf]# Mkdir/data/tomcatweb #创建网站根目录
[Email protected] conf]#/etc/init.d/tomcat stop #停止
[Email protected] conf]#/etc/init.d/tomcat start #启动
[[email protected] conf]# NETSTAT-LNP #查看java whether to occupy 80 ports
TCP 0 0::: +:::* LISTEN 2579/java
[Email protected] conf]# NETSTAT-LNP |grep java
TCP 0 0::: +:::* LISTEN 2579/java
TCP 0 0:: ffff:127.0.0.1:8005:::* LISTEN 2579/java
TCP 0 0::: 8009:::* LISTEN 2579/java
Test access on Windows PC: No additional 8080 is required and can be accessed directly.
650) this.width=650; "src=" http://s5.51cto.com/wyfs02/M02/8B/5C/wKiom1hKXY3AeU-1AAFwRnTOrqs474.jpg "title=" t3.jpg "alt=" Wkiom1hkxy3aeu-1aafwrntorqs474.jpg "/>
[Email protected] conf]# cd/data/tomcatweb/
[Email protected] tomcatweb]# vim 1.txt #输入以下内容
Welcome to CHINA,2016-12-09!!!!
Welcome to CHINA,2016-12-09!!!!
Welcome to CHINA,2016-12-09!!!!
[[email protected] tomcatweb]# vim 1.jsp #输入以下内容, which is a script for Java display time
Now time is: <%=new java.util.Date ()%>
</center></body>
----------------------------------------------------
[[email protected] tomcatweb]#/etc/init.d/tomcat stop
[Email protected] tomcatweb]#/etc/init.d/tomcat start #重启tomcat
[[email protected] tomcatweb]# NETSTAT-LNP |grep java #确认Tomcat started
TCP 0 0::: +:::* LISTEN 2151/java
TCP 0 0:: ffff:127.0.0.1:8005:::* LISTEN 2151/java
TCP 0 0::: 8009:::* LISTEN 2151/java
-----------------------------------------------------
Use the Curl command to test under Linux : The following effect, you can access the 1.txt, you can also parse the JSP.
[Email protected] tomcatweb]# curl-xlocalhost:80 www.7_linux.com/1.txt
[Email protected] tomcatweb]# curl-xlocalhost:80 www.7_linux.com/1.jsp
650) this.width=650; "src=" http://s2.51cto.com/wyfs02/M02/8B/60/wKiom1hK0XLh8OPrAADPYs04lcA088.jpg "title=" t5.jpg "alt=" Wkiom1hk0xlh8opraadpys04lca088.jpg "/>
testing on the Windows client :
In C:\Windows\System32\drivers\etc\hosts designation: 10.0.0.10 www.7_linux.com;
Open ie:
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/8B/5C/wKioL1hK1HyhD-aQAADVrJragy8414.jpg "title=" t6.jpg "alt=" Wkiol1hk1hyhd-aqaadvrjragy8414.jpg "/>
Simply configure the application, if you want to know more, please consult the relevant information.
2016-12-09 23:59 Friday
This article is from the "Cbo#boy_linux Road" blog, make sure to keep this source http://20151213start.blog.51cto.com/9472657/1881385
Linux Tomcat Installation & configuration & Optimization