This article explains how to deploy our compiled Javaweb project to Tomcat in a Linux environment, with the overall idea of deploying the Javaweb project to Tomcat in the same way as in Windows, with the following steps and commands.
Note: The JDK must already be installed on Linux before deployment, specifically on how to install the JDK on Linux see: Installing the JDK in a Linux environment
1 Preparatory work
1, download installs Xshell, XFTP (for the remote connection Linux host, the specific self-Baidu)
2, the official website download Linux under the Tomcat installs the package, I use is: apache-tomcat-6.0.45.tar.gz, the direct click can download, of course also can directly to the official website to download: http://tomcat.apache.org/
3, the Javaweb project packaging, such as My project is Cucpayperson, WebApp or Webroot file package into CucPayPerson.tar.gz (this is my practice, and the general practice is to fight the war package)
2 Uploading the engineering code and the Tomcat installation package to the Linux environment
1. Create the Project Deployment directory:
mkdir /app/code
2. Upload the package code file CucPayPerson.tar.gz to the above directory with XFTP
3, Decompression:
tar -xvzf CucPayPerson.tar.gz
4, the final Windows and Linux under the project file system structure comparison is as follows:
3 Installing Tomcat
1. Create a new Tomcat server directory:
mkdir /app/tomcat
2. Unzip the file:
tar xvf apache-tomcat-6.0.45.tar.gz
To the above directory, this time the Tomcat path is:/app/tomcat/apache-tomcat-6.0.45
3. Change the Tomcat folder: apache-tomcat-6.0.45 to Project name: Cucpayperson
mv /app/tomcat/apache-tomcat-6.0.45 /app/tomcat/CucPayPerson
This is because the Linux environment deploys a lot of projects, then we will install a Tomcat server for each project, so a name, the Tomcat path is:/app/tomcat/cucpayperson, the directory structure is as follows:
4 Modifying the Tomcat configuration file
Major changes in port and project deployment paths in Server.xml
1. Enter the Conf folder in Tomcat:
cd /app/tomcat/CucPayPerson/conf
2, modify the content of Server.xml, the implementation:
vi server.xml
Then press I to enter the modification:
Modify the following three parts, click ESC after the modification is complete, and then enter: Wq this saves the exit.
To modify the Shutdown stop service port:
<Server port="9001" shutdown="SHUTDOWN">
To modify the Web login port:
<Connector port="8080" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" />
To modify the project publishing path:
<Host> <Context path="/per" docBase="/app/code/CucPayPerson" debug="0" privileged="true" reloadable="false" /></Host>
Note: If you have multiple Tomcat servers installed for multiple projects, you must ensure that the shutdown service port and the Web landing port are different, and that the project release path is the project code path above
5 starting and stopping the Tomcat server
1. Enter the Tomcat startup directory:
cd /app/tomcat/CucPayPerson/bin
The bin directory has the following files, you can see that there are some of this file, where startup.sh and shutdown.sh are start and stop scripts, respectively
2. Execute the Start command:
nohup ./startup.sh &
The./means to execute the current path under the script file, nohup means the background execution
3. Stop command
shutdown.sh
Or:
shutdown.sh
6 trace log commands during startup
1. Enter the Tomcat log directory:
cd /app/tomcat/CucPayPerson/logs
2. Execute trace log command
tail -100f catalina.out
This command means to dynamically flush the last 100 lines of the trace file Catalina.out
7 See if the project is started
1. Query the project process
ps -ef|grep CucPayPerson
2. Whether the test service has been successfully started
Browser input: Http://10.1.7.88:8080/per, change to the IP or domain name of the Linux host.
8 Mandatory Kill Project Process
In addition to using Tomcat's stop command to stop the project service, you can also kill the process by checking the process ID
1, first get the project process ID
| grep CucPayPerson
2, according to process ID kill process
kill -9 进程号
Over
http://blog.csdn.net/trigl/article/details/51138640//Original
Deploying Javaweb Engineering on Tomcat in a Linux environment