- Product Bulletin
- Service Overview
-
User Guide
- Usage Overview
- Selecting HCE as the Public Image When Creating an ECS
- Changing an OS to HCE
- Migrating an OS
- Upgrading HCE and RPM Packages
- Security Updates for HCE
- Obtaining the openEuler Extended Software Packages
- Creating a Docker Image and Starting a Container
- Tools
- Kernel Functions and Interfaces
- xGPU
- Configuring the Repositories and Installing Software for HCE
-
FAQs
- What Do I Do If CentOS Linux Is No Longer Maintained?
- Does Huawei Cloud Have a Migration Solution for CentOS?
- How Do I Install the MLNX Driver?
- How Do I Enable SELinux on an ECS Running HCE?
- How Do I Change the OS Name on the Console After the OS Is Migrated?
- How Are Huawei Cloud EulerOS, EulerOS, and openEuler Different from One Another?
- How Do I Enable WireGuard in Kernel and Install wireguard-tools?
- How Do I Save the User Credential Information for Logging In to Docker Like What Docker CE Does?
- What Is OOM? Why Does OOM Occur?
- How Do I Handle IPVS Errors?
- Why Can't HCE Obtain an IPv6 Address After IPv6 Is Enabled for an ECS?
- How Do I Set Auto Log Using TMOUT?
- Best Practices
- General Reference
Show all
Copied.
Installing Tomcat
Introduction
Apache Tomcat (or simply Tomcat) is an open source web server and servlet container developed by the Apache Software Foundation. This tutorial describes how you can deploy Tomcat in HCE 2.0.
Preparations
- Prepare an ECS and assign a public IP address or EIP to the ECS.
- Ensure that inbound security group rules allow traffic to flow to the ECS over port 8080.
Procedure
- Install Tomcat.
- Run the following command to install Java:
dnf install java-1.8.0-openjdk
- Run the following command to check whether the installation is successful:
java -version
- Run the following command to install Tomcat:
dnf install tomcat
The Tomcat is installed in the /usr/share/tomcat directory.
- Run the following command to install Java:
- Configure Tomcat.
- Add the following content to the /etc/profile file:
JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.342.b07-0.hce2.x86_64/jre PATH=$PATH:$JAVA_HOME/bin CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar export JAVA_HOME CLASSPATH PATH
- Run the following command to activate the preceding environment variables:
source /etc/profile
- Clear the /usr/share/tomcat/conf/server.xml file and paste the following content:
<?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 %s %b" /> </Host> </Engine> </Service> </Server>
Save the settings and exit. You can customize the preceding configuration as required.
- Run the following command to create the directories specified by appbase and docbase in the preceding configuration:
mkdir -p /data/wwwroot/default
- Run the following command to set tomcat as the owner of the preceding directory:
chown -R tomcat.tomcat /data/wwwroot/
- Create the /usr/share/tomcat/bin/setenv.sh file and enter the following information to set JVM memory parameters:
JAVA_OPTS='-Djava.security.egd=file:/dev/./urandom -server -Xms256m -Xmx496m -Dfile.encoding=UTF-8'
- Run the following command to start Tomcat:
systemctl start tomcat
- Run the following command to check the Tomcat status:
systemctl status tomcat
If active (running) is displayed, Tomcat is started.
- Add the following content to the /etc/profile file:
- Check whether Tomcat is installed.
- Run the following command to create a test page:
echo Tomcat test > /data/wwwroot/default/index.jsp
- Enter http://<Public IP address of the Tomcat service>:8080 in the address box of the browser. If the following page is displayed, the installation is successful.
- Run the following command to create a test page:
The preceding configuration is used only for tests. Exercise caution when using the configuration in the service environment.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot