Tomcat is the most well-known Java container, it is not easy to install using Tomcat 7 under Windows, this article takes Windows 2008R2 x64 as an example.
1, download and install JDK, set Java_home (slightly)
2. Download Tomcat 7
Since we are x64 system, we need to download x64-bit version of Tomcat, if it is x86 version, memory usage has 4G limit, other restrictions are unknown.
Download here to the D packing directory, the correct download version is as follows:
Http://mirrors.ustc.edu.cn/apache/tomcat/tomcat-7/v7.0.70/bin/apache-tomcat-7.0.70-windows-x64.zip
2. Right-click to unzip the package to D:\apache-tomcat-7.0.70
3. Basic adjustment
A, modify the D:\apache-tomcat-7.0.70\conf\server.xml, modify
<connector port= "8080" protocol= "http/1.1" connectiontimeout= "20000" server= "Nginx" enablelookups= "false" uriencoding= "UTF-8" compression= "on" useSendfile= " False " Compressionminsize= "2048" nocompressionuseragents= "Gozilla,traviata" redirectPort= "8443" />
The contents of the set are mainly masquerading as headers, setting character sets, gzip compression.
(If Tomcat has nginx,gzip in front, it does not have to be turned on)
(Windows version tomcat comes with Tcnative-1.dll, which is Apr mode, no need to ask)
B. Create a file
D:\apache-tomcat-7.0.70\lib\org\apache\catalina\util\ServerInfo.properties
The contents are as follows
Server.info=apache Tomcat
C, set java_opts parameters, edit D:\apache-tomcat-7.0.70\bin\catalina.bat, about 185 lines,
Set "java_opts=-server-xms1024m-xmx1024m-xx:permsize=64m-xx:maxpermsize=128m"
Additional parameters should be added as needed.
4. Turn on Tomcat
Put your application into D:\apache-tomcat-7.0.70\webapps, double-click D:\apache-tomcat-7.0.70\bin\startup.bat, no accident, there will be a CMD interface display tomcat details. Using a browser to access the local 8080 port, the Tomcat Welcome page is displayed.
5. Firewall
In order for someone else to access Tomcat, you must release port 8080 in the Windows Firewall-Advanced settings
Summary
You think you're done with this? It's probably why Tomcat is so easy. Everything is running in the foreground because of Tomcat.
I'll say a few questions about how Tomcat is deployed in the foreground:
A, limited screen, lack of error logs, difficulty in troubleshooting
b, the operating system does not start automatically after restarting, you must manually log in, and then double-click Startup.bat.
(Ps:windows has an automatic update and requires a restart of the bad features)
C, running a number of Tomcat, operation is difficult, which is which silly division, novice do not know the need to double-click which few Startup.bat
---------------------------the evil dividing line--------------------------------------
The solution is to have Tomcat run in the background and start with the operating system.
1, edit the file D:\apache-tomcat-7.0.70\bin\service.bat, about 162, 163, 164 lines,
--jvmoptions "-dcatalina.home=%catalina_home%;-dcatalina.base=%catalina_base%;-djava.endorsed.dirs=%catalina_ Home%\endorsed;-djava.io.tmpdir=%catalina_base%\temp;-djava.util.logging.manager= Org.apache.juli.classloaderlogmanager;-djava.util.logging.config.file=%catalina_base%\conf\logging.properties; -xx:permsize=64m;-xx:maxpermsize=128m "^--jvmms ^--jvmmx 1024
Here is the JVM memory, default 128 and 256, if you have only one Tomcat instance, double-clicking Tomcat7w.exe will pop up a dialog box, or you can set the JVM parameters.
This is why many people use Startup.bat to start normally, and the Windows service does not start properly. Because the Windows service does not read the java_opts inside the Catalina.bat.
2. Install Tomcat Service
D:CD D:\apache-tomcat-7.0.70\binservice Install tomcat7-8080net start tomcat7-8080
In fact, the service install can be, the default name is TOMCAT7, but multiple tomcat instances, it will cause a conflict of services name, so it is better to specify a name, it is recommended to name the business, such as Tomcat7-site1,tomcat7-app2
Be sure to modify service.bat before installing the Tomcat service, or you will need to uninstall the Tomcat service before reinstalling the Tomcat service.
D:CD D:\apache-tomcat-7.0.70\binnet Stop Tomcat7-8080service Remove tomcat7-8080
The Tomcat service is manual by default and runs the command services.msc into the Windows service, allowing the Tomcat service to boot automatically.
The process name of the Tomcat daemon is called Tomcat7.exe, and if Tomcat is running in the foreground, then the process is called Java.exe
3. Open multiple Tomcat instances
A, copy the Tomcat directory, modify the port in Server.xml, do not conflict with other instances
b, install the Tomcat service ditto, the service name does not conflict with other instances
The full text is finished, the CMD chart is ready to fill.
This article is from the "Focus on Linux Operations" blog, please be sure to keep this source http://purplegrape.blog.51cto.com/1330104/1827142
Windows installation Tomcat 7