Complete Tutorial on Deploying Java Web Project on Linux Server

Complete Tutorial on Deploying Java Web Project on Linux Server

Most of this article refers to other tutorials on the Internet. It is a summary after actual operation. I hope it can be helpful to you who are deploying projects.

Basic environment: Centos7, tomcat8, jdk8, MySQL5.6, nginx

Install JDK

yum install java-1.8.0-openjdk* -y

Use yum to install, no need to configure the system environment, JDK is installed after executing this command.

Install MySQL

We use MySQL here. If you use MariaDB, it is usually installed on the cloud server and you only need to upgrade it.

Installation steps:

# wget http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm
# rpm -ivh mysql-community-release-el7-5.noarch.rpm
# yum install mysql-community-server

Restart the MySQL service:

# service mysqld restart

After restarting, we use the following command to enter MySQL, because MySQL has no password by default.

# mysql -u root

After entering MySQL, we use the following MySQL

set password for 'root'@'localhost' =password('password');

At this point, the MySQL database is basically installed. Sometimes during the development process, for convenience, you want to remotely connect to the online database through a local visualization tool. In this case, you can run the following command to open the remote connection to the database.

grant all privileges on *.* to root@'%'identified by 'password';

Install tomcat

Tomcat's deployment is the simplest:

1. Download directly and drag it to the /home folder of Linux (the download version is as follows);

2. Use Xftp to drag the packaged war file to the webapps folder. This operation is no different from the operation under Windows, so I won’t go into details.

3. Start the tomcat server command:

Stop service command:

Execute trace log command

cd /home/apache-tomcat-8.5.23/bin
nohup ./startup.sh &

Enter the editor to make changes. After the changes are completed, click esc, then enter :wq to save and exit. After restarting Tomcat, the configuration will take effect.

Using Nginx as a proxy server

1. Install gcc g++ development library

Install make:

Install g++:

yum -y install gcc automake autoconf libtool make

2. Select the installation file directory

You can choose any directory, in this article, we choose cd /usr/local/src

cd /usr/local/src

3. Install the PCRE library

ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/ Download the latest PCRE source package and use the following commands to download, compile and install the PCRE package:

cd /usr/local/src
wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.39.tar.gz
tar -zxvf pcre-8.37.tar.gz
cd pcre-8.34
./configure
make
make install

4. Install zlib library

Download the latest zlib source package from http://zlib.net/zlib-1.2.11.tar.gz and use the following commands to download, compile and install the zlib package:

cd /usr/local/src
 
wget http://zlib.net/zlib-1.2.11.tar.gz
tar -zxvf zlib-1.2.11.tar.gz
cd zlib-1.2.11
./configure
make
make install

5. Install openssl (some vps do not have ssl installed by default)

cd /usr/local/src
wget https://www.openssl.org/source/openssl-1.0.1t.tar.gz
tar -zxvf openssl-1.0.1t.tar.gz

6. Install nginx

Nginx generally has two versions, stable version and development version. You can choose one of these two versions according to your purpose. The following are the detailed steps to install Nginx in the /usr/local/nginx directory:

cd /usr/local/src
wget http://nginx.org/download/nginx-1.1.10.tar.gz
tar -zxvf nginx-1.1.10.tar.gz
cd nginx-1.1.10
./configure
make
make install

7. Configure nginx

Because apeache may occupy port 80, try not to modify the apeache port. We choose to modify the nginx port.

In Linux, modify the path /usr/local/nginx/conf/nginx.conf. In Windows, modify the installation directory\conf\nginx.conf.

Change the port to 8090 and localhost to your server IP address.


8. Restart, shut down, and start nginx

start up

Startup code format: nginx installation directory address -c nginx configuration file address

For example:

[root@LinuxServer sbin]# /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf

stop

1. Check the process number

Find the nginx master port

2. Kill the process

[root@LinuxServer ~]# kill -QUIT 2072

Restart

1. Verify whether the nginx configuration file is correct

Method 1: Enter the nginx installation directory sbin and enter the command ./nginx -t

The following shows that nginx.conf syntax is ok

nginx.conf test is successful

This indicates that the configuration file is correct!

Nginx is configured correctly. We can execute the restart Nginx command by entering the nginx executable directory sbin and entering the command ./nginx -s reload .

Summarize

The above is the complete tutorial on deploying JavaWeb project on Linux server introduced by the editor. I hope it will be helpful to everyone. If you have any questions, please leave me a message and the editor will reply to you in time. I would also like to thank everyone for their support of the 123WORDPRESS.COM website!
If you find this article helpful, please feel free to reprint it and please indicate the source. Thank you!

You may also be interested in:
  • Idea2020.2 Detailed explanation of how to create a JavaWeb project (deploy Tomcat)
  • Baota panel configuration and deployment javaweb tutorial (the most complete on the Internet)
  • Detailed steps for deploying Java Web projects to the server
  • How to deploy JavaWeb project to Tomcat server in IDEA
  • A brief discussion on the web.xml configuration deployment descriptor file in JavaWeb
  • Detailed steps for deploying a Java Web project to Alibaba Cloud Server
  • How to deploy javaweb project to linux
  • Tencent Cloud deployment javaWeb project implementation steps

<<:  Complete steps for vue dynamic binding icons

>>:  Detailed analysis of the parameter file my.cnf of MySQL in Ubuntu

Recommend

How to obtain root permissions in a docker container

First, your container must be running You can vie...

HTML+CSS project development experience summary (recommended)

I haven’t updated my blog for several days. I jus...

Thoroughly understand JavaScript prototype and prototype chain

Table of contents Preface Laying the foundation p...

React realizes secondary linkage effect (staircase effect)

This article shares the specific code of React to...

Linux Dig command usage

Dig Introduction: Dig is a tool that queries DNS ...

MySQL trigger usage scenarios and method examples

trigger: Trigger usage scenarios and correspondin...

How to implement Docker to dynamically pass parameters to Springboot projects

background Recently, some friends who are new to ...

Several ways to manually implement HMR in webpack

Table of contents 1. Introduction 2. GitHub 3. Ba...

Vue detailed explanation of mixins usage

Table of contents Preface 1. What are Mixins? 2. ...

Implementing simple chat room dialogue based on websocket

This article shares the specific code for impleme...

What is this in JavaScript point by point series

Understand this Perhaps you have seen this in oth...