Linux Tomcat7.0 Installation Configuration Practice Summary

Source: Internet
Author: User
Tags tomcat server

One, install the JDK

    1. 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.

    2. Unzip the JDK, move and rename it.
      TAR-ZXVF jdk-8u31-linux-i586.tar.gz
      MV Jdk1.8.0_31/usr/local

    3. 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

    1. 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
    2. TAR-ZXVF apache-tomcat-7.0.70.tar.gz MV Apache-tomcat-7.0.70/usr/local/tomcat
    3. Vi/etc/profile add Tomcat_home=/usr/local/tomcat source/etc/profile to make it effective
    4. Verify the above variables, echo $TOMCAT _home
    5. Cd/usr/local/tomcat
    6. Start Tomcat bin/startup.sh
    7. 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

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.