Configure jdk8 and tomcat8
Configure jdk8
1. Download
Download address:
Official address (login required):
https://www.oracle.com/cn/java/technologies/javase/javase-jdk8-downloads.html
Download the following version:
Other address:
https://www.jdkdownload.com/
Download the following version:
2. Create installation directory
mkdir -p /usr/java/jdk8
3. Use xftp to move the jdk installation package to any directory, and move the following into the / root directory:
4. Decompression package
tar -zxvf jdk-8u181-linux-x64.tar.gz
5. Move the unzipped file to the installation directory you created and remove the package:
Move:
mv ./jdk1.8.0_181/* /usr/java/jdk8
Delete:
rm -f jdk-8u181-linux-x64.tar.gz
6. Configuration
vim /etc/profile
Press the i key and wrap after the last line unset-f pathmunge, adding the following code:
export JAVA_HOME=/usr/java/jdk8 export CLASSPATH=.:$JAVA_HOME/jre/lib/rt.jar:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar export PATH=$PATH:$JAVA_HOME/bin
Press the esc key and enter: wq to save and exit.
Then enter the following command:
source /etc/profile
7. Test for successful installation
javac -version
Configure Tomcat 8.0
1. Download the tomcat installation package
Download path:
https://tomcat.apache.org/download-80.cgi
2. Create installation directory
mkdir -p /usr/local/tomcat8
3. Use xftp to move the jdk installation package to any directory, and move the following into the / root directory:
4. Unzip the installation package
tar -vzxf apache-tomcat-8.5.66.tar.gz
5. Move the unzipped directory to the created directory and delete the installation package
Move:
mv apache-tomcat-8.5.66/* /usr/local/tomcat8
Delete:
rm -f apache-tomcat-8.5.66.tar.gz
6. Configuring environment variables
vim /etc/profile
Press the i key and add the following to the code written in the current configuration jdk:
export CATALINE_HOME=/usr/local/tomcat8
And in export PATH=$PATH:$JAVA_Add code after HOME/bin, and the final code is as follows:
export PATH=$PATH:$JAVA_HOME/bin:$CATALINE_HOME/bin
Press the esc key and enter: wq to save and exit.Then type the following command:
source /etc/profile
7. Testing
Enter the following command:
startup.sh
netstat -ano|grep 8080
The tomcat configuration is complete.
Open port 8080 in the firewall
1. Scheme 1:
1) Open port 8080
firewall-cmd --zone=public --add-port=8080/tcp --permanent
2) Restart the firewall
firewall-cmd --reload
3) Check if the port is open
firewall-cmd --zone=public --query-port=8080/tcp
4) Enter your ip address with the port number, i.e.
http://ip Address: 8080
If the above assembly is successful, you can access the above links.
2. Plan 2:
Close the firewall permanently with the following commands:
systemctl disable firewalld.service
Enter the following command to restart:
reboot
After the system restarts, query the firewall status, the command is as follows:
systemctl status firewalld
Proves that the firewall has been permanently closed.
At this point, you need to type a command:
startup.sh
Is accessible http://ip Address: 8080.
Configure tomcat boot-up self-start
Scheme 2 is strongly recommended!
1. Scheme 1
Modify the original configuration file
vim /etc/rc.d/rc.local
Press the i key and enter the following at the end line:
export JAVA_HOME=/usr/java/jdk8 /usr/local/tomcat8/bin/startup.sh
Press the esc key and enter: wq to save and exit.
In the above file, it says: Official advice is best to create your own service file.If you want to use the file, you need to give it permission, that is:
chmod +x /etc/rc.d/rc/local
At this point, the details of the file are as follows:
Then reboot and you can access the link without running the startup.sh command.
2. Plan 2:
Create your own service file.
vim /usr/lib/systemd/system/tomcat.service
Press the i key and type the following:
[Unit] Description=tomcat After=network.target [Service] Type=oneshot ExecStart=/usr/local/tomcat8/bin/startup.sh ExecStop=/usr/local/tomcat8/bin/shutdown.sh ExecReload=/bin/kill -s HUP $MAINPID RemainAfterExit=yes [Install] WantedBy=multi-user.target
Press the esc key and enter: wq to save and exit.
Set tomcat.service to startup with the following commands:
systemctl enable tomcat.service
Enter the following command again to modify setclasspath.sh.
vim /usr/local/tomcat8/bin/setclasspath.sh
Press the i key and enter the following:
export JAVA_HOME=/usr/java/jdk8 export JRE_HOME=/usr/java/jdk8/jre
Press the esc key and enter: wq to save and exit.
Enter reboot.Wait for the restart to access the link.