apache2.2+tomcat7.0 Integrated Configuration Detailed

Source: Internet
Author: User
Tags custom name web hosting server port apache tomcat

First, a brief introduction of Apache, Tomcat

Apache HTTP Server (Apache), an open source Web server for the Apache Software Foundation, is one of the most popular Web server software to run on Windows, Unix, Linux and other operating systems. Apache is fast and efficient, but only supports static pages such as HTML (PHP pages are also supported after loading plugins).
Apache Tomcat is a Web server developed jointly by the Apache Software Fund Association and Sun, which supports JSP and Servlet in addition to static pages such as HTML.
In the same operating environment, Tomcat response to static pages is not Apache sensitive, integrated Apache and Tomcat to enable the system to operate in a good environment, improve system efficiency.

Second, the package download

Operating Environment: Windows 7

Apache 2.2 Download: http://httpd.apache.org/download.cgi

Tomcat 7.0 Download: http://tomcat.apache.org/download-70.cgi

JDK 6 Download: http://www.oracle.com/technetwork/java/javase/downloads/index.html

Mod_jk.mo Connection Pack Download: http://apache.etoak.com//tomcat/tomcat-connectors/jk/binaries/windows/

Third, JDK installation

The JDK (Java development Kit) is the Sun's product for Java developers and is the most widely used Java SDK today. The JDK is the core of the entire Java, including the Java Runtime environment and the base Class library. Common versions include JDK 6, JDK 7, and JDK 8.

After you successfully install JDK 6, you must set environment variables so that the system senses and can invoke JDK 6.


Open Control Panel-system safety-and advanced system settings-environment variables to add the following configuration:

Variable Value Description
Java_home C \ jdk1.6.0_30 Path written to JDK installation
Path ;%java_home%\bin Add this value to path's original value
Classpath ;%java_home%\lib\dt.jar;%java_home%\lib\tools.jar Add this value to the original value of the Classpath

Iv. Installation of Apache 2.2

Run the Apache 2.2 installation package, the installation process can set the domain name, server name and port, Apache default port is 80.

Httpd.conf is the main Apache configuration file, after the Apache installation, you can try to open the "/apache 2.2/conf/httpd.conf" file for modification, the following is the common configuration of Apache:

  1 ServerRoot "C:/Program Files/apache software foundation/apache2.2" 2 # defines the root directory for configuration files, log files, and so on, typically Apache2.2 installed to directory 3 4 &lt ; Ifmodule mpm_winnt.c> 5 threadsperchild 6 Maxrequestsperchild 0 7 </IfModule> 8 # <ifmodule P Refork.c> 9 # ... Ten # </IfModule> # <ifmodule worker.c> 12 # ... # </IfModule> # Apache supports the MPM multi-path processing module, MPM is a multi-process and multi-threaded mode of hybrid Model # Apache defines perwork, worker, BeOS for Unix, OS/2, and BeOS systems Multiple Modes 16 # But only Winnt mode is supported under Windows # Threadperchild defines the number of threads commonly used, Maxrequestsperchild defines the maximum number of threads Listen 8000 20 # Set Apache Of the listening path, the general default is 127.0.0.1:80 port, but because 80 is often occupied by IIS and other processes, 21 # Construction Instead of another port, where the use of 8000 port LoadModule actions_module modules/mod_ actions.so LoadModule alias_module modules/mod_alias.so LoadModule asis_module modules/mod_asis.so-LoadModule au Th_basic_module modules/mod_auth_basic.so # LoadModule Auth_digest_module modules/mod_auth_digest.so 28 ..... 29 ..... 30 # Set Module handling <ifmodule!mpm_netware_module> <ifmodule!mpm_winnt_module> User daemon Group daemon Dule> </IfModule> 38 # If you want to make httpd run as a different user or group, you must start with Root 39 # and then switch it to the user or group you want to use. ServerAdmin [email protected] 42 # define the admin mailbox, when Apache error will send error message to this address ServerName 127.0.0.1 44 # If your host does not have a DNS name registered, Type its IP address here. DocumentRoot "E:/apache Webs" 47 # defines the root directory of the release file <directory/> Order deny,allow     Y from all </Directory> 52 # Configure a default set of directives for a specific directory, prohibit access to the root directory <directory "E:/apache webs/website1"/> 55 Order Deny,allow </Directory> 57 # allows customers to access directories under WebSite1 errorlog "Logs/error.log" # errorlog: Error log file location. LogLevel warn # LogLevel: Controls the number of log messages logged in the error log file. 63 # Includes: Debug,info,notice,warn,error,crit,alert,emerg. <ifmodule log_config_module> Logformat "%h%l%u%t \"%r\ "%>s%b \"%{referer}i\ "\"%{user-agent}i\ "" Combined Logformat "%h%l%u%t \"%r\ "%>s%b" comMon <ifmodule logio_module> logformat "%h%l%u%t \"%r\ "%>s%b \"%{referer}i\ "\"%{user-agent}i  \ "%I%O" Combinedio </IfModule> customlog "Logs/access.log" common </IfModule> 73 # log Access format settings <ifmodule alias_module> scriptalias/cgi-bin/"C:/Program Files/apache software Foundation/Apache2.2/ cgi-bin/"</IfModule> 78 # Set default CGI script directory and alias <directory" C:/Program Files/apache software Foundation/apach E2.2/cgi-bin "> Bayi allowoverride None of the Allow,deny Options None---</dire Ctory> 86 # Setting default CGI script directory properties defaulttype text/plain 89 # Set default MIME content type mime_module> <ifmodule Types Config conf/mime.types AddType application/x-compress.    Z AddType application/x-gzip gz. tgz 94 </IfModule> 95 # Specify MIME type mapping file <ifmodule ssl_module> 98 Sslrandomseed startup builtin Sslrandomseed connect builtin100 </ifmodulE&GT;101 # SSL Default configuration 

After the configuration is complete, launch Apache 2.2 and add the static page index.html in "E:\\apache webs\website1".
Finally, open http://localhost:8000/index.html to test whether Apache 2.2 is functioning properly.

V. TOMCAT 7 Installation

After you run the Tomcat 7 installation package, after the installation is complete, open Control Panel-system security--Advanced system settings-environment variables-to add the following configuration:

Variable Value
Tomcat_home C:\Program Files\apache Software Foundation\tomcat 7.0
Path ;%tomcat_home%\lib;%tomcat_home%\lib\servlet-api.jar;%tomcat_home%\lib\jsp-api.jar

In the Tomcat directory, the Conf folder contains the core configuration of Tomcat, the Logs folder contains Tomcat logging, and the WebApps folder is the default Web hosting directory for Tomcat.

The server.xml of the Conf folder is the most important configuration of Tomcat, and the following are common settings for Server.xml:

 1 <?xml version= ' 1.0 ' encoding= ' Utf-8 '?> 2 <!--Server Property Description 3 Port: Specify a port that listens for requests to shut down Tomcat 4 Shutdown: command string to shut down server sent to Port 5--6 <server port= "8006" shutdown= "Shutdown" > 7 <!--define multiple listeners--& Gt 8 <listener classname= "Org.apache.catalina.core.AprLifecycleListener" sslengine= "on"/> 9 <listener Classna Me= "Org.apache.catalina.core.JasperListener"/>10 <listener classname= " Org.apache.catalina.core.JreMemoryLeakPreventionListener "/>11 <listener classname=" Org.apache.catalina.mbeans.GlobalResourcesLifecycleListener "/>12 <listener classname=" Org.apache.catalina.core.ThreadLocalLeakPreventionListener "/>13 <!--define shared resources-->14 < globalnamingresources>15 <resource name= "userdatabase" auth= "Container" type= Ina. Userdatabase "description=" User database, can be updated and saved "factory=" Org.apa Che.catalina. Users.    Memoryuserdatabasefactory "Pathname=" Conf/tomcat-users.xml "/>20 </globalnamingresources>21 <!--<Service> elements are defined by the Org.apache.catalina.Service interface, which contains a <Engine> element, 22, and one or more <connector> These Connector elements are shared with the same engine element-->23 <service name= "Catalina" >24 <!--<Connector> elements that represent the exchange of information with the client program, which can receive Customer's request, and returns the response result to the customer-->25 <!--defines how the HTTP protocol is handled, the processing interface defaults to 808026 because this interface is often called by other applications, it is recommended to modify the interface-->27 <conne ctor port= "8081" protocol= "http/1.1", connectiontimeout= "20000" redirectport= "8443"/&G T;30 <!--define how the ajp/1.3 protocol is handled, and this is the core protocol for integrating Tomcat+apache, so be careful with-->31 <connector port= "8009" protocol= "ajp/1.3 "Redirectport=" 8443 "/>32 <!--each <Service> element can include only one <Engine> element. The <Engine> element handles customer requests received by all <Connector> elements in the same <Service>-->34 <engine name= "Catalina" de faulthost= "localhost" >35 <!--realm is a Stored user name, password, and userThe "database" 36 user name of the role in which the name is associated, and the password can be used to verify the validity of the user for one or more Web applications. -->37 <realm classname= "Org.apache.catalina.realm.LockOutRealm" >38 <realm classname= "Org.apach E.catalina.realm.userdatabaserealm "Resourcename=" Userdatabase "/>40 </realm>41 & lt;! The--

Tomcat uses port 8080 to process HTTP requests by default (because this port is often called by other applications and is recommended for modification).
Once you have finished setting up, enter the address localhost:8080 to see the Tomcat administration page.

You can create a new index.jsp page in the WebApps directory, start Tomcat, and test whether Tomcat works correctly.

Vi. Integration of Apache+tomcat

Copy Mod_jk.mo to "/apache2.2/modules" when Apache and Tomcat are working properly
Add the Workers.properties file under the/tomcat 7.0/conf folder and enter the following.

1 Workers.tomcat_home=c:\program files\apache software foundation\tomcat 7.0 2 #让 mod_jk module-aware Tomcat 3 workers.java_home=c : \program Files\java\jdk1.6.0_30\jre 4 #让 mod_jk Module-aware JRE 5 ps= 6 #指定文件路径分割符 7 WORKER.LIST=CONFIG1 8 worker.config1.port=8 009 9 #工作端口, this port should match the port used by the ajp/1.3 protocol of the connector element in Server.xml worker.config1.host=localhost11 #Tomcat服务器的地址12 worker.config1.type=ajp1313 #类型14 worker.config1.lbfactor=115 #负载平衡因数

Attention:

WORKER.LIST=CONFIG1, CONIFG1 is a custom name, but this name must match the name of the Jkmount directive in the/apache 2.2/conf/httpd.conf file described below.

After adding the Workers.properties file, you can modify the "/apache 2.2/conf/httpd.conf" file to add the following configuration.
Note the variables in the Jkmount directive must be the same as the name configured by Worker.list.

 1 # Set the virtual host, define the port as 8000 2 <virtualhost 127.0.0.1:8000> 3 ServerName 127.0.0.1 4 #定义服务名称 5 DocumentRoot "C:/Program Files/apache software foundation/tomcat 7.0/webapps" 6 #定义站点项目所在路径, pointing the path to the default site directory in Tomcat 7 Director Yindex index.html index.htm index.jsp 8 errorlog logs/shsc-error_log.txt 9 Customlog logs/shsc-access_log.txt Co Mmon10 #例子1, let Apache support Webapps/sun.shop/blog in the page jkmount/sun.shop/blog/* config112, request this folder to Apache. Inside the page, the system will turn to use Tomcat to resolve the Jkmount/*.jsp config114 #例子3, request JSP page to Apache, using Tomcat to parse the Jkmount/*.do config1 #例子4, request to Apache. Do action, use Tomcat to parse the Jkmount/*.action config118 #例子5, request to Apache. When action moves, use Tom Cat parsing </virtualhost>20 21 # allows clients to access this path <directory "C:/Program Files/apache software Foundation/tomcat 7.0/webapps "> Options Indexes followsymlinks allowoverride None" Order Allow,deny-Al Low from all </directory> LoadModule jk_module modules/mod_jk.so30 # here mod_jk.so file for you download file Jkworkersfile "C:/Program" S/apache software Foundation/tomcat 7.0/conf/workers.properties "32 # Specify TOMCAT Listener profile address" Jklogfile C:/Program " Apache software Foundation/tomcat 7.0/logs/mod_jk2.log "34 # Specify Log storage location + jkloglevel Info

Attention:

The Jkmount/*.jsp config1 directive indicates that processing points to Tomcat when the client sends a *.JSP page request to Apache. When using struts, it is recommended to use *.action, *.do and other suffix naming actions, otherwise, if you use a no-suffix name, add the jkmount/* config1 command, Apache will include *.html and other static page all requests, All turned to Tomcat.

After completing the above configuration, restart Apache, Tomcat. At this point, the default directory for Apache, Tomcat is "C:/Program Files/apache software foundation/tomcat 7.0/webapps", for HTTP requests, Apache uses 8000 port, Tomcat uses port 8081. After adding the index.jsp page to the default directory, the http://localhost:8000/index.jsp page request is sent directly to Apache, which shows that Apache will turn the request to Tomcat for processing.
Interested in Java development Friends Welcome to join QQ Group: 174850571 Joint Discussion!

Application and management of service class tools

apache2.2+tomcat7.0 Integrated Configuration Detailed

Windows Server R2 load Balancing Getting Started

From:http://www.cnblogs.com/leslies2/archive/2012/07/23/2603617.html

apache2.2+tomcat7.0 Integrated Configuration Detailed

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.