JavaWeb project deployment server and configure ssl certificate tutorial

JavaWeb project deployment server and configure ssl certificate tutorial

I believe that after learning programming for 1.2 years, you may have learned to write web projects by yourself, but you can only play in your own local area, which greatly discourages the enthusiasm for learning (mainly because you can't make cups with friends). This article is a more detailed web project deployment tutorial starting from configuring the server.

Ready to work:

  1. One server (this article uses Alibaba Cloud's lightweight server)
  2. A javaweb project that can be run locally (this article uses the ssm+mysql project)
  3. Two hands (en...)

Deployment process:
purchase the server —> configure the server’s java environment and mysql, etc. —> mark the local project as a war package and upload it to the server —> configure the tomcat of the server —> start tomcat and prepare to take off —> access

Buy server

Server, then select Ali cloud and Tencent cloud is not all problems

If you are still a student party, there is a student discount of about 10RMB a month.

The author tried it a few days ago and found that Tencent Cloud's student server purchase process is relatively simple.

Configure the server

Configure the server system

The author installed CentOS 7.3 on the server
Insert picture description here

  1. Enter the Alibaba Cloud console
  2. Choose to reset the system
  3. Select System Mirror—> CentOS 7.3
  4. Click to confirm replacement
  5. Waiting for successful replacement

Modify server login password

Insert picture description here

  1. Change the password of the server
  2. Restart server

Install Xshell6 and Xftp6

You can refer to the following link
https://blog.csdn.net/weixin_44678368/article/details/105473780

Use Xshell6 and Xftp6 to connect to the server

You can refer to the following link
https://www.cnblogs.com/honeynan/p/12653526.html

Configure the java environment of the server

The author installed jdk1.8 and
uploaded a linux 64-bit jdk1.8 Baidu cloud download
link: https://pan.baidu.com/s/1dbhAwA0IQ4OW-Ly_uYOxJw
Extraction code: ljep

The specific process can refer to the following link
https://blog.csdn.net/jinhaijing/article/details/82668583

Configure the mysql environment of the server

The author installed mysql5.7

You can refer to the following link
https://blog.csdn.net/lizy928/article/details/82531749?utm_medium=distribute.pc_relevant.none-task-blog-BlogCommendFromBaidu-3.control&depth_1-utm_source=distribute.pc_relevant.none-task- blog-BlogCommendFromBaidu-3.control

In case you unfortunately fail to install MySQL or install two, you must completely uninstall and reinstall. You can refer to the following link.
http://www.lbb.pub/articles/2019/09/09/1568028549819.html

Okay, the feature film begins

First, mark your web project into a war package.
The author here introduces the process of packaging with idea.

Remember to change the database password configuration in the project to your server's database password before packaging! ! !

Make the project into a war package

One, use maven to package
Insert picture description here

First modify the configuration of pom.xml to change the packaging method to war package

Insert picture description here
Open maven and select clean to run

Insert picture description here
Select the package and run it

Insert picture description here
If there is no error, then the project should generate a target folder, which contains the war package that we need to use later.

Two, manual packaging
Insert picture description here

Insert picture description here
Enter the Project Settings interface, open the Artifacts,
Insert picture description here
click the + sign, select Web Application: Exploded (publish the project in the form of a folder) —> From Modules...
Insert picture description here
Select your project, click ok

Insert picture description here
Click the + sign to select Web Application: Archive (publish the project in the form of a war package) —> select the file you just generated
Insert picture description here

Select this newly generated war package and click Apply —> OK

Insert picture description here
Click Build at the top of the compiler and select Build Artifacts...
Insert picture description here
Select the war package file just generated and click Build to
Insert picture description here
find the storage path of the generated war package.
Insert picture description here
Enter the path and copy the war package to the desktop

OK, this is the end of the packaging process!

Configure tomcat for the server

Tomcat installation:

Tar.gz installation and configuration:
https://tomcat.apache.org/download-90.cgi
Insert picture description here

https://downloads.apache.org/tomcat/tomcat-9/v9.0.40/bin/apache-tomcat-9.0.40.tar.gz
Insert picture description here

Download completed:
Insert picture description here
Insert picture description here

After decompression is complete:
Insert picture description here

Development firewall port:

Because port 8080 is not open, the port cannot be accessed from the outside, the way we deal with it is to open this port.
firewall-cmd --permanent --add-port=8080/tcp
Insert picture description here
restart the firewall:
Insert picture description here

Modify the Alibaba Cloud firewall:
In addition to modifying the server firewall, you can also modify the Alibaba Cloud firewall configuration.
Insert picture description here

Insert picture description here

Ready to take off:

Insert picture description here
Use the browser to visit the address ip:8080
Insert picture description here
OK, the tomcat configuration is over!

Import the database

Use Xftp 6 to upload the database sql file to the server /root/ directory

Use mysql -u root -p to log in to the database.
Insert picture description here
Create a new data. The name of this database should correspond to the data connection address configured in your project.
Because I already have a library database, I use the test database as a demonstration.
Insert picture description here

Insert picture description here
Use use test; use the database to
Insert picture description here
execute the sql file
source /root/library.sql uploaded to /root/. If
Insert picture description here
no error is reported, it will be OK, and the database import is over!

Deploy war package

Upload the previously prepared war package to the webapps path of the installed tomcat. It is
recommended to rename the war package before uploading, otherwise the generated war package will generally have a long and smelly name.
Insert picture description here
Enter tomcat's conf path and
Insert picture description here
modify the configuration file
vi server.xml
Insert picture description here

Add the above configuration under the Host node, you can visit without the package name.

OK, everything is ready!

take off

Enter the bin directory of
tomcat./shutdown.sh to stop the tomcat service./startup.sh to
start the tomcat service

Make a visit
Insert picture description here

To be continued...
How to install the ssl certificate will be updated later

Guess you like

Origin blog.csdn.net/u013456390/article/details/112547045