Tomcat deployment and host manager, server status, manager app page configuration access
1. Introduction
Tomcat server is a free and open source web application server, which is a lightweight application server. It is widely used in small and medium-sized systems and occasions where there are not many concurrent access users. It is the first choice for developing and debugging JSP programs. For a beginner, it can be considered that when the Apache server is configured on a machine, it can be used to respond to the access request of the HTML (an application under the standard general markup language) page. Tomcat is actually an extension of the Apache server, but it runs independently at runtime, so when you run tomcat, it actually runs as a separate process from Apache.
Tomcat is a free open source Serlvet container used to run java program containers
It is the first choice for developing and debugging Servlet (Server Applet), JSP (Java Server Pages) programs;
Tomcat is one of the legendary middleware. Tomcat itself is a container specially used to run java programs. Web pages developed in java language .jsp
should run in tomcat, and the operation of tomcat itself also depends on the jdk environment.
Commonly used middleware
Generally, for local development, small projects or personal development suggest using tomcat;
The Linux system recommends using jetty or apache hpppd;
For large projects, use JBOSS or webloigc;
Large projects or commercial projects generally use: weblgoic/webshere, others include jboss, glassfish, etc.;
Some sample projects or small projects often use jetty;
tomcat, jboss, weblogic, websphere general project tomcat will do.
2. Deploy tomcat
1. Turn off the firewall and selinux
[root@ls ~]# systemctl disable --now firewalld
Removed /etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
[root@ls ~]# setenforce 0
[root@ls ~]# sed -ri 's/^(SELINUX=).*/\1disabled/g' /etc/selinux/config
2. Install java
[root@ls ~]# yum -y install java-11-openjdk
3. Unzip tomcat to the /usr/local/ directory
[root@ls ~]# ls
anaconda-ks.cfg apache-tomcat-10.0.23.tar.gz
[root@ls ~]# tar -xzf apache-tomcat-10.0.23.tar.gz -C /usr/local/
[root@ls ~]# cd /usr/local/
[root@ls local]# ln -s apache-tomcat-10.0.23/ tomcat
4. Customize a Hello World java test page
[root@ls local]# mkdir /usr/local/tomcat/webapps/test
[root@ls local]# cd /usr/local/tomcat/webapps/test
[root@ls test]# vim index.jsp
<html>
<head>
<title>test page</title>
</head>
<body>
<%
out.println("Hello World");
%>
</body>
</html>
5. Start tomcat
[root@ls test]# cd /usr/local/tomcat
[root@ls tomcat]# bin/startup.sh
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.
6. Test access
tomcat homepage
hello world test page
3. Access the Host Manager interface
1. Configure the tomcat-users.xml file, add two lines above </tomcat-users>
the line , set the role, login user name and password, the role name can only be admin-gui user name and password customization
[root@ls ~]# vim /usr/local/tomcat/conf/tomcat-users.xml
<role rolename="admin-gui"/>
<user username="tomcat" password="123456" roles="admin-gui"/>
</tomcat-users>
2. Configure the host-manager/META-INF/context.xml file to allow access from the 192.168.183.0/24 network segment, and add it after the allow field
[root@ls ~]# vim /usr/local/tomcat/webapps/host-manager/META-INF/context.xml
allow="192\.168\.183\.\d+|127\.\d+\.\d+\.\d+|::1|0:0:0:0:0:0:0:1" />
3. Restart the service, close the service first, and then start the service
[root@ls ~]# /usr/local/tomcat/bin/catalina.sh stop
[root@ls ~]# /usr/local/tomcat/bin/catalina.sh start
4. Log in to the web page to test and log in to Host Manager, enter the corresponding user name and password
username | password |
---|---|
tomcat | 123456 |
4. Access the Server Status interface
1. Edit tomcat-users.xml
[root@ls ~]# vim /usr/local/tomcat/conf/tomcat-users.xml
<role rolename="admin-gui"/>
<role rolename="manager-gui"/>
<user username="tomcat" password="123456" roles="admin-gui,manager-gui"/>
</tomcat-users>
2. Edit manager/META-INF/context.xml, add in the allow field to allow 192.168.183.0/24 network segment access
[root@ls ~]# vim /usr/local/tomcat/webapps/manager/META-INF/context.xml
allow="192\.168\.183\.\d+|127\.\d+\.\d+\.\d+|::1|0:0:0:0:0:0:0:1" />
3. Restart the service, close the service first, and then start the service
[root@ls ~]# /usr/local/tomcat/bin/catalina.sh stop
[root@ls ~]# /usr/local/tomcat/bin/catalina.sh start
4. Log in to the webpage, visit Server Status, user name tomcat password 123456
5. Access the Manager App interface
When accessing the Manager App, no password is required, because the Server Status interface is accessed, so there is no need to enter a password