标签:sys ali str key 安装tomcat tcl open add pat
[root@vm5 ~]# yum -y install java-11-openjdk java-11-openjdk-devel
[root@vm5 ~]# java -version
openjdk version "11.0.9" 2020-10-20 LTS
OpenJDK Runtime Environment 18.9 (build 11.0.9+11-LTS)
OpenJDK 64-Bit Server VM 18.9 (build 11.0.9+11-LTS, mixed mode, sharing)
[root@vm5 opt]# wget http://mirror.bit.edu.cn/apache/tomcat/tomcat-9/v9.0.40/bin/apache-tomcat-9.0.40.tar.gz
[root@vm5 opt]# ll -h
total 11M
-rw-r--r--. 1 root root 11M Nov 12 23:53 apache-tomcat-9.0.40.tar.gz
[root@vm5 opt]# tar xf apache-tomcat-9.0.40.tar.gz -C /usr/local
[root@vm5 opt]# cd /usr/local/
[root@vm5 local]# ln -sv apache-tomcat-9.0.40/ tomcat
‘tomcat‘ -> ‘apache-tomcat-9.0.40/‘
[root@vm5 local]# ll
total 0
drwxr-xr-x. 9 root root 220 Nov 28 20:08 apache-tomcat-9.0.40
drwxr-xr-x. 2 root root 6 May 11 2019 bin
drwxr-xr-x. 2 root root 6 May 11 2019 etc
drwxr-xr-x. 2 root root 6 May 11 2019 games
drwxr-xr-x. 2 root root 6 May 11 2019 include
drwxr-xr-x. 2 root root 6 May 11 2019 lib
drwxr-xr-x. 2 root root 6 May 11 2019 lib64
drwxr-xr-x. 2 root root 6 May 11 2019 libexec
drwxr-xr-x. 2 root root 6 May 11 2019 sbin
drwxr-xr-x. 5 root root 49 Nov 11 20:31 share
drwxr-xr-x. 2 root root 6 May 11 2019 src
lrwxrwxrwx. 1 root root 21 Nov 28 20:09 tomcat -> apache-tomcat-9.0.40/
[root@vm5 local]# cd tomcat/
[root@vm5 tomcat]# ll
total 128
drwxr-x---. 2 root root 4096 Nov 28 20:08 bin
-rw-r-----. 1 root root 18982 Nov 12 23:41 BUILDING.txt
drwx------. 2 root root 238 Nov 12 23:41 conf
-rw-r-----. 1 root root 5409 Nov 12 23:41 CONTRIBUTING.md
drwxr-x---. 2 root root 4096 Nov 28 20:08 lib
-rw-r-----. 1 root root 57092 Nov 12 23:41 LICENSE
drwxr-x---. 2 root root 6 Nov 12 23:35 logs
-rw-r-----. 1 root root 2333 Nov 12 23:41 NOTICE
-rw-r-----. 1 root root 3257 Nov 12 23:41 README.md
-rw-r-----. 1 root root 6898 Nov 12 23:41 RELEASE-NOTES
-rw-r-----. 1 root root 16507 Nov 12 23:41 RUNNING.txt
drwxr-x---. 2 root root 30 Nov 28 20:08 temp
drwxr-x---. 7 root root 81 Nov 12 23:38 webapps
drwxr-x---. 2 root root 6 Nov 12 23:35 work
[root@vm5 tomcat]# cd webapps/
[root@vm5 webapps]# mkdir test
[root@vm5 webapps]# ll
total 4
drwxr-x---. 15 root root 4096 Nov 28 20:08 docs
drwxr-x---. 7 root root 99 Nov 28 20:08 examples
drwxr-x---. 6 root root 79 Nov 28 20:08 host-manager
drwxr-x---. 6 root root 114 Nov 28 20:08 manager
drwxr-x---. 3 root root 223 Nov 28 20:08 ROOT
drwxr-xr-x. 2 root root 6 Nov 28 20:13 test
[root@vm5 webapps]# cat >> test/index.jsp <<EOF
> <html>
> <head>
> <title>test page</title>
> </head>
> <body>
> <%
> out.println("Hellow World");
> %>
> </body>
> </html>
> EOF
[root@vm5 webapps]# ll test/
total 4
-rw-r--r--. 1 root root 141 Nov 28 20:16 index.jsp
[root@vm5 bin]# pwd
/usr/local/tomcat/bin
[root@vm5 bin]# ls
bootstrap.jar configtest.sh shutdown.sh
catalina.bat daemon.sh startup.bat
catalina.sh digest.bat startup.sh
catalina-tasks.xml digest.sh tomcat-juli.jar
ciphers.bat makebase.bat tomcat-native.tar.gz
ciphers.sh makebase.sh tool-wrapper.bat
commons-daemon.jar setclasspath.bat tool-wrapper.sh
commons-daemon-native.tar.gz setclasspath.sh version.bat
configtest.bat shutdown.bat version.sh
[root@vm5 bin]# /usr/local/tomcat/bin/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
Using CLASSPATH: /usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/bin/tomcat-juli.jar
Using CATALINA_OPTS:
Tomcat started.
[root@vm5 bin]# ps -ef | grep tomcat
root 3301 1 54 20:22 pts/0 00:00:13 /usr/bin/java -Djava.util.logging.config.file=/usr/local/tomcat/conf/logging.properties -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Djdk.tls.ephemeralDHKeySize=2048 -Djava.protocol.handler.pkgs=org.apache.catalina.webresources -Dorg.apache.catalina.security.SecurityListener.UMASK=0027 -Dignore.endorsed.dirs= -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 start
root 3340 1181 0 20:22 pts/0 00:00:00 grep --color=auto tomcat
[root@vm5 bin]# ss -antl
State Recv-Q Send-Q Local Address:Port Peer Address:Port
LISTEN 0 128 0.0.0.0:22 0.0.0.0:*
LISTEN 0 1 [::ffff:127.0.0.1]:8005 *:*
LISTEN 0 100 *:8080 *:*
LISTEN 0 128 [::]:22 [::]:*
[wisan@fyj ~]$ curl 192.168.225.134:8080/test/
<html>
<head>
<title>test page</title>
</head>
<body>
Hellow World
</body>
</html>
[root@vm5 tomcat]# pwd
/usr/local/tomcat
[root@vm5 tomcat]# cd conf
[root@vm5 conf]# ls
Catalina context.xml logging.properties tomcat-users.xsd
catalina.policy jaspic-providers.xml server.xml web.xml
catalina.properties jaspic-providers.xsd tomcat-users.xml
[root@vm5 conf]# vim tomcat-users.xml
<?xml version="1.0" encoding="UTF-8"?>
...................................................
<tomcat-users xmlns="http://tomcat.apache.org/xml"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://tomcat.apache.org/xml tomcat-users.xsd"
version="1.0">
....................................................
<role rolename="manager-gui"/>
<user username="tomcat" password="123456" roles="manager-gui"/>
</tomcat-users>
[root@vm5 manager]# pwd
/usr/local/tomcat/webapps/manager
[root@vm5 manager]# ll
total 20
drwxr-x---. 2 root root 25 Nov 28 20:08 css
drwxr-x---. 2 root root 44 Nov 28 20:08 images
-rw-r-----. 1 root root 913 Nov 12 23:41 index.jsp
drwxr-x---. 2 root root 25 Nov 28 21:01 META-INF
-rw-r-----. 1 root root 4374 Nov 12 23:41 status.xsd
drwxr-x---. 3 root root 32 Nov 28 20:08 WEB-INF
-rw-r-----. 1 root root 4709 Nov 12 23:41 xform.xsl
[root@vm5 manager]# vim META-INF/context.xml
....................................................
<Context antiResourceLocking="false" privileged="true" >
<CookieProcessor className="org.apache.tomcat.util.http.Rfc6265CookieProcessor"
sameSiteCookies="strict" />
<Valve className="org.apache.catalina.valves.RemoteAddrValve"
allow="192\.168\.43\.\d+|192\.168\.225\.\d+|127\.\d+\.\d+\.\d+|::1|0:0:0:0:0:0:0:1" />
<Manager sessionAttributeValueClassNameFilter="java\.lang\.(?:Boolean|Integer|Long|Number|String)|org\.apache\.catalina\.filters\.CsrfPreventionFilter\$LruCache(?:\$1)?|java\.util\.(?:Linked)?HashMap"/>
</Context>
[root@vm5 manager]# /usr/local/tomcat/bin/catalina.sh stop
[root@vm5 manager]# /usr/local/tomcat/bin/catalina.sh start
[root@vm5 manager]# ss -antl
State Recv-Q Send-Q Local Address:Port Peer Address:Port
LISTEN 0 128 0.0.0.0:22 0.0.0.0:*
LISTEN 0 1 [::ffff:127.0.0.1]:8005 *:*
LISTEN 0 100 *:8080 *:*
LISTEN 0 128 [::]:22 [::]:*
[root@vm5 tomcat]# pwd
/usr/local/tomcat
[root@vm5 tomcat]# cd conf
[root@vm5 conf]# ls
Catalina context.xml logging.properties tomcat-users.xsd
catalina.policy jaspic-providers.xml server.xml web.xml
catalina.properties jaspic-providers.xsd tomcat-users.xml
[root@vm5 conf]# vim tomcat-users.xml
<?xml version="1.0" encoding="UTF-8"?>
...................................................
<tomcat-users xmlns="http://tomcat.apache.org/xml"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://tomcat.apache.org/xml tomcat-users.xsd"
version="1.0">
....................................................
<role rolename="manager-gui"/>
<user username="tomcat" password="123456" roles="manager-gui"/>
<role rolename="admin-gui"/>
<user username="tomcat" password="123456" roles="admin-gui"/>
</tomcat-users>
[root@vm5 host-manager]# pwd
/usr/local/tomcat/webapps/host-manager
[root@vm5 host-manager]# ls
css images index.jsp META-INF WEB-INF
[root@vm5 host-manager]# cd META-INF/
[root@vm5 META-INF]# ls
context.xml
[root@vm5 META-INF]# vim context.xml
......................................................
<Context antiResourceLocking="false" privileged="true" >
<CookieProcessor className="org.apache.tomcat.util.http.Rfc6265CookieProcessor"
sameSiteCookies="strict" />
<Valve className="org.apache.catalina.valves.RemoteAddrValve"
allow="192\.168\.43\.\d+|192\.168\.225\.\d+|127\.\d+\.\d+\.\d+|::1|0:0:0:0:0:0:0:1" />
<Manager sessionAttributeValueClassNameFilter="java\.lang\.(?:Boolean|Integer|Long|Number|String)|org\.apache\.catalina\.filters\.CsrfPreventionFilter\$LruCache(?:\$1)?|java\.util\.(?:Linked)?HashMap"/>
</Context>
[root@vm5 META-INF]# /usr/local/tomcat/bin/catalina.sh stop
[root@vm5 META-INF]# /usr/local/tomcat/bin/catalina.sh start
[root@vm5 META-INF]# ss -antl
State Recv-Q Send-Q Local Address:Port Peer Address:Port
LISTEN 0 128 0.0.0.0:22 0.0.0.0:*
LISTEN 0 1 [::ffff:127.0.0.1]:8005 *:*
LISTEN 0 100 *:8080 *:*
LISTEN 0 128 [::]:22 [::]:*
[root@vm5 ~]# yum -y install httpd
[root@vm5 ~]# vim /etc/httpd/conf/httpd.conf
................................................
Include conf.modules.d/*.conf
..................................................
ServerName www.wisan.com:80
.................................................
<IfModule dir_module>
DirectoryIndex index.html index.jsp
</IfModule>
.................................................
IncludeOptional conf.d/*.conf
[root@vm5 ~]# vim /etc/httpd/conf.d/vhost.conf
<VirtualHost *:80>
DocumentRoot "/var/www/html"
ServerName www.wisan.com
ProxyRequests Off
ProxyPass /test http://127.0.0.1:8080/test/
ProxyPassReverse /test http://127.0.0.1:8080/test/
<Directory "/var/www/html">
Options none
AllowOverride none
Require all granted
</Directory>
</VirtualHost>
[root@vm5 ~]# vim /etc/httpd/conf.modules.d/00-proxy.conf
........................................................
LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_connect_module modules/mod_proxy_connect.so
LoadModule proxy_http_module modules/mod_proxy_http.so
........................................................
[root@vm5 ~]# cd /var/www/html
[root@vm5 html]# ls
wisan
[root@vm5 html]# ls wisan/
index.html
[root@vm5 html]# cat wisan/index.html
wisan,hello!
[root@vm5 webapps]# pwd
/usr/local/tomcat/webapps
[root@vm5 webapps]# ls
docs examples host-manager manager ROOT test
[root@vm5 webapps]# cd test/
[root@vm5 test]# ls
conn_mysql.jsp index.jsp
[root@vm5 test]# cat index.jsp
<html>
<head>
<title>test page</title>
</head>
<body>
<%
out.println("Hellow World");
%>
</body>
</html>
[root@vm5 test]# ls
conn_mysql.jsp index.jsp
[root@vm5 test]# cat conn_mysql.jsp
<%@page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@page import="java.sql.DriverManager"%>
<%@page import="java.sql.Connection"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
<%
try{
Class.forName("org.mariadb.jdbc.Driver");
String url="jdbc:maria://localhost:3306/test";
String username="root";
String password="123456";
Connection conn=DriverManager.getConnection(url,username,password);
if(conn!=null){
out.println("mysql数据库连接成功!!!");
}else{
out.println("数据库连接失败!!!");
}
}catch(ClassNotFoundException e){
e.printStackTrace();
}
%>
</body>
</html>
[root@vm5 ~]# yum -y install mariadb-server mariadb
[root@vm5 test]# yum -y install mariadb-java-client //连接mariadb的jdbc连接器
[root@vm5 ~]# cp /usr/lib/java/mariadb-java-client.jar /usr/local/tomcat/lib //将mariadb-java-client.jar导入tomcat/lib库中
[root@vm5 ~]# ls /usr/local/tomcat/lib/
annotations-api.jar jaspic-api.jar tomcat-i18n-ja.jar
catalina-ant.jar jsp-api.jar tomcat-i18n-ko.jar
catalina-ha.jar mariadb-java-client.jar tomcat-i18n-pt-BR.jar
catalina.jar servlet-api.jar tomcat-i18n-ru.jar
catalina-ssi.jar tomcat-api.jar tomcat-i18n-zh-CN.jar
catalina-storeconfig.jar tomcat-coyote.jar tomcat-jdbc.jar
catalina-tribes.jar tomcat-dbcp.jar tomcat-jni.jar
ecj-4.17.jar tomcat-i18n-cs.jar tomcat-util.jar
el-api.jar tomcat-i18n-de.jar tomcat-util-scan.jar
jasper-el.jar tomcat-i18n-es.jar tomcat-websocket.jar
jasper.jar tomcat-i18n-fr.jar websocket-api.jar
[root@vm5 ~]# systemctl start mariadb
[root@vm5 ~]# mysql -uroot
MariaDB [(none)]> set password=password(‘123456‘);
[root@vm5 ~]# mysql -uroot -p123456
MariaDB [(none)]> create database test;
Query OK, 1 row affected (0.002 sec)
MariaDB [(none)]> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| test |
+--------------------+
4 rows in set (0.003 sec)
[root@vm5 ~]# systemctl restart httpd
[root@vm5 ~]# systemctl restart mariadb
[root@vm5 ~]# /usr/local/tomcat/bin/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
Using CLASSPATH: /usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/bin/tomcat-juli.jar
Using CATALINA_OPTS:
[root@vm5 ~]# /usr/local/tomcat/bin/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
Using CLASSPATH: /usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/bin/tomcat-juli.jar
Using CATALINA_OPTS:
Tomcat started.
[root@vm5 ~]# ss -antl
State Recv-Q Send-Q Local Address:Port Peer Address:Port
LISTEN 0 128 0.0.0.0:22 0.0.0.0:*
LISTEN 0 1 [::ffff:127.0.0.1]:8005 *:*
LISTEN 0 80 *:3306 *:*
LISTEN 0 100 *:8080 *:*
LISTEN 0 128 *:80 *:*
LISTEN 0 128 [::]:22 [::]:*
标签:sys ali str key 安装tomcat tcl open add pat
原文地址:https://www.cnblogs.com/fyjpeng/p/14055418.html