Installing Tomcat under LIUNX environment

Source: Internet
Author: User

First: Download the Tomcat installation package



Second: Download the version of the installation package

Three: Unzip the installation package and configure the relevant environment variable information
"#1" Copy the Tomcat package apache-tomcat-7.0.68.tar.gz to the installation directory/opt/tomcat/directory
"#2" unzip the package with the tar command: TAR-ZXVF apache-tomcat-7.0.68.tar.gz
"#3" Tomcat requires a JDK, so you need to configure the JDK before installing Tomcat, and then configure the Tomcat environment variable directory as follows:
Export java_home=/usr/java/jdk/jdk1.6.0_45
Export Java_bin=/usr/java/jdk/jdk1.6.0_45/bin
Export path= $PATH: $JAVA _home/bin
Export classpath=.: $JAVA _home/lib/dt.jar: $JAVA _home/lib/tools.jar
Export Java_home java_bin PATH CLASSPATH

Export maven_home=/usr/java/maven/apache-maven-3.0.3
Export Maven_home
Export Path=${path}:${maven_home}/bin

Export catalina_base=/opt/tomcat/apache-tomcat-7.0.68
Export catalina_home=/opt/tomcat/apache-tomcat-7.0.68
"#4" Enter the directory/opt/tomcat/apache-tomcat-7.0.68/bin, run the command./startup.sh (boot tomcat), output as follows:
Using catalina_base:/opt/tomcat/apache-tomcat-7.0.68
Using Catalina_home:/opt/tomcat/apache-tomcat-7.0.68
Using Catalina_tmpdir:/opt/tomcat/apache-tomcat-7.0.68/temp
Using Jre_home:/usr/java/jdk/jdk1.6.0_45
Using CLASSPATH:/opt/tomcat/apache-tomcat-7.0.68/bin/bootstrap.jar:/opt/tomcat/apache-tomcat-7.0.68/bin/ Tomcat-juli.jar
Tomcat started.
Prove that Tomcat has started.
"#5" in the browser input localhost:8080 can enter the Tomcat home page.
"#6" under the/opt/tomcat/apache-tomcat-7.0.68/bin directory, run the command./shutdown.sh (turn tomcat off)

Four: The structure and significance of the Tomcat directory and related configuration
Test Tomcat:
Open the firewall to allow external access
#/sbin/iptables-i input-p TCP--dport 8080-j ACCEPT
# Service Iptables Save
# Service Iptables Restart
or directly modify the file/etc/sysconfig/iptables.
# Vi/etc/sysconfig/iptables
-A input-p tcp-m tcp--dport 8080-j ACCEPT
# Service Iptables Restart
In the browser input: http://192.168.16.133:8080
As can be entered in this machine: http://localhost:8080
The page that appears Tomcat indicates that the installation was successful.


Stop Tomcat
#./shutdown.sh


4. Configure the Web Admin account
To modify the file Conf/tomcat-users.xml, add the account password to the <tomcat-users> element, you need to specify the role.
# Vi/usr/local/tomcat/server/conf/tomcat-users.xml
<tomcat-users>
<user name= "admin" password= "admin" roles= "Admin-gui,manager-gui"/>
</tomcat-users>


5. Configure the Web Access port
You can modify the file Server.xml in the Conf directory, modify the connector element (the default port for Tomcat is 8080) and need to restart the Tomcat service to take effect.
# Vi/usr/local/tomcat/server/conf/server.xml
<connector port= "protocol=" http/1.1 "connectiontimeout=" 20000 "redirectport=" 8443 "/>


6. Configure HTTPS secure connection (SSL encrypted connection)
A digital certificate and digital signature (MD5 algorithm) is required for HTTPS connections
Web site HTTPS connection first need to request a digital certificate, configure the encryption connector, browser installation certificate.
• Use Java tools Keytool to generate digital certificates
# Keytool-genkey-alias Tomcat-keyalg RSA
Generate files. KeyStore
Note: CN is the host name, localhost can be used natively
• Put the file. KeyStore into the Conf directory of the Tomcat server
# CP. keystore/usr/local/tomcat/server/conf/
• Modify the Conf/server.xml file, modify the encryption connector, add Keystorefile and Keystorepass
<connector port= "8443" protocol= "http/1.1" sslenabled= "true"
maxthreads= "Scheme=" "https" secure= "true"
Clientauth= "false" sslprotocol= "TLS"
Keystorefile= "Conf/.keystore" keystorepass= "123456"/>
• Restart Tomcat. The browser enters https://localhost:8443 access and installs the certificate.


Directory Structure of 7.Tomcat
bin//Command script file to store tomcat
conf//Storage of various configuration files for Tomcat server, mostly Server.xml
Lib//store Tomcat Server support Jar package
logs//storing log files
Temp//Storing temporary files
webapps//web application directory, external access to Web Resources storage directory
Working directory of work//tomcat


Directory structure for 8.web applications
WebApp--The directory where the Web application resides
|---html, JSP, CSS, JS files, etc.-these files are generally in the root directory of the Web application, the files under the root directory can be directly accessed by the outside world.
|---web-inf directory-java classes, JAR packages, Web configuration files exist in this directory, the outside world is not directly accessible, the WEB server is responsible for the call.
|---Classes Directory--Java class
|---lib directory--the jar package required for Java classes to run
|---web. xml file--configuration file


9. Configuration of the virtual host
Specify the virtual hostname, modify Conf/server.xml, add <context path= "/webapp" docbase= "/webapps/webapp"/>
Cases:
You must set up DNS resolution (host file or DNS system).




Mapping of 10.web applications and virtual directories.
You can modify the <Context> elements of an XML configuration file to set up mappings for Web apps and virtual directories.
conf/server.xml//Add <context path= "/webdir" docbase= "/webappdir"/&gt under the conf/context.xml//Add <Context> elements All Web apps are valid.
Conf/[enginename]/[hostname]/context.xml.default//[enginename] is generally Catalina, and all Web applications of the host [hostname] are valid.
conf/[enginename]/[hostname]///Create a file (extension XML) in the directory, and the file name is the virtual directory name. The multi-level directory uses # segmentation. <context docbase= "/webappdir"/>
The default Web App catalog can be defined as Root.xml, add <context docbase= "/webappdir"/&gt, and restart the Tomcat server.
· Meta-inf/context.xml//
The Web application can be placed in the WebApps directory for the Tomcat server to automatically map, suitable for the development environment, the actual use of the environment without automatic mapping.
If the configuration file is not modified, the Web App directory is the default Web app when it is rooted.


11.web Application Home Page (welcome file) configuration
To modify a WEB app's configuration file: [Webapp]/web-inf/web.xml
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>



Installing tomcat under a liunx environment

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.