An Apache versus Tomcat connection
Apache supports static pages, and Tomcat supports dynamic, such as Servlets.
For general use of Apache+tomcat, Apache is just a forwarding, and the processing of JSPs is handled by Tomcat.
Apache can support Php\cgi\perl, but to use Java, you need Tomcat to support Apache in the background and transfer Java requests from Apache to Tomcat processing.
Apache is a Web server , Tomcat is an application (Java) server, it is just a servlet (JSP also translated into a servlet) container, can be considered an Apache extension, However, it can be run independently of Apache .
These two can be compared in the following points:
1, both are developed by Apache organizations
2, both have the function of HTTP service
3. Both are free
Apache is dedicated to providing HTTP services, and related configuration (such as virtual host, URL forwarding, etc.)
Tomcat is a JSP server developed by Apache in accordance with the Java EE JSP and servlet standards.
The benefits of consolidation are:
If the client is requesting a static page, only the Apache server responds to the request
If the client requests a dynamic page, the Tomcat server responds to the request
Because JSP is a server-side interpretation code, consolidation can reduce the service overhead of Tomcat
A simple way to integrate Apache with Tomcat under Linux II
Transferred from: http://hi.baidu.com/%D0%A1%BA%EC%DD%AB%DC%C4/blog/item/52154ec5a5c02ca08226acf9.html
1, prepare, download the required documents. This assumes that you have properly installed the JDK.
To download the required files on the Apache official website:
where httpd and jakarta-tomcat-connectors are source packages, Apache-tomcat are binary packages.
2, install Apache.
# tar XZVF httpd-2.2.0.tar.gz
# CD httpd-2.2.0
# make Install
3, install Tomcat.
# CP apache-tomcat-5.5.12.tar.gz/usr/local/
# tar XZVF apache-tomcat-5.5.12.tar.gz
# ln-s apache-tomcat-5.5.12 Tomcat
4. Compile and generate MOD_JK.
# tar XZVF jakarta-tomcat-connectors-1.2.15-src.tar.gz
# CD Jakarta-tomcat-connectors-1.2.15-src/jk/native
Build two profiles mod_jk.conf and workers.properties under/usr/local/apache2/conf/.
# VI Mod_jk.conf
Add the following content:
# indicate the location of the working file Workers.properties required for the MOD_JK module to work
# Where to put JK logs
# Set the JK log level [Debug/error/info]
# Select the log format
# jkoptions indicate to send SSL KEY SIZE,
Jkoptions +forwardkeysize +forwarduricompat-forwarddirectories
# Jkrequestlogformat Set the request format
# Send all servlet and JSP requests through the AJP13 protocol to Tomcat for Tomcat to handle
# VI Workers.properties
Add the following content:
# Defining a worker named Worker1 and of type ajp13
# Set Properties for Worker1
Then configure the httpd.conf to make the following changes:
Modify Listen 80 to Listen 127.0.0.1:80
Modify ServerName to ServerName localhost:80
Add index.jsp to DirectoryIndex
My Web page is placed under/var/wwwroot, so I want to modify the DocumentRoot
<directory "/var/wwwroot" >
Options includes FollowSymLinks
Allow from all
<directory "/var/wwwroot/web-inf" >
Deny from all
To add a statement about loading MOD_JK:
LoadModule Jk_module modules/mod_jk.so
Finally, edit the Tomcat configuration file Server.xml and add the following in the host section:
<context path= "" docbase= "/var/wwwroot" debug= "0" reloadable= "true" crosscontext= "true"/>
Create a index.jsp under/var/wwwroot, launch Apache and Tomcat, access the http://localhost/with a browser, and you should see the correct page.
Three Windows Apache and Tomcat integration
Transferred from: http://bbs.blueidea.com/thread-2873268-1-1.html
1. Apache 2.2.4
2. Tomcat 6.0.16
: http://apache.mirror.phpchina.co ... e-tomcat-6.0.16.zip
: Http://cds.sun.com/is-bin/INTERS ...-windows-i586-p.exe
If only the application, you can also choose to install the JRE, because the JRE is relatively small:)
: Http://www.apache.org/dist/tomca ... 2.26-httpd-2.2.4.so
Note that the JK version must be the same as the Apache version. If your version and my different, can go to the official website to download, there are many versions, applicable to various operating systems, download the applicable can, address: http://www.apache.org/dist/tomcat/tomcat-connectors/jk/binaries/
To start the installation:
The installation order of the software can be adjusted appropriately, but the JDK (JRE) must be installed before Tomcat:
1. Installing the JDK (JRE)
The default, custom installation is available here. After the installation is complete, set your system environment variables as follows: My Computer, Properties----Advanced environment variables (System variables, non-user variables are added here)
Java_home = D:\Program files\java\jdk1.6.0_07
CLASSPATH =.; %java_home%\lib\tools.jar;%java_home%\lib\dt.jar;
Note that the Java_home path changes to your actual installation path. The other two does not change.
2. Installing Apache
Note here that if you have IIS installed and have 80 ports, you can choose to disable IIS or specify a different port for IIS, or specify a different port for Apache to set according to the actual situation. In the Apache installation process to set up network domain and server name localhost, set your email address (this must be set, or Apache will not start up).
After installation, if Apache is using port 80, enter http://localhost in the browser, if you are using a different port such as 81, then enter http://localhost:81, you will see the success of Apache page. At this point Apache has run, in the system tray can see its icon, double-click Open can control Apache service, we also install Tomcat and JK, so now choose Stop Stop Apache service.
3. Install Tomcat
Unzip the Tomcat to D:\Program Files\tomcat and set the environment variable:
Catalina_base = D:\Program Files\tomcat
Catalina_home = D:\Program Files\tomcat
Running D:\Program Files\tomcat\bin\startup.bat launches Tomcat, and the Tomcat page indicates a successful installation.
4. Installing JK
Copy the mod_jk-1.2.26-httpd-2.2.4.so to the D:\Program files\apache2.2\modules.
The configuration of the server is as follows:
1. Configuring Tomcat
Look for the Conf/server.xml file under the Tomcat directory and add the following statement in <context path= "" docbase= "E:\wwwroot" reloadable= "true" crosscontext= "true"/>
Here, if path is not empty, the virtual directory is set, and the value of path is the virtual directory name.
Look for the conf/workers.properties file under the Tomcat directory and compare the text below, if there is a difference, modify it with the text below.
Workers.java_home=d:\program files\java\jre1.6.0_07 #让mod_jk模块知道jre的位置
worker.ajp13.port=8009 #工作端口, do not modify if not occupied
Worker.ajp13.host=localhost #本机, if the above Apache host is not localhost, make the corresponding modification
Worker.ajp13.lbfactor=1 #代理数, no modification
If this file does not exist, it is created from the above content. Any changes to the Tomcat settings will be restarted to take effect.
2. Configure Apache
Open the httpd.conf under D:\Program files\apache2.2\conf, and at the end, add the following code and save it.
LoadModule Jk_module modules\mod_jk-1.2.26-httpd-2.2.4.so
Jkworkersfile "D:\Program files\tomcat\conf\workers.properties"
Jklogfile "D:\Program Files\tomcat\logs\mod_jk2.log"
#如果非虚拟主机, <virtualhost localhost> and final </VirtualHost> comments can be removed
<directory "E:/wwwroot" >
#您的站点项目所在路径, should be the same as the directory settings in Tomcat, it is said that the above two must be set at the same time to take effect, there is no time to try different times what happens
DirectoryIndex index.html index.htm index.jsp
Customlog Logs/shsc-access_log.txt Common
#让Apache支持对servlet传送, used for Tomcat parsing
#让Apache支持对jsp传送, used for Tomcat parsing
#让Apache支持对. Do transfer for Tomcat parsing
#开头的行为注释, you can delete it. Here the configuration I was to set up the virtual directory, re-specify the Servername,documentroot path to configure the site, in fact, Apache configuration can be very flexible, you can also do not use the virtual directory, and directly to modify the default configuration of the site, Use any text editing tool, search for related items such as servername,documentroot,serveradmin, and then change the configuration of the item according to your actual situation. I recommend that you try a lot of different configurations, which is a fun experience.
After all the modifications are complete, double-click the Apache icon in the system tray and click Start to start the Apache service.
Enter http://localhost/in the address bar separately, and http://localhost:8080/if the results are the same, Apache and Tomcat are integrated successfully
1. One boot Apache appears "Windows cannot start Apache2 on local computer" error
Most of the problem is the port, there may be other software use 80 port, it is best to change the Apache port to 81 port.
2.windows View 80 port occupancy, suitable for viewing any port
Start – Run –cmd enter Netstat-ano at the command prompt to see all connected PID and find the program corresponding to this PID in Task manager if there is no PID in Task Manager, you can select "View"-"Choose Column" in Task Manager, often We start the application when the system needs to find the port is occupied by other programs, how to know who owns the port we need, many people are more headache, the following is a very simple method, I hope it is useful to everyone.
We need to make sure who's taking our 80 ports.
Execute under Windows command-line window: C:\>netstat-aon|findstr "80″
See, Port is occupied by process number 2044 process, continue to execute the following command:
Avp.exe 2044 Console 0 37,680 K
Very clear, AVP Kappa Monitor 80 port, adjust the Cat network monitoring settings.
Of course, if your 80 port is occupied by another program, kill or adjust the port.
The integration of Apache and Tomcat