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

JavaScript design pattern learning proxy pattern

Table of contents Overview Implementation Protect...

Example of using CSS to achieve floating effect when mouse moves over card

principle Set a shadow on the element when hoveri...

Native JS to implement breathing carousel

Today I will share with you a breathing carousel ...

Use of VNode in Vue.js

What is VNode There is a VNode class in vue.js, w...

Briefly describe mysql monitoring group replication

Original text: https://dev.mysql.com/doc/refman/8...

Detailed steps to install RabbitMQ in docker

Table of contents 1. Find the mirror 2. Download ...

JavaScript to achieve simple drag effect

This article shares the specific code of JavaScri...

Detailed explanation of VUE Token's invalidation process

Table of contents Target Thought Analysis Code la...

Solution to the problem of passing values ​​between html pages

The first time I used the essay, I felt quite awkw...

Building a selenium distributed environment based on docker

1. Download the image docker pull selenium/hub do...

How to hide and forge version number in Nginx

1. Use curl command to access by default: # curl ...