CentOS installation tomcat environment installation and configuration process complete version

CentOS installation tomcat environment installation and configuration process


View installation package information

yum info tomcat

installation

yum -y install tomcat

Check if the installation is successful

rpm -q tomcat

Output:

tomcat-7.0.76-16.el7_9.noarch

Indicates that the installation was successful.

Configure environment variables

tomcat default installation path

/usr/share/tomcat/

Add environment variable configuration

Add Tomcat environment variables to the /etc/profile configuration file:

JAVA_HOME=/usr/lib/jvm/java

PATH=$PATH:$JAVA_HOME/bin

CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar

CATALINA_BASE=/usr/share/tomcat

CATALINA_HOME=/usr/share/tomcat

export JAVA_HOME PATH CLASSPATH CATALINA_BASE CATALINA_HOME

Make the configuration file effective:

source /etc/profile

Check whether it works

echo $CATALINA_BASE
echo $CATALINA_HOME

Start tomcat

systemctl start tomcat.service

Check whether to start:

systemctl status tomcat

[External link image transfer failed. The source site may have an anti-leech link mechanism. It is recommended to save the image and upload it directly (img-Fqr14B4D-1611059618926)(evernotecid://6FE75482-54A0-433A-9625-A01F7FEE92EC/appyinxiangcom/9896050/ENResource /p2998)]

If you want to run a tomcat application, you can put it in the /usr/share/tomcat/webapps directory, configure tomcat, and restart the tomcat service.

Configure port

View firewall status

systemctl status firewalld

[External link image transfer failed. The source site may have an anti-leech link mechanism. It is recommended to save the image and upload it directly (img-t868uPgZ-1611059618928)(evernotecid://6FE75482-54A0-433A-9625-A01F7FEE92EC/appyinxiangcom/9896050/ENResource /p2999)]

Closed state, need to open.

Turn on the firewall

systemctl start firewalld

Check the status again:

VM-0-11-centos firewalld[25831]: WARNING: AllowZoneDrifting is enable....

It started, but a warning message appeared here.

Warning resolution

Edit the FirewallD configuration file:

vi /etc/firewalld/firewalld.conf

Find AllowZoneDrifting=yes and change yes to no:

[External link image transfer failed. The source site may have an anti-leech link mechanism. It is recommended to save the image and upload it directly (img-VLEgwyCK-1611059618930)(evernotecid://6FE75482-54A0-433A-9625-A01F7FEE92EC/appyinxiangcom/9896050/ENResource /p3000)]

Take effect after restarting.

Permanently open port 8080

Excuting an order:

firewall-cmd --zone=public --add-port=8080/tcp --permanent

Permanently open port 8080, otherwise it will be inaccessible.

Restart the firewall:

systemctl restart firewalld.service

Boot tomcat

systemctl enable tomcat.service

Install tomcat management pack

If you are just starting to use Tomcat, you probably want to install some management tools that will help us deploy Java applications and manage virtual hosts. Fortunately, there are some software packages that use these tools as web applications.

安装 Tomcat 根页面(tomcat-webapps)和 Tomcat Web 应用程序管理器和Virtual Host Manager:
yum install -y tomcat-webapps tomcat-admin-webapps 

安装在线文档(可选):
yum install -y tomcat-docs-webapp tomcat-javadoc

After completion, the tomcat/webapps directory will add the following subdirectories:

ROOT、examples、sample、manager和host-manager。

Configure Tomcat Web Management Interface

In order to use the manager webapp installed in the previous step, we must add a login to our Tomcat server.

Modify the tomcat-users.xml file:

vi /usr/share/tomcat/conf/tomcat-users.xml

New management accounts for accessing manager-gui and admin-gui:

<tomcat-users>
   <user username="admin" password="password" roles="manager-gui,admin-gui"/>
</tomcat-users>

Save and close the tomcat-users.xml file, restart the Tomcat service:

systemctl restart tomcat

Open the browser and enter the server IP address: 8080 in the address bar. Well, we can see the Tomcat interface, and if you click the Manager App button, you can log in with the account and password set above.


PS: For more more content..., please check --> "Server Development"
PS: More more content..., please check --> "Server Development"
PS: More more content..., please check --> "Server Development"

Guess you like

Origin blog.csdn.net/u011578734/article/details/112851588