安装tomcat
[root@node200 ~]# ls
anaconda-ks.cfg apr-util-1.4.1.tar.bz2 install.log.syslog 模板 下载
apache-tomcat-8.0.30.tar.gz epel-release-latest-6.noarch.rpm jdk-7u67-linux-x64.rpm 视频 音乐
apr-1.4.6 httpd-2.4.6.tar.bz2 mariadb-10.0.10-linux-x86_64.tar.gz 图片 桌面
apr-1.4.6.tar.bz2 install.log 公共的 文档
[root@node200 ~]# yum info tomcat
已加载插件:fastestmirror, refresh-packagekit, security
Determining fastest mirrors
epel/metalink | 5.2 kB 00:00
* base: mirrors.btte.net
* epel: mirrors.opencas.cn
* extras: mirrors.163.com
* updates: mirrors.163.com
base | 3.7 kB 00:00
extras | 3.4 kB 00:00
updates | 3.4 kB 00:00
可安装的软件包
Name : tomcat
Arch : noarch
Version : 7.0.33
Release : 4.el6
Size : 86 k
Repo : epel
Summary : Apache Servlet/JSP Engine, RI for Servlet 3.0/JSP 2.2 API
URL : http://tomcat.apache.org/
License : ASL 2.0
Description : Tomcat is the servlet container that is used in the
: official Reference Implementation for the Java Servlet and
: JavaServer Pages technologies. The Java Servlet and
: JavaServer Pages specifications are developed by Sun under
: the Java Community Process.
:
: Tomcat is developed in an open and participatory
: environment and released under the Apache Software License
: version 2.0. Tomcat is intended to be a collaboration of
: the best-of-breed developers from around the world.
[root@node200 ~]# rpm -ivh jdk-7u67-linux-x64.rpm
[root@node200 ~]# rpm -ql jdk
/usr/java/jdk1.7.0_67/man/man1/jps.1
/usr/java/jdk1.7.0_67/man/man1/jrunscript.1
/usr/java/jdk1.7.0_67/man/man1/jsadebugd.1
/usr/java/jdk1.7.0_67/man/man1/jstack.1
/usr/java/jdk1.7.0_67/man/man1/jstat.1
/usr/java/jdk1.7.0_67/man/man1/jstatd.1
/usr/java/jdk1.7.0_67/man/man1/jvisualvm.1
/usr/java/jdk1.7.0_67/man/man1/keytool.1
/usr/java/jdk1.7.0_67/man/man1/native2ascii.1
/usr/java/jdk1.7.0_67/man/man1/orbd.1
/usr/java/jdk1.7.0_67/man/man1/pack200.1
/usr/java/jdk1.7.0_67/man/man1/policytool.1
/usr/java/jdk1.7.0_67/man/man1/rmic.1
/usr/java/jdk1.7.0_67/man/man1/rmid.1
/usr/java/jdk1.7.0_67/man/man1/rmiregistry.1
/usr/java/jdk1.7.0_67/man/man1/schemagen.1
/usr/java/jdk1.7.0_67/man/man1/serialver.1
/usr/java/jdk1.7.0_67/man/man1/servertool.1
/usr/java/jdk1.7.0_67/man/man1/tnameserv.1
/usr/java/jdk1.7.0_67/man/man1/unpack200.1
/usr/java/jdk1.7.0_67/man/man1/wsgen.1
/usr/java/jdk1.7.0_67/man/man1/wsimport.1
/usr/java/jdk1.7.0_67/man/man1/xjc.1
/usr/java/jdk1.7.0_67/release
/usr/java/jdk1.7.0_67/src.zip
[root@node200 ~]# cd /usr/java/
[root@node200 java]# ls
default jdk1.7.0_67 latest
[root@node200 java]# ll
总用量 4
lrwxrwxrwx. 1 root root 16 12月 11 20:40 default -> /usr/java/latest
drwxr-xr-x. 8 root root 4096 12月 11 20:40 jdk1.7.0_67
lrwxrwxrwx. 1 root root 21 12月 11 20:40 latest -> /usr/java/jdk1.7.0_67
[root@node200 java]# cd jdk1.7.0_67/
[root@node200 jdk1.7.0_67]# ls
bin lib src.zip
COPYRIGHT LICENSE THIRDPARTYLICENSEREADME-JAVAFX.txt
db man THIRDPARTYLICENSEREADME.txt
include README.html
jre release
[root@node200 jdk1.7.0_67]# cd bin
[root@node200 bin]# ls
appletviewer javafxpackager jinfo jvisualvm serialver
apt javah jmap keytool servertool
ControlPanel javap jmc native2ascii tnameserv
extcheck java-rmi.cgi jmc.ini orbd unpack200
idlj javaws jps pack200 wsgen
jar jcmd jrunscript policytool wsimport
jarsigner jconsole jsadebugd rmic xjc
java jcontrol jstack rmid
javac jdb jstat rmiregistry
javadoc jhat jstatd schemagen
配置环境变量
[root@node200 jdk1.7.0_67]# vim /etc/profile.d/java.sh
1 export JAVA_HOME=/usr/java/latest
2 export PATH=$JAVA_HOME/bin:$PATH
[root@node200 profile.d]# . /etc/profile.d/java.sh
查看
[root@node200 profile.d]# java
用法: java [-options] class [args...]
(执行类)
或 java [-options] -jar jarfile [args...]
(执行 jar 文件)
其中选项包括:
-d32 使用 32 位数据模型 (如果可用)
-d64 使用 64 位数据模型 (如果可用)
-server 选择 "server" VM
默认 VM 是 server.
-cp <目录和 zip/jar 文件的类搜索路径>
-classpath <目录和 zip/jar 文件的类搜索路径>
用 : 分隔的目录, JAR 档案
和 ZIP 档案列表, 用于搜索类文件。
-D<名称>=<值>
设置系统属性
-verbose:[class|gc|jni]
启用详细输出
-version 输出产品版本并退出
-version:<值>
需要指定的版本才能运行
-showversion 输出产品版本并继续
-jre-restrict-search | -no-jre-restrict-search
在版本搜索中包括/排除用户专用 JRE
-? -help 输出此帮助消息
-X 输出非标准选项的帮助
-ea[:<packagename>...|:<classname>]
-enableassertions[:<packagename>...|:<classname>]
按指定的粒度启用断言
-da[:<packagename>...|:<classname>]
-disableassertions[:<packagename>...|:<classname>]
禁用具有指定粒度的断言
-esa | -enablesystemassertions
启用系统断言
-dsa | -disablesystemassertions
禁用系统断言
-agentlib:<libname>[=<选项>]
加载本机代理库 <libname>, 例如 -agentlib:hprof
另请参阅 -agentlib:jdwp=help 和 -agentlib:hprof=help
-agentpath:<pathname>[=<选项>]
按完整路径名加载本机代理库
-javaagent:<jarpath>[=<选项>]
加载 Java 编程语言代理, 请参阅 java.lang.instrument
-splash:<p_w_picpathpath>
使用指定的图像显示启动屏幕
有关详细信息, 请参阅 http://www.oracle.com/technetwork/java/javase/documentation/index.html。
[root@node200 profile.d]# java -version
java version "1.7.0_67"
Java(TM) SE Runtime Environment (build 1.7.0_67-b01)
Java HotSpot(TM) 64-Bit Server VM (build 24.65-b04, mixed mode)
安装tomcat
[root@node200 ~]# tar xf apache-tomcat-8.0.30.tar.gz -C /usr/local
[root@node200 ~]# cd /usr/local/
[root@node200 local]# ls
apache-tomcat-8.0.30 etc include lib64 sbin src
bin games lib libexec share
[root@node200 local]# ln -sv apache-tomcat-8.0.30 tomcat
"tomcat" -> "apache-tomcat-8.0.30"
[root@node200 local]# ll
总用量 44
drwxr-xr-x. 9 root root 4096 12月 11 21:29 apache-tomcat-8.0.30
drwxr-xr-x. 2 root root 4096 9月 23 2011 bin
drwxr-xr-x. 2 root root 4096 9月 23 2011 etc
drwxr-xr-x. 2 root root 4096 9月 23 2011 games
drwxr-xr-x. 2 root root 4096 9月 23 2011 include
drwxr-xr-x. 2 root root 4096 9月 23 2011 lib
drwxr-xr-x. 2 root root 4096 9月 23 2011 lib64
drwxr-xr-x. 2 root root 4096 9月 23 2011 libexec
drwxr-xr-x. 2 root root 4096 9月 23 2011 sbin
drwxr-xr-x. 5 root root 4096 8月 25 22:04 share
drwxr-xr-x. 2 root root 4096 9月 23 2011 src
lrwxrwxrwx. 1 root root 20 12月 11 21:30 tomcat -> apache-tomcat-8.0.30
[root@node200 tomcat]# ls
bin lib logs RELEASE-NOTES temp work
conf LICENSE NOTICE RUNNING.txt webapps
变量:
[root@node200 tomcat]# vim /etc/profile.d/tomcat.sh
1 export CATALINA_HOME=/usr/local/tomcat
2 export PATH=$CATALINA_HOME/bin:$PATH
[root@node200 tomcat]# . /etc/profile.d/tomcat.sh
[root@node200 bin]# version.sh
Using CATALINA_BASE: /usr/local/tomcat
Using CATALINA_HOME: /usr/local/tomcat
Using CATALINA_TMPDIR: /usr/local/tomcat/temp
Using JRE_HOME: /usr/java/latest
Using CLASSPATH: /usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/bin/tomcat-juli.jar
Server version: Apache Tomcat/8.0.30
Server built: Dec 1 2015 22:30:46 UTC
Server number: 8.0.30.0
OS Name: Linux
OS Version: 2.6.32-573.el6.x86_64
Architecture: amd64
JVM Version: 1.7.0_67-b01
JVM Vendor: Oracle Corporation
[root@node200 bin]# catalina.sh version
Using CATALINA_BASE: /usr/local/tomcat
Using CATALINA_HOME: /usr/local/tomcat
Using CATALINA_TMPDIR: /usr/local/tomcat/temp
Using JRE_HOME: /usr/java/latest
Using CLASSPATH: /usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/bin/tomcat-juli.jar
Server version: Apache Tomcat/8.0.30
Server built: Dec 1 2015 22:30:46 UTC
Server number: 8.0.30.0
OS Name: Linux
OS Version: 2.6.32-573.el6.x86_64
Architecture: amd64
JVM Version: 1.7.0_67-b01
JVM Vendor: Oracle Corporation
[root@node200 bin]# ss -tan
State Recv-Q Send-Q Local Address:Port Peer Address:Port
LISTEN 0 128 :::22 :::*
LISTEN 0 128 *:22 *:*
LISTEN 0 128 127.0.0.1:631 *:*
LISTEN 0 128 ::1:631 :::*
LISTEN 0 100 ::1:25 :::*
LISTEN 0 100 127.0.0.1:25 *:*
LISTEN 0 128 127.0.0.1:6010 *:*
LISTEN 0 128 ::1:6010 :::*
LISTEN 0 128 127.0.0.1:6011 *:*
LISTEN 0 128 ::1:6011 :::*
ESTAB 0 0 192.168.112.200:22 192.168.112.1:54683
ESTAB 0 0 192.168.112.200:22 192.168.112.1:63163
[root@node200 bin]# catalina.sh start
[root@node200 bin]# ss -tanlp |grep 8080
LISTEN 0 100 :::8080 :::* users:(("java",3103,43))
访问页面
配置文件
[root@node200 tomcat]# vim conf/server.xml
创建访问页面
[root@node200 webapps]# pwd
/usr/local/tomcat/webapps
[root@node200 webapps]# mkdir testapp
[root@node200 webapps]# mkdir testapp/{WEB-INF,META-INF,classes,lib}
[root@node200 webapps]# ls testapp/
classes lib META-INF WEB-INF
[root@node200 webapps]# tree testapp/
testapp/
├── classes
├── lib
├── META-INF
└── WEB-INF
[root@node200 webapps]# vim testapp/index.jsp
1 <%@ page language="java" %>
2 <%@ page import="java.util.*" %>
3 <html>
4 <head>
5 <title>JSP test page.</title>
6 </head>
7 <body>
8 <% out.println("Hello,world!"); %>
9 </body>
10 </html>
[root@node200 tomcat]# tree work/
work/
└── Catalina
└── localhost
├── docs
├── examples
├── host-manager
├── manager
├── ROOT
│?? └── org
│?? └── apache
│?? └── jsp
│?? ├── index_jsp.class
│?? └── index_jsp.java
└── testapp
└── org
└── apache
└── jsp
├── index_jsp.class
└── index_jsp.java
[root@node200 tomcat]# cd work/Catalina/localhost/testapp/org/apache/jsp/
[root@node200 jsp]# ls
index_jsp.class index_jsp.java
[root@node200 jsp]# vim index_jsp.java------将index.jsp通过jesfer编译成java
111 out.write("\n");
112 out.write("\n");
113 out.write("<html>\n");
114 out.write(" <head>\n");
115 out.write(" <title>JSP test page.</title>\n");
116 out.write(" </head>\n");
117 out.write(" <body>\n");
118 out.write(" ");
119 out.println("Hello,world!");
120 out.write("\n");
121 out.write(" </body>\n");
122 out.write("</html>\n");
123 } catch (java.lang.Throwable t) {
124 if (!(t instanceof javax.servlet.jsp.SkipPageExcepti on)){
125 out = _jspx_out;
126 if (out != null && out.getBufferSize() != 0)
127 try {
128 if (response.isCommitted()) {
129 out.flush();
130 } else {
131 out.clearBuffer();
132 }
133 } catch (java.io.IOException e) {}
[root@node200 jsp]# vim index_jsp.class---------将index.jsp编译成类文件,执行
修改文件路径
[root@node200 apache]# cd /usr/local/tomcat/conf/
[root@node200 conf]# cp server.xml{,.bak}
[root@node200 conf]# ls
Catalina logging.properties tomcat-users.xsd
catalina.policy server.xml web.xml
catalina.properties server.xml.bak
context.xml tomcat-users.xml
[root@node200 conf]# vim server.xml----增加新的虚拟主机
141 <Host name="node200.zye.com" appBase="/webapps/zye.edu"
142 unpackWARs="true" autoDeploy="true">
143 <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
144 prefix="zye_com_access_log" suffix=".txt"
145 pattern="%h %l %u %t "%r" %s %b" />
146 </Host>
[root@node200 logs]# cat localhost_access_log.2015-12-11.txt
192.168.112.1 - - [11/Dec/2015:22:08:51 +0800] "GET / HTTP/1.1" 200 11250
192.168.112.1 - - [11/Dec/2015:22:08:51 +0800] "GET /tomcat.png HTTP/1.1" 200 5103
192.168.112.1 - - [11/Dec/2015:22:08:51 +0800] "GET /tomcat.css HTTP/1.1" 200 5576
192.168.112.1 - - [11/Dec/2015:22:08:51 +0800] "GET /bg-nav.png HTTP/1.1" 200 1401
192.168.112.1 - - [11/Dec/2015:22:08:51 +0800] "GET /asf-logo.png HTTP/1.1" 200 17811
192.168.112.1 - - [11/Dec/2015:22:08:51 +0800] "GET /bg-button.png HTTP/1.1" 200 713
192.168.112.1 - - [11/Dec/2015:22:08:51 +0800] "GET /bg-middle.png HTTP/1.1" 200 1918
192.168.112.1 - - [11/Dec/2015:22:08:51 +0800] "GET /bg-upper.png HTTP/1.1" 200 3103
192.168.112.1 - - [11/Dec/2015:22:08:52 +0800] "GET /favicon.ico HTTP/1.1" 200 21630
[root@node200 conf]# mkdir -pv /webapps/zye.edu/{WEB-INF,classes,lib,META-INF}
mkdir: 已创建目录 "/webapps"
mkdir: 已创建目录 "/webapps/zye.edu"
mkdir: 已创建目录 "/webapps/zye.edu/WEB-INF"
mkdir: 已创建目录 "/webapps/zye.edu/classes"
mkdir: 已创建目录 "/webapps/zye.edu/lib"
mkdir: 已创建目录 "/webapps/zye.edu/META-INF"
[root@node200 conf]# vim /webapps/zye.edu/index.jsp
1 <%@ page language="java" %>
2 <%@ page import="java.util.*" %>
3 <html>
4 <head>
5 <title>JSP test page.</title>
6 </head>
7 <body>
8 <% out.println("Hello,zye!"); %>
9 </body>
10 </html>
[root@node200 conf]# catalina.sh stop
Using CATALINA_BASE: /usr/local/tomcat
Using CATALINA_HOME: /usr/local/tomcat
Using CATALINA_TMPDIR: /usr/local/tomcat/temp
Using JRE_HOME: /usr/java/latest
Using CLASSPATH: /usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/bin/tomcat-juli.jar
[root@node200 conf]# catalina.sh start
Using CATALINA_BASE: /usr/local/tomcat
Using CATALINA_HOME: /usr/local/tomcat
Using CATALINA_TMPDIR: /usr/local/tomcat/temp
Using JRE_HOME: /usr/java/latest
Using CLASSPATH: /usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/bin/tomcat-juli.jar
Tomcat started.
[root@node200 zye.edu]# mv classes/ index.jsp lib/ META-INF/ WEB-INF/ ROOT/
重新创建一个虚拟主机
[root@node200 ~]# cd /usr/local/tomcat/conf/
[root@node200 conf]# vim server.xml---添加
148 <Host name="www.zye.com" appBase="/webapps/jcenter/"
149 unpackWARs="true" autoDeploy="true">
150 <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
151 prefix="www_zye_com_access_log" suffix=".txt"
152 pattern="%h %l %u %t "%r" %s %b" />
153 </Host>
[root@node200 conf]# yum install mysql-server -y
[root@node200 conf]# service mysqld start
[root@node200 ~]# ls
anaconda-ks.cfg apr-1.4.6.tar.bz2 httpd-2.4.6.tar.bz2 JavaCenter_Home_2.0_GBK.tar.bz2 公共的 图片 音乐
apache-tomcat-8.0.30.tar.gz apr-util-1.4.1.tar.bz2 install.log jdk-7u67-linux-x64.rpm 模板 文档 桌面
apr-1.4.6 epel-release-latest-6.noarch.rpm install.log.syslog mariadb-10.0.10-linux-x86_64.tar.gz 视频 下载
[root@node200 ~]# tar xf JavaCenter_Home_2.0_GBK.tar.bz2
[root@node200 ~]# cd JavaCenter_Home_2.0_GBK
[root@node200 JavaCenter_Home_2.0_GBK]# mkdir /webapps/jcenter
[root@node200 JavaCenter_Home_2.0_GBK]# mv ./* /webapps/jcenter/
[root@node200 JavaCenter_Home_2.0_GBK]# cd /webapps/jcenter/
[root@node200 jcenter]# ls
admin p_w_upload cp.jsp editor.jsp p_w_picpath js.jsp network.jsp template xmlrpc.jsp
admincp.jsp avatar.jsp crossdomain.xml errors index.jsp link.jsp rss.jsp theme
api config.properties data favicon.ico install magic.jsp source userapp.jsp
app.jsp contact.jsp do.jsp help.jsp invite.jsp META-INF space.jsp WEB-INF
[root@node200 jcenter]# catalina.sh stop
Using CATALINA_BASE: /usr/local/tomcat
Using CATALINA_HOME: /usr/local/tomcat
Using CATALINA_TMPDIR: /usr/local/tomcat/temp
Using JRE_HOME: /usr/java/latest
Using CLASSPATH: /usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/bin/tomcat-juli.jar
[root@node200 jcenter]# catalina.sh start
Using CATALINA_BASE: /usr/local/tomcat
Using CATALINA_HOME: /usr/local/tomcat
Using CATALINA_TMPDIR: /usr/local/tomcat/temp
Using JRE_HOME: /usr/java/latest
Using CLASSPATH: /usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/bin/tomcat-juli.jar
Tomcat started.
发现错误
[root@node200 logs]# cat www_zye_com_access_log.2015-12-12.txt
192.168.112.1 - - [12/Dec/2015:23:41:31 +0800] "GET / HTTP/1.1" 404 -
192.168.112.1 - - [12/Dec/2015:23:41:32 +0800] "GET /favicon.ico HTTP/1.1" 404 -
192.168.112.1 - - [12/Dec/2015:23:41:36 +0800] "GET /install HTTP/1.1" 302 -
192.168.112.1 - - [12/Dec/2015:23:41:37 +0800] "GET /install/ HTTP/1.1" 500 2897
[root@node200 logs]# cat catalina.out
[root@node200 tomcat]# cd /webapps/
[root@node200 webapps]# ls
jcenter zye.edu
[root@node200 webapps]# cd zye.edu/
[root@node200 zye.edu]# ls
ROOT
[root@node200 zye.edu]# cd ..
[root@node200 webapps]# mv jcenter/ ROOT
[root@node200 webapps]# ls
ROOT zye.edu
[root@node200 webapps]# mkdir jcenter
[root@node200 webapps]# ls
jcenter ROOT zye.edu
[root@node200 webapps]# mv ROOT/ jcenter/
[root@node200 webapps]# ls
jcenter zye.edu
[root@node200 webapps]# ll
总用量 8
drwxr-xr-x. 3 root root 4096 12月 12 23:49 jcenter
drwxr-xr-x. 3 root root 4096 12月 12 03:23 zye.edu
[root@node200 webapps]# ll jcenter/
总用量 4
drwxr-xr-x. 14 root root 4096 12月 12 09:58 ROOT
[root@node200 webapps]# cd jcenter/
[root@node200 jcenter]# ls
ROOT
[root@node200 jcenter]# cd ROOT/
[root@node200 ROOT]# ls
admin p_w_upload cp.jsp editor.jsp p_w_picpath js.jsp network.jsp template xmlrpc.jsp
admincp.jsp avatar.jsp crossdomain.xml errors index.jsp link.jsp rss.jsp theme
api config.properties data favicon.ico install magic.jsp source userapp.jsp
app.jsp contact.jsp do.jsp help.jsp invite.jsp META-INF space.jsp WEB-INF
[root@node200 ROOT]# pwd
/webapps/jcenter/ROOT
[root@node200 ROOT]# vim config.properties
[root@node200 ROOT]# mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.1.73 Source distribution
Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> grant all on *.* to 'root'@'192.168.%.%' identified by 'rootpw';
Query OK, 0 rows affected (0.05 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
为了不让主机名反解
[root@node200 ROOT]# mysql -uroot
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.1.73 Source distribution
Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> show global variables like '%skip%';
+------------------------+-------+
| Variable_name | Value |
+------------------------+-------+
| skip_external_locking | ON |
| skip_name_resolve | OFF |
| skip_networking | OFF |
| skip_show_database | OFF |
| slave_skip_errors | OFF |
| sql_slave_skip_counter | |
+------------------------+-------+
6 rows in set (0.01 sec)
mysql> quit
[root@node200 ROOT]# vim /etc/my.cnf
8 [mysqld_safe]
9 log-error=/var/log/mysqld.log
10 pid-file=/var/run/mysqld/mysqld.pid
11 skip-name-resolve=on
[root@node200 ROOT]# service mysqld restart
停止 mysqld: [确定]
正在启动 mysqld: [确定]
[root@node200 ROOT]# vim config.properties
[root@node200 ROOT]# mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.1.73 Source distribution
Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> set password for 'root'@'localhost' = password('rootpw');
Query OK, 0 rows affected (0.00 sec)
mysql> set password for 'root'@'127.0.0.1' = password('rootpw');
Query OK, 0 rows affected (0.00 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
[root@node200 ROOT]# vim config.properties
下面简单介绍几个常用组件:
1、Server组件-----在本机可以关闭一个jvm实例
[root@node200 ROOT]# ss -tanpl | grep 8005
LISTEN 0 1 ::ffff:127.0.0.1:8005 :::* users:(("java",4261,66))
[root@node200 ROOT]# telnet 127.0.0.1 8005
Trying 127.0.0.1...
Connected to 127.0.0.1.
Escape character is '^]'.
SHUTDOWN
Connection closed by foreign host.
[root@node200 ROOT]# ss -tan
State Recv-Q Send-Q Local Address:Port Peer Address:Port
LISTEN 0 50 *:3306 *:*
LISTEN 0 128 :::22 :::*
LISTEN 0 128 *:22 *:*
LISTEN 0 128 127.0.0.1:631 *:*
LISTEN 0 128 ::1:631 :::*
LISTEN 0 100 ::1:25 :::*
LISTEN 0 100 127.0.0.1:25 *:*
LISTEN 0 128 127.0.0.1:6011 *:*
LISTEN 0 128 ::1:6011 :::*
LISTEN 0 128 127.0.0.1:6012 *:*
LISTEN 0 128 ::1:6012 :::*
ESTAB 0 52 192.168.112.200:22 192.168.112.1:63518
ESTAB 0 0 192.168.112.200:22 192.168.112.1:59100
3、Connector组件:
69 <Connector port="80" protocol="HTTP/1.1"
70 connectionTimeout="20000"
71 redirectPort="8443" />
[root@node200 ROOT]# catalina.sh stop
Using CATALINA_BASE: /usr/local/tomcat
Using CATALINA_HOME: /usr/local/tomcat
Using CATALINA_TMPDIR: /usr/local/tomcat/temp
Using JRE_HOME: /usr/java/latest
Using CLASSPATH: /usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/bin/tomcat-juli.jar
[root@node200 ROOT]# catalina.sh start
Using CATALINA_BASE: /usr/local/tomcat
Using CATALINA_HOME: /usr/local/tomcat
Using CATALINA_TMPDIR: /usr/local/tomcat/temp
Using JRE_HOME: /usr/java/latest
Using CLASSPATH: /usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/bin/tomcat-juli.jar
[root@node200 ROOT]# ss -tanp
State Recv-Q Send-Q Local Address:Port Peer Address:Port
LISTEN 0 100 :::8009 :::* users:(("java",7036,48))
LISTEN 0 50 *:3306 *:* users:(("mysqld",6075,10))
LISTEN 0 100 :::80 :::* users:(("java",7036,43))
重新还原service.xml
[root@node200 conf]# rm -rf server.xml
[root@node200 conf]# mv server.xml.bak server.xml
[root@node200 conf]# ls
Catalina catalina.properties logging.properties tomcat-users.xml web.xml
catalina.policy context.xml server.xml tomcat-users.xsd
[root@node200 conf]# cp server.xml server.xml.bat
[root@node200 conf]# ls
Catalina context.xml server.xml.bat web.xml
catalina.policy logging.properties tomcat-users.xml
catalina.properties server.xml tomcat-users.xsd
[root@node200 conf]# vim server.xml
123 <Host name="localhost" appBase="webapps"
124 unpackWARs="true" autoDeploy="true">
125 <Context path="/shopxx" docBase="shopxx" />
[root@node200 ~]# unzip shopxx-a5-Beta.zip
[root@node200 ~]# ls
anaconda-ks.cfg install.log.syslog 视频
apache-tomcat-8.0.30.tar.gz JavaCenter_Home_2.0_GBK 说明.htm
apr-1.4.6 JavaCenter_Home_2.0_GBK.tar.bz2ls 图片
apr-1.4.6.tar.bz2 jdk-7u67-linux-x64.rpm cd
文档
apr-util-1.4.1.tar.bz2 mariadb-10.0.10-linux-x86_64.tar.gz 下载
connect-web.war shopxx-a5-Beta.zip 音乐
epel-release-latest-6.noarch.rpm shopxx-v3.0-Beta 桌面
httpd-2.4.6.tar.bz2 公共的
install.log 模板
[root@node200 ~]# mv shopxx-v3.0-Beta/shopxx-3.0Beta/ /usr/local/tomcat/webapps/shopxx
[root@node200 ~]# cd /usr/local/tomcat/webapps/shopxx/
[root@node200 shopxx]# ls
admin favicon.ico install META-INF robots.txt upload
changelog.txt index.jsp license.html resources shopxx.txt WEB-INF
[root@node200 tomcat]# catalina.sh stop
Using CATALINA_BASE: /usr/local/tomcat
Using CATALINA_HOME: /usr/local/tomcat
Using CATALINA_TMPDIR: /usr/local/tomcat/temp
Using JRE_HOME: /usr/java/latest
Using CLASSPATH: /usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/bin/tomcat-juli.jar
[root@node200 tomcat]# rm -rf /usr/local/tomcat/work/*
[root@node200 tomcat]# catalina.sh start
Using CATALINA_BASE: /usr/local/tomcat
Using CATALINA_HOME: /usr/local/tomcat
Using CATALINA_TMPDIR: /usr/local/tomcat/temp
Using JRE_HOME: /usr/java/latest
Using CLASSPATH: /usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/bin/tomcat-juli.jar
Tomcat started.
[root@node200 tomcat]# ss -tanl
State Recv-Q Send-Q Local Address:Port Peer Address:Port
LISTEN 0 100 :::8009 :::*
LISTEN 0 50 *:3306 *:*
LISTEN 0 100 :::8080 :::*
LISTEN 0 128 :::22 :::*
LISTEN 0 128 *:22 *:*
LISTEN 0 128 127.0.0.1:631 *:*
LISTEN 0 128 ::1:631 :::*
LISTEN 0 100 ::1:25 :::*
LISTEN 0 100 127.0.0.1:25 *:*
[root@node200 webapps]# cd shopxx/----------没有index.jsp
[root@node200 shopxx]# ll
总用量 56
drwxr-xr-x. 2 root root 4096 4月 1 2013 admin
-rw-r--r--. 1 root root 872 4月 1 2013 changelog.txt
-rw-r--r--. 1 root root 318 4月 1 2013 favicon.ico
drwxr-xr-x. 7 root root 4096 12月 14 22:24 install
-rw-r--r--. 1 root root 32 12月 14 22:24 install_init.conf
-rw-r--r--. 1 root root 8238 4月 1 2013 license.html
drwxr-xr-x. 2 root root 4096 4月 1 2013 META-INF
drwxr-xr-x. 4 root root 4096 4月 1 2013 resources
-rw-r--r--. 1 root root 69 4月 1 2013 robots.txt
-rw-r--r--. 1 root root 166 4月 1 2013 shopxx.txt
drwxr-xr-x. 3 root root 4096 4月 1 2013 upload
drwxr-xr-x. 7 root root 4096 4月 1 2013 WEB-INF
[root@node200 ~]# rm -rf shopxx-v3.0-Beta/--------找到index.jsp,重解
[root@node200 ~]# unzip shopxx-a5-Beta.zip
[root@node200 ~]# cd shopxx-v3.0-Beta/
[root@node200 shopxx-v3.0-Beta]# ls
shopxx-3.0Beta
[root@node200 shopxx-v3.0-Beta]# cd shopxx-3.0Beta/
[root@node200 shopxx-3.0Beta]# ls
admin favicon.ico install META-INF robots.txt upload
changelog.txt index.jsp license.html resources shopxx.txt WEB-INF
[root@node200 shopxx-3.0Beta]# cp index.jsp /usr/local/tomcat/webapps/shopxx/
[root@node200 shopxx-3.0Beta]# catalina.sh stop
Using CATALINA_BASE: /usr/local/tomcat
Using CATALINA_HOME: /usr/local/tomcat
Using CATALINA_TMPDIR: /usr/local/tomcat/temp
Using JRE_HOME: /usr/java/latest
Using CLASSPATH: /usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/bin/tomcat-juli.jar
[root@node200 shopxx-3.0Beta]# catalina.sh start
Using CATALINA_BASE: /usr/local/tomcat
Using CATALINA_HOME: /usr/local/tomcat
Using CATALINA_TMPDIR: /usr/local/tomcat/temp
Using JRE_HOME: /usr/java/latest
Using CLASSPATH: /usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/bin/tomcat-juli.jar
Tomcat started.
[root@node200 shopxx-3.0Beta]# ll
总用量 56
drwxr-xr-x. 2 root root 4096 4月 1 2013 admin
-rw-r--r--. 1 root root 872 4月 1 2013 changelog.txt
-rw-r--r--. 1 root root 318 4月 1 2013 favicon.ico
-rw-r--r--. 1 root root 325 4月 1 2013 index.jsp
drwxr-xr-x. 7 root root 4096 4月 1 2013 install
-rw-r--r--. 1 root root 8238 4月 1 2013 license.html
drwxr-xr-x. 2 root root 4096 4月 1 2013 META-INF
drwxr-xr-x. 4 root root 4096 4月 1 2013 resources
-rw-r--r--. 1 root root 69 4月 1 2013 robots.txt
-rw-r--r--. 1 root root 166 4月 1 2013 shopxx.txt
drwxr-xr-x. 3 root root 4096 4月 1 2013 upload
drwxr-xr-x. 7 root root 4096 4月 1 2013 WEB-INF
[root@node200 shopxx-3.0Beta]# pwd
/root/shopxx-v3.0-Beta/shopxx-3.0Beta
[root@node200 shopxx-3.0Beta]# cd -
/root/shopxx-v3.0-Beta
[root@node200 shopxx-v3.0-Beta]# cd /usr/local/tomcat/webapps/shopxx/
[root@node200 shopxx]# ls
admin changelog.txt index.html install META-INF resources shopxx.txt upload
article favicon.ico index.jsp license.html product robots.txt sitemap WEB-INF
[root@node200 shopxx-3.0Beta]# catalina.sh stop
Using CATALINA_BASE: /usr/local/tomcat
Using CATALINA_HOME: /usr/local/tomcat
Using CATALINA_TMPDIR: /usr/local/tomcat/temp
Using JRE_HOME: /usr/java/latest
Using CLASSPATH: /usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/bin/tomcat-juli.jar
[root@node200 shopxx-3.0Beta]# catalina.sh start
Using CATALINA_BASE: /usr/local/tomcat
Using CATALINA_HOME: /usr/local/tomcat
Using CATALINA_TMPDIR: /usr/local/tomcat/temp
Using JRE_HOME: /usr/java/latest
Using CLASSPATH: /usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/bin/tomcat-juli.jar
Tomcat started.
登陆tomcat的登陆界面
[root@node200 ~]# cd /usr/local/tomcat/
[root@node200 tomcat]# vim conf/tomcat-users.xml
32 <role rolename="manager-gui"/>
33 <user username="tomcat" password="tomcat" roles="manager-gui"/>
、[root@node200 ~]# cd /usr/local/tomcat/
[root@node200 tomcat]# vim conf/tomcat-users.xml
[root@node200 tomcat]# catalina.sh stop
Using CATALINA_BASE: /usr/local/tomcat
Using CATALINA_HOME: /usr/local/tomcat
Using CATALINA_TMPDIR: /usr/local/tomcat/temp
Using JRE_HOME: /usr/java/latest
Using CLASSPATH: /usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/bin/tomcat-juli.jar
[root@node200 tomcat]# catalina.sh start
Using CATALINA_BASE: /usr/local/tomcat
Using CATALINA_HOME: /usr/local/tomcat
Using CATALINA_TMPDIR: /usr/local/tomcat/temp
Using JRE_HOME: /usr/java/latest
Using CLASSPATH: /usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/bin/tomcat-juli.jar
Tomcat started.
[root@node200 tomcat]#
热部署
[root@node200 tomcat]# vim conf/tomcat-users.xml
32 <role rolename="manager-gui"/>
33 <role rolename="admin-gui"/>
34 <user username="tomcat" password="tomcat" roles="admin-gui,manager-gui"/>
建立主机
[root@node200 tomcat]# cp -r webapps/testapp/ /webapps/testapp
[root@node200 tomcat]# ll /webapps/testapp/
总用量 20
drwxr-xr-x. 2 root root 4096 12月 15 21:54 classes
-rw-r--r--. 1 root root 187 12月 15 21:54 index.jsp
drwxr-xr-x. 2 root root 4096 12月 15 21:54 lib
drwxr-xr-x. 2 root root 4096 12月 15 21:54 META-INF
drwxr-xr-x. 2 root root 4096 12月 15 21:54 WEB-INF
[root@node200 tomcat]# cd /webapps/
[root@node200 webapps]# ls
jcenter testapp zye.edu
[root@node200 webapps]# mv testapp/ ROOT
[root@node200 webapps]# mkdir testapp
[root@node200 webapps]# mv ROOT/ testapp/
[root@node200 webapps]# ls
jcenter testapp zye.edu
[root@node200 webapps]# cd testapp/
[root@node200 testapp]# ll
总用量 4
drwxr-xr-x. 6 root root 4096 12月 15 21:54 ROOT
nginx+tomcat
[root@node200 ~]# ls
anaconda-ks.cfg connect-web.war JavaCenter_Home_2.0_GBK shopxx-a5-Beta.zip 说明.htm 桌面
apache-tomcat-8.0.30.tar.gz epel-release-latest-6.noarch.rpm JavaCenter_Home_2.0_GBK.tar.bz2 shopxx-v3.0-Beta 图片
apr-1.4.6 httpd-2.4.6.tar.bz2 jdk-7u67-linux-x64.rpm 公共的 文档
apr-1.4.6.tar.bz2 install.log mariadb-10.0.10-linux-x86_64.tar.gz 模板 下载
apr-util-1.4.1.tar.bz2 install.log.syslog nginx-1.8.0-1.el6.ngx.x86_64.rpm 视频 音乐
[root@node200 ~]# rpm -ivh nginx-1.8.0-1.el6.ngx.x86_64.rpm
[root@node200 ~]# ss -tnl
State Recv-Q Send-Q Local Address:Port Peer Address:Port
LISTEN 0 1 ::ffff:127.0.0.1:8005 :::*
LISTEN 0 100 :::8009 :::*
LISTEN 0 50 *:3306 *:*
LISTEN 0 100 :::8080 :::*
LISTEN 0 128 :::22 :::*
LISTEN 0 128 *:22 *:*
LISTEN 0 128 127.0.0.1:631 *:*
LISTEN 0 128 ::1:631 :::*
LISTEN 0 100 ::1:25 :::*
LISTEN 0 100 127.0.0.1:25 *:*
LISTEN 0 128 127.0.0.1:6010 *:*
LISTEN 0 128 ::1:6010 :::*
LISTEN 0 128 127.0.0.1:6012 *:*
LISTEN 0 128 ::1:6012 :::*
[root@node200 ~]# service nginx start
正在启动 nginx: [确定]
[root@node200 ~]# ss -tnl
State Recv-Q Send-Q Local Address:Port Peer Address:Port
LISTEN 0 1 ::ffff:127.0.0.1:8005 :::*
LISTEN 0 100 :::8009 :::*
LISTEN 0 50 *:3306 *:*
LISTEN 0 128 *:80 *:*
LISTEN 0 100 :::8080 :::*
LISTEN 0 128 :::22 :::*
LISTEN 0 128 *:22 *:*
LISTEN 0 128 127.0.0.1:631 *:*
LISTEN 0 128 ::1:631 :::*
LISTEN 0 100 ::1:25 :::*
LISTEN 0 100 127.0.0.1:25 *:*
LISTEN 0 128 127.0.0.1:6010 *:*
LISTEN 0 128 ::1:6010 :::*
LISTEN 0 128 127.0.0.1:6012 *:*
LISTEN 0 128 ::1:6012 :::*
[root@node200 ~]# vim /etc/nginx/conf.d/default.conf
8 location / {
9 # root /usr/share/nginx/html;
10 proxy_pass http://192.168.112.200:8080/;
11 index index.jsp index.html index.htm;
[root@node200 ~]# service nginx reload
重新载入 nginx: [确定]
lnamt-----不会像lnmt那样跳过nginx直接访问tomcat
[root@node200 ~]# service nginx stop
停止 nginx: [确定]
[root@node200 ~]# rpm -q httpd
httpd-2.2.15-45.el6.centos.x86_64
[root@node200 ~]# httpd -l------------静态模块
Compiled in modules:
core.c
prefork.c
http_core.c
mod_so.c
[root@node200 ~]# httpd -M
Loaded Modules:
core_module (static)
mpm_prefork_module (static)
http_module (static)
so_module (static)
auth_basic_module (shared)
auth_digest_module (shared)
authn_file_module (shared)
authn_alias_module (shared)
authn_anon_module (shared)
authn_dbm_module (shared)
authn_default_module (shared)
authz_host_module (shared)
authz_user_module (shared)
authz_owner_module (shared)
authz_groupfile_module (shared)
authz_dbm_module (shared)
authz_default_module (shared)
ldap_module (shared)
authnz_ldap_module (shared)
include_module (shared)
log_config_module (shared)
logio_module (shared)
env_module (shared)
ext_filter_module (shared)
mime_magic_module (shared)
expires_module (shared)
deflate_module (shared)
headers_module (shared)
usertrack_module (shared)
setenvif_module (shared)
mime_module (shared)
dav_module (shared)
status_module (shared)
autoindex_module (shared)
info_module (shared)
dav_fs_module (shared)
vhost_alias_module (shared)
negotiation_module (shared)
dir_module (shared)
actions_module (shared)
speling_module (shared)
userdir_module (shared)
alias_module (shared)
substitute_module (shared)
rewrite_module (shared)
proxy_module (shared)
proxy_balancer_module (shared)
proxy_ftp_module (shared)
proxy_http_module (shared)
proxy_ajp_module (shared)
proxy_connect_module (shared)
cache_module (shared)
suexec_module (shared)
disk_cache_module (shared)
cgi_module (shared)
version_module (shared)
dnssd_module (shared)
Syntax OK
[root@node200 ~]# vim /etc/httpd/conf/httpd.conf
292 #DocumentRoot "/var/www/html"292 #DocumentRoot "/var/www/html"
[root@node200 ~]# cd /etc/httpd/conf.d/
[root@node200 conf.d]# vim http-tomcat.conf
1 NameVirtualHost *:80
2
3 <Virtualhost *:80>
4 ServerName www.zye.com
5 ProxyVia On
6 ProxyRequests Off
7 ProxyPreserveHost On
8 <proxy *>
9 Order deny,allow
10 Allow from all
11 </Proxy>
12 ProxyPass /status !
13 ProxyPass / http://192.168.112.200:8080/
14 ProxyPassReverse / http://192.168.112.200:8080/
15 <Location />
16 Order deny,allow
17 Allow from all
18 </Location>
19 </VirtualHost>
[root@node200 conf.d]# httpd -t
Syntax OK
[root@node200 conf.d]# service httpd restart
停止 httpd: [失败]
正在启动 httpd: [确定]
[root@node200 conf.d]# ss -tnulp
Netid State Recv-Q Send-Q Local Address:Port Peer Address:Port
udp UNCONN 0 0 *:631 *:* users:(("cupsd",1546,9))
tcp LISTEN 0 128 127.0.0.1:6013 *:* users:(("sshd",16009,8))
tcp LISTEN 0 128 ::1:6013 :::* users:(("sshd",16009,7))
tcp LISTEN 0 1 ::ffff:127.0.0.1:8005 :::* users:(("java",12711,60))
tcp LISTEN 0 100 :::8009 :::* users:(("java",12711,48))
tcp LISTEN 0 50 *:3306 *:* users:(("mysqld",12267,10))
tcp LISTEN 0 128 :::80 :::* users:(("httpd",16161,4),("httpd",16163,4),("httpd",16164,4),("httpd",16165,4),("httpd",16166,4),("httpd",16167,4),("httpd",16168,4),("httpd",16169,4),("httpd",16170,4),("httpd",16171,4))
tcp LISTEN 0 100 :::8080 :::* users:(("java",12711,43))
tcp LISTEN 0 128 :::22 :::* users:(("sshd",1785,4))
tcp LISTEN 0 128 *:22 *:* users:(("sshd",1785,3))
tcp LISTEN 0 128 127.0.0.1:631 *:* users:(("cupsd",1546,7))
tcp LISTEN 0 128 ::1:631 :::* users:(("cupsd",1546,6))
tcp LISTEN 0 100 ::1:25 :::* users:(("master",1867,13))
tcp LISTEN 0 100 127.0.0.1:25 *:* users:(("master",1867,12))
tcp LISTEN 0 128 127.0.0.1:6011 *:* users:(("sshd",15878,8))
tcp LISTEN 0 128 ::1:6011 :::* users:(("sshd",15878,7))
[root@node200 conf.d]# cp http-tomcat.conf ajp-tomcat.conf
[root@node200 conf.d]# mv http-tomcat.conf http-tomcat.conf.bak
[root@node200 conf.d]# vim ajp-tomcat.conf
1 NameVirtualHost *:80
2
3 <Virtualhost *:80>
4 ServerName www.zye.com
5 ProxyVia On
6 ProxyRequests Off
7 ProxyPreserveHost On
8 <proxy *>
9 Order deny,allow
10 Allow from all
11 </Proxy>
12 ProxyPass /status !
13 ProxyPass / ajp://192.168.112.200:8009/
14 ProxyPassReverse / ajp://192.168.112.200:8009/
15 <Location />
16 Order deny,allow
17 Allow from all
18 </Location>
19 </VirtualHost>
[root@node200 conf.d]# httpd -M |grep ajp
proxy_ajp_module (shared)
Syntax OK
[root@node200 conf.d]# service httpd restart
停止 httpd: [确定]
正在启动 httpd: [确定]