Manually Deploying Java Web
Introduction
Tomcat is a widely used Java Web application server. This section describes how to deploy Java Web on an ECS. To do so, you need to download the Java Web installation package, upload the package to the ECS, and set security rules for the ECS. After installing Java Web, you need to configure related software.
Intended Audience
Any one who wants to deploy Java Web on their ECSs can refer to this section.
The ECS in this chapter uses CentOS 7.3 64bit as OS.
Deployment Process
Related Software and Tools
Table 1 lists the official paths to download JDK and Tomcat installation packages. You can also obtain the installation packages from other open-source image paths.
| Tool | Description | How to Obtain |
|---|---|---|
| PuTTY | A cross-platform remote access tool, which is used to access various nodes from a Windows OS during software installation | |
| WinSCP | File transfer across platforms, which is used for transferring files between Windows and Linux systems |
Prerequisites
- An ECS with an EIP bound is available.
- The jdk directory has been created on the ECS. The commands are as follows:
cd /home/
mkdir webDemo
cd webDemo/
mkdir jdk
- The tomcat directory has been created on the ECS. The commands are as follows:
cd webDemo/
mkdir tomcat
- The installation packages have been downloaded to the local PC and uploaded to the ECS through the file transfer tool. Alternatively, you can run the wget command to download the installation packages to the ECS. The details of both methods are described as follows:
- Method 1: Upload the installation packages to the ECS using the file transfer tool.
- Use WinSCP to upload the JDK software package to the jdk directory.
- Use WinSCP to upload the Tomcat software package to the tomcat directory.
- Method 2: Run the wget command to download the installation packages to the ECS.
- Run the following command to switch to the jdk directory:
cd /home/webDemo/jdk
- Running the following command to download the JDK installation package:
wget JDK package download address
Download the JDK installation package from the path listed in Table 1 or from other open-source image paths.
Check the available JDK 8 software package versions. The JDK installation package jdk-8u261-linux-x64.tar.gz is used as an example. Run the following command to download the package:
wget http://mirrors.linuxeye.com/jdk/jdk-8u261-linux-x64.tar.gz
- Run the following command to switch to the tomcat directory:
cd /home/webDemo/tomcat
- Running the following command to download the Tomcat installation package:
Download the Tomcat installation package from the path listed in Table 1 or from other open-source image paths.
Run the following command to download the installation package, for example, apache-tomcat-8.5.58.tar.gz:
wget http://mirrors.tuna.tsinghua.edu.cn/apache/tomcat/tomcat-8/v8.5.58/bin/apache-tomcat-8.5.58.tar.gz
- Run the following command to switch to the jdk directory:
- Method 1: Upload the installation packages to the ECS using the file transfer tool.
Configuring Security Group Rules for the ECS
- Click the ECS name to switch to the ECS details page and click Security Groups.
- In the upper right corner of the security group rule list, click Modify Security Group Rule.
- On the displayed page showing security group details, click Add Rule.
- In the Add Inbound Rule dialog box, add a security group rule as prompted.
To deploy the Java Web environment, you need to add two security group rules for the ECS.
- Set Protocol to ICMP.
If ICMP is disabled by default, pinging the ECS EIP will time out. Therefore, you must add a rule that allows access to the ECS over ICMP.

- Set an appropriate port. You can set the port number only when TCP or UDP is selected for Protocol. 8080 is used as an example here.

- Set Protocol to ICMP.
Installing JDK
- Run the following command to decompress the JDK installation package to the jdk directory:
tar -xvf jdk-8u261-linux-x64.tar.gz -C /home/webDemo/jdk/
- Run the following command to configure environment variables:
- Add the following content to the end of the file:
#set java environment export JAVA_HOME=/home/webDemo/jdk/jdk1.8.0_261 export JRE_HOME=/home/webDemo/jdk/jdk1.8.0_261/jre export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JRE_HOME/lib/tools.jar export PATH=$JAVA_HOME/bin:$PATH
- Run the following command to save the configuration and exit:
- Run the following command to make the /etc/profile configurations take effect:
source /etc/profile
- Run the following command to verify the installation.
JDK is successfully installed if the following information is displayed:
[root@ecs-c525-web ~]# java -version java version "1.8.0_261" Java(TM) SE Runtime Environment (build 1.8.0_261-b11) Java HotSpot(TM) 64-Bit Server VM (build 25.261-b08, mixed mode
Installing Tomcat
- Run the following command to decompress the Tomcat installation package to the tomcat directory:
tar -xvf apache-tomcat-8.5.58.tar.gz -C /home/webDemo/tomcat/
- Run the following commands to install Tomcat:
cd /home/webDemo/tomcat/apache-tomcat-8.5.58/
cd bin/
- Run the following command to edit the setclasspath.sh script: Add the following content to the setclasspath.sh script:
export JAVA_HOME=/home/webDemo/jdk/jdk1.8.0_261 export JRE_HOME=/home/webDemo/jdk/jdk1.8.0_261/jre
- Save the file and exit. Run the following command to start Tomcat:
Verifying Java Web Deployment
Enter the following content in the address box of a browser:
http://EIP bound to the ECS:8080
If the Tomcat page is displayed, Java Web has been set up. Port 8080 of ECSs can be accessed over the public network.
Last Article: Setting Up an FTP Site (Linux)
Next Article: Manually Setting Up a Magento E-Commerce Website (Linux)
Did this article solve your problem?
Thank you for your score!Your feedback would help us improve the website.