mkdir /usr/java # Create a `java` foldercd /usr/java # Enter the `java` folder
# Upload JDK installation package (recommended)You are recommended to use tools such as WinSCP to upload the JDK installation package to the above `java` folder and then decompress it.Or# Use a command (you are recommended to upload the installation package): run `wget` to download the package, which cannot be decompressed because a downloaded package declines the Oracle BSD License by default. Please go to https://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html to accept the license agreement and obtain the download link with your cookies.wget --no-check-certificate --no-cookies --header "Cookie: oraclelicense=accept-securebackup-cookie" https://download.oracle.com/otn-pub/java/jdk/8u201-b09/42970487e3af4f5aa5bca3f542482c60/jdk-8u201-linux-x64.tar.gz
# Decompresschmod +x jdk-8u201-linux-x64.tar.gztar -xzvf jdk-8u201-linux-x64.tar.gz
/etc/profile file.vi /etc/profile
# set java environmentexport JAVA_HOME=/usr/java/jdk1.8.0_201export CLASSPATH=$JAVA_HOME/lib/tools.jar:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/libexport PATH=$JAVA_HOME/bin:$PATH
:wq to save and close the file.source /etc/profile
java -version command. If the JDK version information is displayed, JDK has been successfully installed.

# The mirror address may change and the Tomcat version may be continuously upgraded. If the download link expired, please go to [Tomcat official website](https://tomcat.apache.org/download-80.cgi) and select an appropriate installation package address.wget http://mirrors.tuna.tsinghua.edu.cn/apache/tomcat/tomcat-8/v8.5.39/bin/apache-tomcat-8.5.39.tar.gztar -xzvf apache-tomcat-8.5.39.tar.gzmv apache-tomcat-8.5.39 /usr/local/tomcat/
/usr/local/tomcat/ directory:server.xml and web.xml.# Add a general user `www` to run Tomcatuseradd www# Create a website root directorymkdir -p /data/wwwroot/default# Upload the Java web project file (WAR package) to the website root directory and modify the file permission under the directory to `www`. This example shows how to create a Tomcat test page in the website root directory:echo Hello Tomcat! > /data/wwwroot/default/index.jspchown -R www.www /data/wwwroot
/usr/local/tomcat/bin/setenv.sh script file.vi /usr/local/tomcat/bin/setenv.sh
JAVA_OPTS='-Djava.security.egd=file:/dev/./urandom -server -Xms256m -Xmx496m -Dfile.encoding=UTF-8'
:wq to save and exit./usr/local/tomcat/conf/ directory.cd /usr/local/tomcat/conf/
server.xml file.mv server.xml server_default.xml
server.xml file.vi server.xml
<?xml version="1.0" encoding="UTF-8"?><Server port="8006" shutdown="SHUTDOWN"><Listener className="org.apache.catalina.core.JreMemoryLeakPreventionListener"/><Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener"/><Listener className="org.apache.catalina.core.ThreadLocalLeakPreventionListener"/><Listener className="org.apache.catalina.core.AprLifecycleListener"/><GlobalNamingResources><Resource name="UserDatabase" auth="Container"type="org.apache.catalina.UserDatabase"description="User database that can be updated and saved"factory="org.apache.catalina.users.MemoryUserDatabaseFactory"pathname="conf/tomcat-users.xml"/></GlobalNamingResources><Service name="Catalina"><Connector port="8080"protocol="HTTP/1.1"connectionTimeout="20000"redirectPort="8443"maxThreads="1000"minSpareThreads="20"acceptCount="1000"maxHttpHeaderSize="65536"debug="0"disableUploadTimeout="true"useBodyEncodingForURI="true"enableLookups="false"URIEncoding="UTF-8"/><Engine name="Catalina" defaultHost="localhost"><Realm className="org.apache.catalina.realm.LockOutRealm"><Realm className="org.apache.catalina.realm.UserDatabaseRealm"resourceName="UserDatabase"/></Realm><Host name="localhost" appBase="/data/wwwroot/default" unpackWARs="true" autoDeploy="true"><Context path="" docBase="/data/wwwroot/default" debug="0" reloadable="false" crossContext="true"/><Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"prefix="localhost_access_log." suffix=".txt" pattern="%h %l %u %t "%r" %s %b" /></Host></Engine></Service></Server>
:wq to save and exit.bin directory of the Tomcat server and run the ./startup.sh command to start the Tomcat server.cd /usr/local/tomcat/bin./startup.sh

service tomcat start.wget https://github.com/lj2007331/oneinstack/raw/master/init.d/Tomcat-initmv Tomcat-init /etc/init.d/tomcatchmod +x /etc/init.d/tomcat
JAVA_HOME startup script.sed -i 's@^export JAVA_HOME=.*@export JAVA_HOME=/usr/java/jdk1.8.0_201@' /etc/init.d/tomcat
chkconfig --add tomcatchkconfig tomcat on
# Start Tomcatservice tomcat start# View Tomcat server statusservice tomcat status# Stop Tomcatservice tomcat stop

cd /usr/localchmod -R 777 tomcat
http://public IP:port (where the port is the connector port set in server.xml) in the address bar of the browser. If the following page appears, the installation is successful.

server.xml, so you need to open TCP:8080 to the internet in the security group bound to the corresponding CVM instance.

Feedback