System environment: centos 6.3 64bit IP: 192.168.1.108
Tomcat: apache-tomcat-6.0.28.tar.gz
Jdk Version: jdk-6u18-linux-x64-rpm.bin (requires registration download)
Tomcat source package: wget-c http://archive.apache.org/dist/tomcat/tomcat-6/v6.0.28/bin/apache-tomcat-6.0.28.tar.gz
JDK binary code package: http://www.oracle.com/technetwork/java/javasebusiness/downloads/java-archive-downloads-javase6-419409.html
1. Install JDK
Place the jdk package
# Cd/usr/local/src/
# Chmod 755 jdk-6u18-linux-x64-rpm.bin
#./Jdk-6u18-linux-x64-rpm.bin
Enter yes in the middle
Click enter once
Configure environment variables: cp/etc/profile. bak // backup
Vim/etc/profile
Add at the end:
Export JAVA_HOME =/usr/java/jdk1.6.0 _ 18 export JAVA_BIN =/usr/java/jdk1.6.0 _ 18/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 CLASSPAT
Make it take effect: source/etc/profile
Test whether JDK works properly:
[[Email protected] src] # java-versionjava version "1.6.0 _ 24" OpenJDK Runtime Environment (IcedTea6 1.11.1) (rhel-1.45.1.11.1.el6-x86_64) OpenJDK 64-Bit Server VM (build between 0-b12, mixed mode)
2. Install tomcat
# Cd/usr/local/src/
# Tar zxvf apache-tomcat-6.0.28.tar.gz-C/usr/local/
# Cd/usr/local/
# Mv apache-tomcat-6.0.28 tomcat
Start tomcat:
1./usr/local/tomcat/bin/startup. sh>/dev/null 2 <& 1 &
Stop tomcat:
2./usr/local/tomcat/bin/shutdown. sh
Test: The startup is complete. Check the tomcat process to make sure it starts properly:
# Ps aux | grep javaroot 13231 15.0 16.5 2150360 82116 pts/0 Sl 01/usr/local/jdk1.8.0 _ 11/jre/bin/java-Djava. util. logging. config. file =/usr/local/tomcat/conf/logging. properties-Djava. util. logging. manager = org. apache. juli. classLoaderLogManager-Djava. endorsed. dirs =/usr/local/tomcat/endorsed-classpath/usr/local/tomcat/bin/bootstrap. jar:/usr/local/tomcat/bin/tomcat-juli.jar-Dcatalina. base =/usr/local/tomcat-Dcatalina. home =/usr/local/tomcat-Djava. io. tmpdir =/usr/local/tomcat/temp org. apache. catalina. startup. bootstrap startroot 13262 0.0 0.1 112656 988 pts/0 R + grep -- color = auto java
3. Enable port 8080 of the firewall:
# Iptables-I INPUT-p tcp-m multiport -- dport 80, 8080-j ACCEPT
Enter http: // 192.168.1.141: 8080/the following tomcat test page in the browser:
Test:
In Linux:
# Curl-I localhost: 8080 HTTP/1.1 200 OKServer: Apache-Coyote/1.1Content-Type: text/html; charset = UTF-8Transfer-Encoding: chunkedDate: Mon, 28 Jul 2014 23:16:27 GMT
4. Client test:
1. vim/usr/local/tomcat/webapps/ROOT/test. jsp
2. The time is <% = new java. util. Date () %>
It indicates that the test is successful in the browser.
So far! Tomcat environment setup is complete. Next we will briefly understand the roles of the directories under the tomcat root directory:
Details:
Bin: Some executable script files are stored in this directory. tomcat startup and shutdown are all stored in this file.
Conf: The Directory stores tomcat configuration files, such as the server. xml tomcat-user.xml
Lib: the directory to be bought stores some tomcat library files.
Log: log Directory
Temp: temporary file directory
Webapps: application file storage directory, such as war jsp. (if tomcat is deployed and you do not want to access tomcat by default, you only need to rename or delete the root directory in this directory, redeploy the new application here)
Work:
The webapps directory corresponding to some topics on the tomcat test homepage is as follows:
650) this. width = 650; "width =" 600 "class =" zoom "id =" aimg_1129 "alt =" 175633kx6rxzlx0x69jorx.jpg "src =" http://www.linuser.com/data/attachment/forum/201408/06/175633kx6rxzlx0x69jorx.jpg "/>
Note: There are two configuration files in the conf directory that need to be highlighted:
Server. xml: this is the main configuration file of tomcat. It contains the port, domain name, IP address, and virtual host configuration;
Tomcat-users.xml: This file is mainly for tomcat management configuration, such as login manager, view the server running status, the premise is to define users and groups in the file, etc.
First let's look at the tomcat-users.xml file, which is commented out almost all, as follows:
[[Email protected] webapps] # cat./conf/tomcat-users.xml <? Xml version = '1. 0' encoding = 'utf-8'?> <! -- Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. see the NOTICE file distributed with this work for additional information regarding copyright ownership. the ASF licenses this file to You under the Apache License, Version 2.0 (the "License"); you may not use this file License T in compliance with the License. you may obtain a copy of the License Http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "as is" BASIS, without warranties or conditions of any kind, either express or implied. see the License for the specific language governing permissions and limitations under the License. --> <tomcat-users> # define user information labels <! -- NOTE: By default, no user is authorized in the "manager-gui" role required to operate the "/manager/html" web application. if you wish to use this app, you must define such a user-the username and password are arbitrary. --> <! -- NOTE: The sample user and role entries below are wrapped in a comment and thus are ignored when reading this file. Do not forget to remove <!.. ...> That surrounds them. --> <! -- <Role rolename = "tomcat"/> <role rolename = "role1"/> <user username = "tomcat" password = "tomcat" roles = "tomcat"/> <user username = "both" password = "tomcat" roles = "tomcat, role1 "/> <user username =" role1 "password =" tomcat "roles =" role1 "/> --> <role rolename =" manager-gui "/> <user username = "silence" password = "tomcat" roles = "manager-gui"/> </tomcat-users>
If you do not modify the file, log on to the manager from the tomcat homepage. A logon box is displayed, asking you to enter the logon account password.
650) this. width = 650; "width =" 600 "class =" zoom "id =" aimg_1130 "alt =" 175647thf1jo732fhb6lcb.jpg "src =" http://www.linuser.com/data/attachment/forum/201408/06/175647thf1jo732fhb6lcb.jpg "/>
3. jpg (664.62 KB, Downloads: 0)
Download attachment
Upload
We cannot log in because the default tomcat-users.xm file is not configured. Click Cancel or close the login box. A prompt page is displayed, showing how to configure verification information:
650) this. width = 650; "width =" 600 "class =" zoom "id =" aimg_1131 "alt =" 175658qrju6ugyhgxpjhhx.jpg "src =" http://www.linuser.com/data/attachment/forum/201408/06/175658qrju6ugyhgxpjhhx.jpg "/>
In order to log on smoothly, let's modify the tomcat-users.xml file and add in the middle of <tomcat-users>... </tomcat-users>:
<Role rolename = "manager"/> # define the manager Group <user username = "admin" password = "admin" roles = "manager"/> # define the user name and password, add admin to manager
In order to log on smoothly, let's modify the tomcat-users.xml file and add in the middle of <tomcat-users>... </tomcat-users>:
<Role rolename = "manager"/> <role rolename = "admin"/> <user username = "admin" password = "admin" roles = "manager, admin"/>
Restart tomcat:
[[Email protected] webapps] #/usr/local/tomcat/bin/shutdown. sh Using CATALINA_BASE:/usr/local/tomcatUsing CATALINA_HOME:/usr/local/tomcatUsing CATALINA_TMPDIR:/usr/local/tomcat/tempUsing JRE_HOME: /usr/local/jdk1.8.0 _ 11/jreUsing CLASSPATH:/usr/local/tomcat/bin/bootstrap. jar:/usr/local/tomcat/bin/tomcat-juli.jar
[[Email protected] webapps] #/usr/local/tomcat/bin/startup. sh Using CATALINA_BASE:/usr/local/tomcatUsing CATALINA_HOME:/usr/local/tomcatUsing CATALINA_TMPDIR:/usr/local/tomcat/tempUsing JRE_HOME: /usr/local/jdk1.8.0 _ 11/jreUsing CLASSPATH:/usr/local/tomcat/bin/bootstrap. jar:/usr/local/tomcat/bin/tomcat-juli.jarTomcat started.
This article is from the "David 0512" blog, please be sure to keep this source http://gjr0512.blog.51cto.com/6518687/1573049
Tomcat6.0.28 configuration in centos