×
Community Blog Hands-on Labs | Build a Java Web Development Environment

Hands-on Labs | Build a Java Web Development Environment

This step-by-step tutorial introduces how to build a Java web development environment.

>> Get hands-on experience with this tutorial in a lab environment.


1. Configure Resources

This section is for reference. If you have already configured your resources, please skip this section and move to the next.

1.  On the basic configuration page, configure the ECS basic configuration according to the following instructions. The configuration that is not mentioned remains the default option, and then click Next: Network and security group.

1

Note: the following configurations are used in this experiment. The configurations not mentioned remain the default options.

Configuration description:

2

Configuration item Example Explain
Region and zone Region: Singapore
Zone: Singapore Zone B
After an instance is created, you cannot directly change the region and zone.
Instance type Type family: ecs.t5-c1m1.large (Standard) You can go to the ECS instance purchase region to view the instance purchase status in each region.
Image Type: Public image
Version: CentOS 7.9 64 bit
After the instance is started, the system disk will completely copy the operating system and application data of the image.

2.  On the network and security groups page, configure the ECS network and security group according to the following instructions. The configuration that is not mentioned remains the default option, and then click Next: Network and security group.

Configuration description:

Configuration item Example Explain
VPC Default VPC Select your VPC. To create a VPC, click create in the console.
VSwitch Default vSwitch Select your vSwitch. To create a vSwitch, click create in the console.
Assign public IPv4 addresses Select assign public IPv4 address When selected, a public IPv4 address is automatically assigned.
Bandwidth billing mode Pay-by-traffic You only need to pay for the Internet traffic consumed by using the traffic mode. For more information, see Internet bandwidth billing.
Peak bandwidth 5 Mbps None.
Security Group Default security group Select your security group. You must enable ports 80, 443, 22, 3389, and 3306. To create a security group, click Create Security Group.

3.  On the System configuration page, configure the ECS system configuration according to the following instructions. The configuration that is not mentioned remains the default option, and then click Next: Group settings.

Configuration description:

Configuration item Example Explain
login credentials Custom password In this tutorial, select a custom password and manually set a password for remote connection and sign in to the ECS instance.
Sign-in password Ecs123456 When you select a custom password for the Sign-in credential, you must set this option and confirm the password. When you connect to the ECS instance later, you must enter the username root and the password set here.
Instance name EcsQuickStart You can customize the instance name.

4.  On the Group settings page, all configurations remain the default option, confirm the order, and Create an instance.

2. Install JDK

1.  After creating the resource, click the right side of the page icon, switch to the Web Terminal to connect to the server.

1

2.  Run the following command to view the JDK Version in the yum source.

yum list java*

3.  Run the following command to install JDK1.8 using yum.

yum -y install java-1.8.0-openjdk*

4.  Run the following command to check whether the installation is successful.

java -version

If the following figure is displayed, JDK installation is successful.

2

3. Install MySQL Database

1.  Run the following command to download and install the official MySQL Yum Repository.

wget http://dev.mysql.com/get/mysql57-community-release-el7-10.noarch.rpm
yum -y install mysql57-community-release-el7-10.noarch.rpm
yum -y install * --nogpgcheck mysql-community-server

3

2.  Run the following command to start the MySQL database.

systemctl start mysqld.service

3.  Run the following command to view the initial MySQL password.

grep "password" /var/log/mysqld.log

4

4.  Run the following command and enter the MySQL initial password in the previous command to sign in to the database.

mysql -uroot -pMySQL-uroot-P

5

5.  Run the following command to modify the MySQL default password.

set global validate_password_policy=0;  #Modify the password security policy to low (only verify the password length, at least 8 digits).
ALTER USER 'root'@'localhost' IDENTIFIED BY '12345678';

6.  Run the following command to grant the root user the remote management permission.

GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '12345678';

7.  Enter exit to exit the database.

4. Install Tomcat

1.  Run the following command to download the Tomcat package. If the image is invalid, check the latest tomcat version and replace it.

wget --no-check-certificate https://labfileapp.oss-cn-hangzhou.aliyuncs.com/apache-tomcat-8.5.72.tar.gz

6

2.  Run the following command to decompress the downloaded Tomcat package.

tar -zxvf apache-tomcat-8.5.72.tar.gz

3.  Run the following command to modify the Tomcat name.

mv apache-tomcat-8.5.72 /usr/local/Tomcat8.5

4.  Run the following command to authorize Tomcat.

chmod +x /usr/local/Tomcat8.5/bin/*.sh

5.  Run the following command to change the default port number of Tomcat to 80.

Note: the default port number of Tomcat is 8080.

sed -i 's/Connector port="8080"/Connector port="80"/' /usr/local/Tomcat8.5/conf/server.xml

7

6.  Start Tomcat.

/usr/local/Tomcat8.5/bin/./startup.sh

5. Access Tomcat

1.  Open the browser and enter the public IP address of the ECS instance in the address bar, for example, 139.0.0.1

If the following interface is displayed, the Tomcat installation configuration is successful.

8

2.  At this point, Java Web development environment has been built.


>> Get hands-on experience with this tutorial in a lab environment.

0 1 0
Share on

Alibaba Cloud Community

1,061 posts | 259 followers

You may also like

Comments