One, install the JDK
- Download the JDK first, link http://www.oracle.com/technetwork/java/javase/downloads/index.html, and select the JDK that corresponds to the platform.
Because the author system is 32-bit, so I download the package is jdk-8u31-linux-i586.tar.gz.
- Unzip the JDK, move and rename it.
TAR-ZXVF jdk-8u31-linux-i586.tar.gz
MV Jdk1.8.0_31/usr/local
- Edit the environment variable, define Java_home CLASSPATH, and append java_bin to the environment variable.
vim/etc/profile.d/java.sh
Export java_home=/usr/local/jdk1.8.0_31/
Export Classpath=/usr/local/jdk1.8.0_31/lib
Export path= $PATH: $JAVA _home/bin
Let it take effect immediately, source/etc/profile
Check whether the environment configuration is Ok,echo $JAVE _home; echo $CLASSPATH; Echo $PATH
View Java version java-version
Two, install Tomcat
- CD/USR/LOCAL/SRC wget http://mirror.bit.edu.cn/apache/tomcat/tomcat-7/v7.0.70/bin/apache-tomcat-7.0.70.tar.gz
- TAR-ZXVF apache-tomcat-7.0.70.tar.gz MV Apache-tomcat-7.0.70/usr/local/tomcat
- Vi/etc/profile add Tomcat_home=/usr/local/tomcat source/etc/profile to make it effective
- Verify the above variables, echo $TOMCAT _home
- Cd/usr/local/tomcat
- Start Tomcat bin/startup.sh
- PS Aux|grep Tomcat to see if there is a process, Netstat-lnp|grep Java to view the process port (specifically, Tomcat is calling Java, so the process shown is Java), you can see that the port number is 8080.
TCP 0 0::: 8080:::* LIST EN 12199/java
8. Turn off Tomcat bin/shutdown.sh
Third, configure the Tomcat startup script
Cd/usr/local/tomcat/bin CP Bin/catalina.sh/etc/init.d/tomcat Vi/etc/init.d/tomcat
Add the following lines under #!/bin/bash:
#chkconfig: 345 23 77
#description: Tomcat Server #Source function library
. /etc/init.d/functions
Java_home=/usr/local/jdk1.8.0_31
Catalina_home=/usr/local/tomcat//Save and exit
Chkconfig--add Tomcat//Join the Service list
chmod 755 Tomcat
Chkconfig tomcat on//boot auto start
/etc/init.d/tomcat Start//Startup Tocat Service
In addition, Tomcat does not support restart restart, if you want to restart it, you need to close it first, and then start, that is,/etc/init.d/tomcat stop/etc/init.d/tomcat start.
Four, modify the Tomcat default port
Cd/usr/local/tomcat/conf
VI server.xml Search 8080, find the following section configuration
Change 8080 to 80 and restart the Tomcat service when you're done.
Five, add a virtual host to Tomcat,
1,vi Server.xml, find
Host name= "www.test.com" appbase= "/data/tomcatweb"
Unpackwars= "false" autodeploy= "true"
Xmlvalidation= "false" Xmlnamespaceaware= "false" >
<context path= "" docbase= "./" debug= "0" reloadable= "true" crosscontext= "true"/>
</Host>
,
Save exit, close Tocat, and start Tomcat.
2, create AppBase mkdir-p/data/tomcatweb
Vi/data/tomcatweb/index.jsp (Write a time function for Java)
Save exit.
3, test curl-x localhost:80 www.test.com
Shown below:
Now time Is:sun 06:42:07 CST 2016
</center></body>
Linux Tomcat7.0 Installation Configuration Practice Summary