Before installing Tomcat, install the JDK environment
- Take a look at my previous article installing the JDK and environment configuration about the problems encountered in configuring the Java environment on a Linux server
- Go to the Apache website to download the Tomcat8.5 installation package, tomcat.apache.org/
- You can also choose another version of Tomcat
- So Tomcat8,Tomcat.apache.org/download-80…
- Wget command + copy the download address
Wget HTTP: / / https://mirrors.bfsu.edu.cn/apache/tomcat/tomcat-8/v8.5.60/bin/apache-tomcat-8.5.60.tar.gzCopy the code
- Download it and unzip it
Tar ZXVF - apache tomcat - 8.5.60. Tar. GzCopy the code
- Tomcat name is too long, you can change it, I’ll change it here
tomcat8.5.8010
Said,tomcat8.5
Version and the listening port is8010
Mv apache tomcat - 8.5.60 tomcat8.5.8010Copy the code
- Change the Tomcat port number, because there are many projects, it is best to deploy a Tomcat project, so listen to the default port
8080
It won’t be enough. You’d better change it to something else - Switch to the Tomcat directory
conf
Folder, openserver.xml
vim server.xml
Copy the code
- find
8080
Change the port number to8010
To save and exit
- Note: Enable the security group on the cloud server
8010
The port number andA firewall
Also want to release8010
firewall-cmd --zone=public --add-port=8010/tcp --permanent
Copy the code
- This will be successful
8010
Port addedpublic
In the area,permanent
The parameter takes effect permanently, even after the firewall is restarted. Finally, do not forget to update firewall rules:
firewall-cmd --reload
Copy the code
- Look at the
public
For all open ports in the zone, run the following command:
firewall-cmd --zone=public --list-ports
Copy the code
- Before adding Tomcat environment variables, you must add Java environment variables, otherwise it will not be used. You can refer to this article to configure the Java environment encountered by Linux server
- You can also add the Tomcat path to the environment variable so that instead of switching to Tomcat’s bin directory every time Tomcat is started or shut down, you can execute commands in any path.
vim /etc/profile
Copy the code
- Open and add at the end
export JAVA_HOME=/usr/local/ jdk1.8.0 _271 /export CLASSPATH=%JAVA_HOME%/lib:%JAVA_HOME%/jre/lib
exportTOMCAT_HOME = / WWW/server/tomcat8.5.8010 /export PATH=$TOMCAT_HOME/bin:$JAVA_HOME/bin:$JAVA_HOME/jre/bin:$PATH
Copy the code
- Reload the configuration to take effect
source /etc/profile
Copy the code
- Test the Java environment:
- Finally, test whether the configuration is successful. Start or close Tomcat in another directory.For example, start Tomcat in the root directory
Pay attention to: Start or close Tomcat in the bin directory./startup.sh
Add environment variables without adding. /
startup.sh
shutdown.sh
Copy the code
- Access: Public IP address of the cloud server :8010
- It is not necessary to add the Tomcat directory to the environment variable, because if you need more than one Tomcat on a server, you will need to configure the environment every time. See me configuration for details
nginx
The environment configuration can achieve:
Centos8.0 builds and installs the latest stable version of nginx