Quickly build java web development environment in centos8

Time:2020-11-27

After recording the learning process, Bi set made a small project, but it was not deployed on the server. Now start building the centos8 server environment.

Install JDK

1. Execute the following command to view JDK1.8 version in Yum source.

yum list java-1.8*

2. Execute the following command to install JDK1.8 using yum.

yum -y install java-1.8.0-openjdk*

3. Execute the following command to check whether the installation is successful.

java -version

If the version information is shown in the figure below, it indicates that the JDK installation is successful
Quickly build java web development environment in centos8

Install MySQL database

1. Execute the following command to download and install the official Yum source of MySQL

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 mysql-community-server

Note that when the third command is executed, it may appear
Unable to find a match: MySQL community server error, as shown in the figure below
Quickly build java web development environment in centos8
In this case, first execute:yum module disable mysql
Re execution:yum -y install mysql-community-server
The following figure shows that the installation is successful
Quickly build java web development environment in centos8
2. Execute the following command to start MySQL database.

service mysqld start

3. Execute the following command to view the initial password of MySQL.

grep 'temporary password' /var/log/mysqld.log

Quickly build java web development environment in centos8
4. Execute the following command to log in to the database.

mysql -uroot -p

5. Execute the following command to modify the password security policy and MySQL default password

set global validate_password_policy=0;
ALTER USER 'root'@'localhost' IDENTIFIED BY '12345678';

6. Execute the following command to grant remote management rights to root user.

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

7. Enter quit database

Note 1: you can enter the following command to view the status of firewall. If you need to open port 3306, the following are common commands for firewall
Systemctl status firewalld view firewall status
Systemctl start firewalld
Firewall CMD -- zone = public -- add port = 3306 / TCP -- permanent open a port
Firewall CMD -- reload restart
Firewall CMD -- zone = public -- List ports to view the opened ports
Firewall CMD -- zone = public -- remove port = 3306 / TCP -- persistent to close a port
Note 2: if it is an alicloud server, you need to release port 3306 in the security group.

8. Navcat remote connection test. If the connection fails, please refer to the above precautions.
Quickly build java web development environment in centos8

Install Tomcat

1. Execute the following command to download the Tomcat package.

wget https://mirrors.bfsu.edu.cn/apache/tomcat/tomcat-8/v8.5.59/bin/apache-tomcat-8.5.59.tar.gz

2. Execute the following command to unzip the Tomcat package just downloaded.

tar -zxvf apache-tomcat-8.5.59.tar.gz 

3. Execute the following command to move Tomcat to the desired directory.

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

4. Execute the following command to authorize Tomcat.

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

5. Change the default port 8080 of Tomcat to the default port 80 of browser.

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

see server.xml
Quickly build java web development environment in centos8
6. Start Tomcat.

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

7. Visit Tomcat.
Open the browser and enter the public IP address of the server. If the following interface appears. Then Tomcat is installed and configured successfully.
Quickly build java web development environment in centos8
So far, the Java Web development environment is completed. (this tutorial refers to Alibaba cloud’s rapid construction of Java Web development environment)