[Linux] Configure JDK&Tomcat development environment, MySQL installation and back-end project deployment

Table of Contents

1. JDK and tomcat installation

2. Install Tomcat

3. MySQL installation

4. Backend deployment

Foreword:

Today we will install JDK, tomcat, and MySQL on Linux. I hope you can find your answer through this blog! ! !

1. JDK and tomcat installation

1.1. First we must have the installation packages of apache-tomcat-8.5.20.tar.gz and jdk-8u151-linux-x64.tar.gz! ! !

1.2. Our Linux server must have a special directory to store these files. Here I create java/softwart and create the java directory.

1.3. Upload apache-tomcat-8.5.20.tar.gz, jdk-8u151-linux-x64.tar.gz to the linux server.

Note:
The tar package is a packaging file. It is a compression and packaging tool on Unix and Unix-like systems. It can package multiple files into one file. The file suffix is tar.
The tar.gz package is a compressed file. The tar file compressed by gzip forms a tar.gz package with the extension tar.gz.
The two files have different purposes. Generally, tar.gz is a source code installation package, which needs to be decompressed and then compiled and installed before it can be executed. The tar package was originally designed to back up files to tape (tape archive), hence the name, and is generally used for file backup.

Because we are using MobaXterm software, it supports direct drag and drop copying.

1.4. Unzip the file (name the jdk according to your own)

tar -xvf compressed file name.tar.gz

Here our decompressed jdk is:

tar -xvf jdk-8u151-linux-x64.tar.gz 

After decompression, you can enter: ll (whether there are already decompressed files)

1.5. Configure environment variables
run:

vi /etc/profile

Add java environment variables to the configuration file:

#java environment
export JAVA_HOME=/javaxl/jdk1.8.0_151 (jdk decompression path)
export JRE_HOME=${JAVA_HOME}/jre
export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib
export PATH=${JAVA_HOME}/bin:$PATH

Save and let the newly set environment variables take effect:

source /etc/profile

Check if java installation is successful

java -version

Second, install Tomcat

2.1. Unzip tomcat to (the version here is based on the name of your installation)

#Unzip tomcat
tar -zxvf apache-tomcat-8.5.20.tar.gz

2.2. After decompression, enter the command

cd apache-tomcat-8.5.20

cdbin

(Enter the bin directory and find the tomcat startup item)

Then enter the command: ./startup.sh

(start tomcat)

./startup.sh

Tomcat cannot be accessed immediately after starting because port 8080 is blocked by the firewall. You can turn off the firewall (not recommended) or configure port 8080 in the firewall.

Enter the command: systemctl status firewalld (View firewall status)

Enter the command: systemctl stop firewalld.service (turn off the firewall)

If you turn off the firewall, it may bring security risks to your computer! ! !

#Open port
firewall-cmd --zone=public --add-port=3306/tcp --permanent
#Update firewall rules
firewall-cmd --reload
#firewalllist
firewall-cmd --zone=public --list-ports
#Firewall status
systemctl status firewalld
#Start firewall
systemctl start firewalld
#Close firewall
systemctl stop firewalld.service
systemctl disable firewalld.service

So here, we should use the development port command! ! !

Enter the command: (open port 3306)

firewall-cmd --zone=public --add-port=3306/tcp --permanent

Enter the command: (open port 8080)

firewall-cmd --zone=public --add-port=8080/tcp --permanent 

#Update firewall rules

firewall-cmd --reload

And check the ports in the firewall list

firewall-cmd --zone=public --list-ports

Visit http://192.168.62.131:8080/. If you see the tomcat management page, it means success.

After importing our background jar package, accessing the specified path will return Json data.

Deploy our OA single project to Linux

Three, MySQL installation

3.1. Uninstall mariadb, otherwise there will be conflicts when installing MySql (check first, then delete and then check)

First check whether mariadb has any impact on the installation of MySQL.

Enter the command: rpm -qa|grep mariadb (View)

Appears: mariadb-libs-5.5.56-2.el7.x86_64 (describe the impact)

Enter the following command:

rpm -qa|grep mariadb

3.2. Extract the MySQL installation package to the specified directory

Enter the command: tar -xvf mysql-5.7.35-1.el7.x86_64.rpm-bundle.tar -C mysql-5.7

(Extract mysql to the specified file)

3.3. Start the installation, -ivh where i means installation, v means display the installation process, and h means display progress

rpm -ivh mysql-community-common-5.7.35-1.el7.x86_64.rpm
rpm -ivh mysql-community-libs-5.7.35-1.el7.x86_64.rpm
rpm -ivh mysql-community-client-5.7.35-1.el7.x86_64.rpm
rpm -ivh mysql-community-server-5.7.35-1.el7.x86_64.rpm

3.4. Start the MySQL service

systemctl start mysqld

3.5 Log in to mysql to change password

 grep "password" /var/log/mysqld.log
mysql -uroot -p

#Set the password verification policy (0 or LOW), otherwise the password is too LOW and will not let you pass

set global validate_password_policy=0;

#Set the password verification length, otherwise the password will not be allowed to pass if it is too short (multiple tests found that the minimum password length is 4 digits)

set global validate_password_length=4;

#update password

set password = password("123456");

#After input, the following statement is needed to make the modification effective.

FLUSH PRIVILEGES;

#You can log out and try to log in again with a new password

exit

#Centos7 cannot remotely connect to the mysql database. The database is not authorized. Remote login to mysql as root is allowed.

GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '123456' WITH GRANT OPTION;

#After input, the following statement is needed to make the modification effective.

FLUSH PRIVILEGES;

#Navicat Link MySQL Test
#View MySQL version
rpm -qa | grep mysql

Open navicat to connect to our database, successful

4. Back-end deployment

4.1 Create database

Create a database name corresponding to the project deployed in tomcat in the database of the virtual machine (Centos), and import the data tables in the project into the database.

4.2. Import .war package

Import the completed war package into the Tomcat webapps file of the virtual machine ( Centos )

4.3. Modify port
Enter the command: firewall-cmd –zone=public –add-port=8082/tcp –permanent (#Open port)

Enter the command: firewall-cmd –reload (#Update firewall rules)

Enter the command: firewall-cmd –zone=public –list-ports (check whether the port is open)

As shown in the figure: Change 8080 to 8082

Enter the command: cd apache-tomcat-8.5.20/conf/ (enter the conf directory)

Enter command: vim server.xml (modify configuration port)

4.4. Enable access

Enter the bin directory of tomcat

Enter the command: ./startup.sh (start Tomcat)