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:
- One server (this article uses Alibaba Cloud's lightweight server)
- A javaweb project that can be run locally (this article uses the ssm+mysql project)
- 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
- Enter the Alibaba Cloud console
- Choose to reset the system
- Select System Mirror—> CentOS 7.3
- Click to confirm replacement
- Waiting for successful replacement
Modify server login password
- Change the password of the server
- 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
First modify the configuration of pom.xml to change the packaging method to war package
Open maven and select clean to run
Select the package and run it
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
Enter the Project Settings interface, open the Artifacts,
click the + sign, select Web Application: Exploded (publish the project in the form of a folder) —> From Modules...
Select your project, click ok
Click the + sign to select Web Application: Archive (publish the project in the form of a war package) —> select the file you just generated
Select this newly generated war package and click Apply —> OK
Click Build at the top of the compiler and select Build Artifacts...
Select the war package file just generated and click Build to
find the storage path of the generated war package.
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
https://downloads.apache.org/tomcat/tomcat-9/v9.0.40/bin/apache-tomcat-9.0.40.tar.gz
Download completed:
After decompression is complete:
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
restart the firewall:
Modify the Alibaba Cloud firewall:
In addition to modifying the server firewall, you can also modify the Alibaba Cloud firewall configuration.
Ready to take off:
Use the browser to visit the address ip:8080
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.
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.
Use use test; use the database to
execute the sql file
source /root/library.sql uploaded to /root/. If
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.
Enter tomcat's conf path and
modify the configuration file
vi server.xml
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
To be continued...
How to install the ssl certificate will be updated later