[Linux Virtual Machine] JDK, Tomcat, MySQL installation and configuration explanation

Table of contents

1. Upload the installation package to the server

2. JDK and Tomcat installation

2.1 Unzip the installation package

2.2 Configure JDK environment variables

2.3 Configure Tomcat environment

3. MySQL installation and configuration

3.1 Delete the default database

3.2 Install the mysql installation package

 3.3 mysql initialization operation

4. Backend interface deployment

 4.1 Import project.war

4.2 Create a new database

4.3 Run server project tests


1. Upload the installation package to the server

1. Use the MobaXterm remote tool I used in my last blog to connect to the virtual machine IP address, and then create a folder to store jdk and other decompressed packages.

2. Find the downloaded file path and use drag and drop (copy and paste) to upload it.

3. Pay attention to the upload progress in the lower left corner. After the upload is completed, you can view the file on the virtual machine.

              

Why use MobaXterm tool?

Compared with other server connection tools, such as: Xshell and FinalShell< a i=4>;

Xshell:

  • Commercial software: Xshell is commercial software and requires purchasing a license to use its advanced features.
  • Windows only: Xshell is mainly available for Windows operating systems and has limited support for other operating systems.

FinalShell:

  • Relatively few functions: Compared with other tools, FinalShell has relatively few functions and may not be suitable for some advanced remote management needs.
  • Simple user interface: FinalShell's user interface is relatively simple and may not be intuitive and easy to use.

 

        The MobaXterm tool is easier to use than others, but the functions of MobaXterm are relatively complex, and it may take some time for novice users to become familiar with and master it. (The last thing is that Xshell does not support the ability to quickly view files and upload files using drag-and-drop method)

 

2. JDK and Tomcat installation

2.1 Unzip the installation package

Unzip command:

tar  -zxvf   压缩文件名.tar.gz

Parameter description:
z: Indicates that the compressed file is gzip compressed
x: Indicates decompression, if the c parameter is used, it means compression -C: Extract to the specified directory, such as: tar - zxf abc.tar.gz -C /root Unzip abc.tar.gz to the root directory. f: The file name to be operated
v: Display the detailed processing process

2.2 Configure JDK environment variables

1. Enter the configuration file instructions:

vi /etc/profile

2. Add java environment variables to the configuration file:

#java environment
export JAVA_HOME=/javaxl/software/jdk1.8.0_151(jdk解压路径)
export JRE_HOME=${JAVA_HOME}/jre
export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib
export PATH=${JAVA_HOME}/bin:$PATH

 

3. Set the environment variable to take effect:

source /etc/profile

 

2.3 Configure Tomcat environment

First, enter the tomcat bin directory and you can see the startup.sh file that starts the service.

But now 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.

 

instruction:


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

But now it is still inaccessible and the firewall rules need to be refreshed.

Firewall rule instructions:

firewall-cmd --reload

Then start the Tomcat service for access:

./startup.sh

Other instructions:

  • Turn off firewall
systemctl stop firewalld.service
  • Start automatically at boot
systemctl enable firewalld.service

3. MySQL installation and configuration

3.1 Delete the default database

There should be default data in CentOS. First check the virtual machine database instructions:

rpm -qa|grep mariadb

 Then run the command to delete the local default database:

#rpm -e --nodeps 本机默认数据库
rpm -e --nodeps mariadb-libs-5.5.56-2.el7.x86_64

3.2 Install the mysql installation package

1. Unzip mysql to the specified file path

First you must have the mysql-5.7 folder

tar -xvf mysql-5.7.35-1.el7.x86_64.rpm-bundle.tar -C mysql-5.7

2. Start installation

rpm -ivh mysql-community-common-5.7.23-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.23-1.el7.x86_64.rpm //客户端
 
rpm -ivh mysql-community-server-5.7.23-1.el7.x86_64.rpm //服务端

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

 

 3.3 mysql initialization operation

1. Start the MySQL service

systemctl start mysqld

2. Check the initialization password

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

 

3. Log in to mysql and lower the password setting level.

#设置密码校验策略(0 or LOW),要不密码太简单不让你过
set global validate_password_policy=0;
#设置密码校验长度,要不密码太短不让你过(多次测试发现密码最小长度为4位)
set global validate_password_length=4;

4. Change the password and refresh the service

#更新密码
set password = password("123456");
#输入后使修改生效还需要下面的语句
FLUSH PRIVILEGES;

5. Grant permissions to the root user

#Centos7下无法远程连接mysql数据库因为数据库没有授权,设置允许以root身份远程登录mysql
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '123456' WITH GRANT OPTION;
#输入后使修改生效还需要下面的语句
FLUSH PRIVILEGES;

6. Open Navicat to test the connection

4. Backend interface deployment

 4.1 Import project.war

How to import a project into a war, recommended article:IDEA’s most detailed graphic tutorial on how to package a web project into a war package - Keeling1720

Then import the back-end project into a .war package and copy it to the virtual machine Tomacat/webapps/ path

4.2 Create a new database

Create a database to use based on imported projects

4.3 Run server project tests

1. Restart the Tomcat service

Because new files have been imported, the tomcat service needs to be restarted.

 

2. Access the server test

        Because this project uses jwt technology, you need to log in to access it. However, since this tutorial is about deploying a back-end project and not deploying a front-end, it is inconvenient to perform login verification. As long as this interface does not appear, it means the access is successful. 

The next article explains how to deploy front-end projects, so stay tuned!

Guess you like

Origin blog.csdn.net/Justw320/article/details/134141731