This article describes how to set up a Java Web environment on a Linux CVM.
This requires you to be familiar with common Linux commands, such as Installing Software via YUM in a CentOS Environment, and understand the versions of the installed software.
These are the software involved:
Setting up a Java Web environment requires a Linux CVM. If you have not purchased one yet, see Getting Started with Linux CVMs.
Download the JDK file, save it locally, and upload it to your CVM. Otherwise, decompressing the file will result in errors.
- If you are using Windows, use [WinSCP]https://intl.cloud.tencent.com/document/product/213/2131) to upload the file.
- If you are using MacOS or Linux, use SCP to upload the file.
tar xzf jdk-8u221-linux-x64.tar.gz -C /usr/java
export PATH USER ...and add the following:
The result should be as follows:
export JAVA_HOME=/usr/java/jdk1.8.0_221 (replace 1.8.0_221 with your JDK version number) export CLASSPATH=$JAVA_HOME/lib/tools.jar:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib export PATH=$JAVA_HOME/bin:$PATH
If the following appears, the installation was successful.
Refer to the Apache Tomcat official website for more information.
tar xzf apache-tomcat-8.5.47.tar.gz
mv apache-tomcat-8.5.47 /usr/local/tomcat/
<Host … appBase="webapps”>and press i to enter edit mode. Replace
appBase="webapps"with the following:
JAVA_OPTS='-Djava.security.egd=file:/dev/./urandom -server -Xms256m -Xmx496m -Dfile.encoding=UTF-8'
If the following appears, Tomcat has been successfully started.
echo Hello World! > /usr/local/tomcat/webapps/ROOT/index.jsp
If the following results appear, the environment configuration was successful.
Public IP address of the CVM instance]:8080[
If you encounter a problem when using CVM, refer to the following documents for troubleshooting based on your actual situation.