We are already aware of the deployment of Java Web projects on local machines (whether Windows or Linux), so how do we deploy Java Web projects on cloud servers? In fact, it is very simple, and it is still inseparable from the three points of Web project deployment:
① Basic JDK environment
② A Web server. Such as Tomcat, JBoss
③ A database. Such as: mysql
For the deployment of Java Web projects on cloud servers, the deployment under Windows and Linux is the same in normal times. At most, it can only operate in pure command mode. In fact, the process is the same.
Since it is the deployment of a Java Web project, it is natural to configure the relevant environment first. That is: first set up a Java development environment on the cloud host, such as the installation of OpenJDK, the installation of Tomcat, and the installation of Mysql database.
If we want to deploy a Java Web project, we must at least upload the project to a cloud server. In fact, the process is very simple, basically the following three steps:
① Package upload: package the project into a war file, and then use it to upload to a remote server (export the project as a .war file directly in Eclipse).
② Move the war file to webapps under the Tomcat directory.
③ Restart Tomcat and visit our project.
In this process, we need to pay attention. Because in general, as a Web project, we must have the use of a database. So what about the database part? In fact, we only need to dump our existing database as a sql file, and then upload the sql file to the cloud server for execution. Take mysql as an example, do the following:
① Dump as sql script and upload: first convert the database used by our project to sql file locally and upload it to the cloud server (you can use Navicat to dump the database into .sql file).
② Execute sql: Then enter mysql to execute the sql file. (If the server is equipped with Navicat, you can directly use Navicat to execute the .sql file. Before execution, you need to select the database that stores the table, and it should be consistent with the database name contained in the database connection statement in the code).