Build a Java deployment environment

yum

Meet yum

yum (Yellow dog Updater, Modified) is a very commonly used package manager under Linux. It is mainly used in distributions such as Fedora, RedHat, and Centos.

The package manager is like an "app store", we can download some apps on the app store.

The function of yum is similar to the dependency management function of Maven. Using Maven can help us install some third-party jar packages conveniently, and yum allows us to install third-party programs conveniently.

Similarly, Github can also function as a "software warehouse", and indeed some programming language package management tools are based on Github (such as Go language). However, Github can not only be used to distribute programs, but also manage source code and perform Collaborative development, while yum and maven are only used to distribute programs

View package list

yum list | grep [软件包关键字]   # 注意, 最好要加上 grep, 否则罗列的内容会非常多, 导致机
器很卡.

Install the package (requires administrator privileges)

yum install [软件包名字]

Uninstall the package (requires administrator privileges)

yum remove [软件包名字]

Precautions 

  • All yum commands can only be used when the network is connected (the cloud server generally has a good network).
  • yum install / yum remove must have administrator privileges (root user).
  • You can use ping www.baidu.com to check the smoothness of the network.

Deploy web projects to Linux

There are 6 steps to build a Java deployment environment.

1. Ensure that the program has been developed and tested.

Add the following code to the pom.xml file of the program :

<!-- 把程打成war包 -->
    <packaging>war</packaging>

    <build>
        <!-- 设置最终生成的包名 -->
        <finalName>blog</finalName>
    </build>

Double click the package 

 

 Generate war package

 

2. Install jdk on the server.

Install via package manager yum

Find jdk1.8 and install it

 

 

Follow the prompts to confirm during the installation. After the installation is complete, you can try to check the jdk version. If you can find it, the installation is successful.

 

When this happens: enter yum install java-devel

 Check again: the installation was successful

3. The server installs the database.

The database management system used here is MariaDB, which was developed under the leadership of the founder of MySQL. MariaDB's transaction-based Maria storage engine replaces MySQL's MyISAM storage engine, and its usage is similar to MySQL.
The following operations are performed as the root user! ! !
Do all of the following steps:

Install mariadb service:

# yum install -y mariadb-server

Install the mariadb command line client:

# yum install -y mariadb

 Install the mariadb C library:

# yum install -y mariadb-libs

Install the mariadb development package:

# yum install -y mariadb-devel

 Start the service:

# systemctl start mariadb

Set the service to start automatically:

# systemctl enable mariadb

Check service status:

# systemctl status mariadb

 If it is as follows, the service is started successfully:

After successful installation, you can connect to the database. The usage is the same as MySQL:

 The database installed at this time does not have a password. You can connect directly by pressing Enter. However, if you want the project to run correctly, you need to set the password to the password of the database to which the project is connected. Modify password statement:

set password for 用户名@localhost = password(‘新密码‘);

 After making the changes, go back to the root directory and copy the database file (that is, the database used by the project). Import the .sql file into the server first. Drag the .sql file directly to the root directory. If it fails, use yum to install the lrzsz tool (drag and drop upload tool) first, and then import the .sql file to succeed.

Then enter the database and run the .sql file.

The database installation is successful here. You can use sql statements to check whether there are any errors in the database tables. 

 

4. Install tomcat on the server.

Download tomcat first, and then transfer it to the server after the download is successful.
Still the same as the database, drag and drop into the Linux directory:
drag and drop tool:

yum install lrzsz

 drag

 Decompression is required after the server: decompression tool:

yum install unzip

 Unzip

After decompression, it is as shown in the figure (you can rename the decompressed file):

5. Transfer the program to the database and place it in the webapps directory of tomcat.

That is, drag and drop the project's war package to tomcat's webapps.

First enter the webapps directory

 

6. Start tomcat.

When I entered the bin directory to start, I found that there was no permission because the .sh file did not have executable permissions set.

Modify permissions: chmod +x ./*.sh 

 Green means it can be executed

Start tomcat

Visit tomcat

If it is the first access, it is generally unsuccessful because the firewall on the cloud platform blocks port 8080. You need to find the corresponding server and configure security rules in the console of the cloud platform. 

 

 Access to tomcat is successful.

Guess you like

Origin blog.csdn.net/qq_59561046/article/details/132195256
Recommended