Java deployment in linux
Note: Here we only record the steps for deploying the java war package and some linux commands. Installation and deployment of JDK, tomcat, redis, and nginx in linux are not discussed and documented.
1. Prepare the war package.
Take the project I currently participate in as an example. We use maven to build the project automatically, first clean the jar package of the maven project, and then maven install to prepare the jar, then, use maven install to create a war package for the project to be deployed.
2. Upload the war package and start tomcat
Use SSH Secure Shell Client (or SecureCRT_6.5) to log on to the linux server.
Ps-ef | grep tomcat // view the tomcat process. You can obtain the directory of the tomcat server.
Cd/tomcat server directory // open the tomcat root directory
Ll // or use ls to view the structure in this directory
Cd/apache-tomcat-6.0.37/bin // open the tomcat bin directory
./Shutdown. bat // shut down the currently running tomcat server. Another way is to directly kill the process. After ps-ef | grep tomcat, kill-9 tomcat process number
Cd ../webapp // open the webapp directory
Rm-rf XXXX * // delete a file or folder containing XXXX (Project war package name)
Then, use SSH Secure File Transfer Client or another FTP upload tool to put the locally prepared war package in the directory of tomcat webapp on the server, that is, the Directory of the File just deleted.
Cd ../bin // return to the bin directory
./Startup. bat // start tomcat
Cd ../logs // open the tomcat log directory
Tail-f catalina. out // open the log to check whether tomcat is started properly
Ctrl + C jump out
3. Open a browser to access the project homepage. If there is no problem, transfer it to the test.