c2:安装apr:
tar zxvf apr-1.4.5.tar.gz
cd apr-1.4.5
./configure --prefix=/usr/local/apr
Make
make install
c3:安装aprtuil
tar zxvf apr-util-1.3.10.tar.gz
cd apr-util-1.3.10
./configure --prefix=/usr/local/apr-util--with-apr=/usr/local/apr
Make
make install
c4安装pcre
tar zxvf pcre-8.11.tar.gz
cd pcre-8.11
./configure --prefix=/usr/local/pcre
Make
make install
D:重新编译httpd
cd httpd-2.2.21
./configure --with-apr=/usr/local/apr--with-apr-util=/usr/local/apr-util --with-pcre=/usr/local/pcre--prefix=/ceno/product/httpd --enable-module=vhost_alias --enable-module=so
Make
Make install
1.2 安装并编译mod_jk
Tar –zxvf tomcat-connectors-1.2.32-src.tar.gz
Cd tomcat-connectors-1.2.32-src/native
./configure --with-apxs=/ceno/product/httpd/bin/apxs
Make
Su –c ‘make install’
1.3 解压tomcat7.0
Tar –zxvf apache-tomcat-7.0.23.tar.gz
Cd /ceno/product/
Ln –s /work/apache/ apache-tomcat-7.0.23tomcat
2. 配置篇章
2.1 配置httpd.conf
Cd /ceno/product/httpd/conf
Vi httpd.conf
下面是
#
# ServerName gives the name and port that theserver uses to identify itself.
# This can often be determined automatically, butwe recommend you specify
# it explicitly to prevent problems duringstartup.
#
# If your host doesn't have a registered DNS name,enter its IP address here.
#
#ServerName www.example.com:80
ServerName 192.168.7.18:80
#
# DocumentRoot: The directory out of which youwill serve your
# documents. By default, all requests are takenfrom this directory, but
# symbolic links and aliases may be used to pointto other locations.
#
#DocumentRoot"/ceno/product/httpd/htdocs"
DocumentRoot"/ceno/product/tomcat/webapps/examples"
<Directory"/ceno/product/tomcat/webapps/examples">
#
#Possible values for the Options directive are "None","All",
# or anycombination of:
# Indexes Includes FollowSymLinksSymLinksifOwnerMatch ExecCGI MultiViews
#
# Notethat "MultiViews" must be named *explicitly* --- "OptionsAll"
#doesn't give it to you.
#
# TheOptions directive is both complicated and important. Please see
#http://httpd.apache.org/docs/2.2/mod/core.html#options
# formore information.
#
OptionsIndexes FollowSymLinks
#
#AllowOverride controls what directives may be placed in .htaccess files.
# It canbe "All", "None", or any combination of the keywords:
# Options FileInfo AuthConfig Limit
#
AllowOverride None
#
#Controls who can get stuff from this server.
#
Orderallow,deny
Allowfrom all
</Directory>
#加入mod_jk配置
Include conf/jk/mod_jk.conf
2.2 在httpd/conf 下添加jk目录,配置mod_jk.conf
Cd /ceno/product/httpd/conf/jk/
#load mod_jk module
LoadModule jk_module modules/mod_jk.so
# Declare the module for <IfModuledirective> (remove this line on Apache 2.0.x)
#AddModule mod_jk.c
# Where to find workers.properties
JkWorkersFile/ceno/product/httpd/conf/jk/workers.properties
# Where to put jk shared memory
JkShmFile /ceno/product/httpd/mod_jk.shm
# Where to put jk logs
JkLogFile /ceno/product/httpd/logs/mod_jk.log
# Set the jk log level [debug/error/info]
JkLogLevel debug
# Select the timestamp log format
JkLogStampFormat "[%a %b %d %H:%M:%S%Y]"
# JkOptions indicate to send SSL KEY SIZE,
JkOptions +ForwardKeySize +ForwardURICompat-ForwardDirectories
# JkRequestLogFormat set the request format
#JkRequestLogFormat "%w %V %T"
# Static files in all Tomcat webapp contextdirectories are served by apache
JkAutoAlias/ceno/product/tomcat/webapps/examples
# All requests go to worker1 by default
JkMount /*balance1
# Servehtml, jpg and gif using httpd
JkUnMount/*.html balance1
JkUnMount/*.jpg balance1
JkUnMount/*.gif balance1
# Add the jkstatus mount point
JkMount/jkmanager/* jkstatus
workers.properties
# the list of workers
worker.list= worker1,worker2,balance1,jkstatus
##
##worker.worker name.type=<worker type>Where worker name is the name assigned to the worker and the worker type is oneof the four types defined in the table
##(a worker name may only contain any space thecharacters [a-zA-Z0-9\-_]).
##Type Description
#ajp12 Thisworker knows how to forward requests to out-of-process Tomcat workers using theajpv12 protocol.
#ajp13 Thisworker knows how to forward requests to out-of-process Tomcat workers using theajpv13 protocol.
#jni DEPRECATED:This worker knows how to forward requests to in-process Tomcat workers usingJNI.
#lb This isa load-balancing worker; it knows how to provide round-robin based sticky loadbalancing with a certain level of fault-tolerance.
#Defines a worker named "loadbalancer"that loadbalances several Tomcat processes transparently.
# Set properties for worker1 (ajp13)
worker.worker1.type=ajp13
worker.worker1.host=192.168.7.18
worker.worker1.port=8009
worker.worker1.lbfactor=1
# Set properties for worker2 (ajp13)
worker.worker2.type=ajp13
worker.worker2.host=192.168.7.18
worker.worker2.port=8010
worker.worker2.lbfactor=3
#worker.worker2.connection_pool_timeout=600
#worker.worker2.socket_keepalive=1
#worker.worker2.socket_timeout=60
worker. balance1.type=lb
#
#After defining the workers you can also specifyproperties for them. Properties can be specified in the following manner:
#worker.<workername>.<property>=<property value>
#
# The worker balance1 while use "real"workers worker1 and worker2
worker.balance1.balance_workers=worker1, worker2
worker.balance1.sticky_session =true
# Define a 'jkstatus' worker using status
worker.jkstatus.type=status
<?xml version='1.0' encoding='utf-8'?>
<!--
Licensedto the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this workfor additional information regarding copyright ownership.
The ASFlicenses this file to You under the Apache License, Version 2.0
(the"License"); you may not use this file except in compliance with
theLicense. You may obtain a copy of theLicense at
http://www.apache.org/licenses/LICENSE-2.0
Unlessrequired by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS"BASIS,
WITHOUTWARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See theLicense for the specific language governing permissions and
limitations under the License.
-->
<!-- Note: A "Server" is not itself a "Container", so you maynot
definesubcomponents such as "Valves" at this level.
Documentationat /docs/config/server.html
-->
<Server port="8005"shutdown="SHUTDOWN">
<!--Security listener. Documentation at /docs/config/listeners.html
<ListenerclassName="org.apache.catalina.security.SecurityListener" />
-->
<!--APRlibrary loader. Documentation at /docs/apr.html -->
<ListenerclassName="org.apache.catalina.core.AprLifecycleListener"SSLEngine="on" />
<!--Initialize Jasper prior to webapps are loaded. Documentation at/docs/jasper-howto.html -->
<Listener className="org.apache.catalina.core.JasperListener"/>
<!--Prevent memory leaks due to use of particular java/javax APIs-->
<ListenerclassName="org.apache.catalina.core.JreMemoryLeakPreventionListener"/>
<Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener"/>
<ListenerclassName="org.apache.catalina.core.ThreadLocalLeakPreventionListener"/>
<!--Global JNDI resources
Documentation at /docs/jndi-resources-howto.html
-->
<GlobalNamingResources>
<!--Editable user database that can also be used by
UserDatabaseRealm to authenticate users
-->
<Resource name="UserDatabase" auth="Container"
type="org.apache.catalina.UserDatabase"
description="User database that can be updated and saved"
factory="org.apache.catalina.users.MemoryUserDatabaseFactory"
pathname="conf/tomcat-users.xml" />
</GlobalNamingResources>
<!-- A"Service" is a collection of one or more "Connectors" thatshare
asingle "Container" Note: A"Service" is not itself a "Container",
soyou may not define subcomponents such as "Valves" at this level.
Documentation at /docs/config/service.html
-->
<Service name="Catalina1">
<!--The connectors can use a shared executor, you can define one ormore named thread pools-->
<!--
<Executor name="tomcatThreadPool"namePrefix="catalina-exec-"
maxThreads="150" minSpareThreads="4"/>
-->
<!--A "Connector" represents an endpoint by which requests are received
andresponses are returned. Documentation at :
Java HTTP Connector: /docs/config/http.html (blocking &non-blocking)
Java AJP Connector:/docs/config/ajp.html
APR(HTTP/AJP) Connector: /docs/apr.html
Define a non-SSL HTTP/1.1 Connector on port8080
-->
<Connector port="8080" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" />
<!--A "Connector" using the shared thread pool-->
<!--
<Connectorexecutor="tomcatThreadPool"
port="8080" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" />
-->
<!--Define a SSL HTTP/1.1 Connector on port 8443
This connector uses the JSSE configuration, when using APR, the
connector should be using the OpenSSL style configuration
described in the APR documentation -->
<!--
<Connector port="8443" protocol="HTTP/1.1"SSLEnabled="true"
maxThreads="150" scheme="https"secure="true"
clientAuth="false" sslProtocol="TLS" />
-->
<!--Define an AJP 1.3 Connector on port 8009 -->
<Connector port="8009" protocol="AJP/1.3"redirectPort="8443" />
<!--An Engine represents the entry point (within Catalina) that processes
every request. The Engineimplementation for Tomcat stand alone
analyzes the HTTP headers included with the request, and passes them
onto the appropriate Host (virtual host).
Documentation at /docs/config/engine.html-->
<!--You should set jvmRoute to support load-balancing via AJP ie :
<Engine name="Catalina" defaultHost="localhost"jvmRoute="jvm1">
-->
<Engine name="Catalina1" defaultHost="localhost"jvmRoute="worker1">
<!--For clustering, please take a look at documentation at:
/docs/cluster-howto.html (simplehow to)
/docs/config/cluster.html (reference documentation) -->
<!--
<Cluster className="org.apache.catalina.ha.tcp.SimpleTcpCluster"/>
-->
<!-- Use the LockOutRealm to prevent attempts to guess user passwords
via a brute-force attack -->
<RealmclassName="org.apache.catalina.realm.LockOutRealm">
<!-- This Realm uses the UserDatabase configured in the global JNDI
resources under the key "UserDatabase". Any edits
that are performed against this UserDatabase are immediately
available for use by the Realm. -->
<Realm className="org.apache.catalina.realm.UserDatabaseRealm"
resourceName="UserDatabase"/>
</Realm>
<!-- Access log processes all example.
Documentation at: /docs/config/valve.html
Note: The pattern used is equivalent to using pattern="common"-->
<ValveclassName="org.apache.catalina.valves.AccessLogValve"directory="logs"
prefix="localhost_access_log." suffix=".txt"
pattern="%h %l %u %t "%r" %s %b" />
<!--The connectors can use a shared executor, you can define one ormore named thread pools-->
<!--
<Executor name="tomcatThreadPool"namePrefix="catalina-exec-"
maxThreads="150" minSpareThreads="4"/>
-->
<!--A "Connector" represents an endpoint by which requests are received
andresponses are returned. Documentation at :
Java HTTP Connector: /docs/config/http.html (blocking &non-blocking)
Java AJP Connector:/docs/config/ajp.html
APR(HTTP/AJP) Connector: /docs/apr.html
Define a non-SSL HTTP/1.1 Connector on port 8080
-->
<Connectorport="8081" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8444" />
<!--A "Connector" using the shared thread pool-->
<!--
<Connector executor="tomcatThreadPool"
port="8080" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" />
-->
<!--Define a SSL HTTP/1.1 Connector on port 8443
This connector uses the JSSE configuration, when using APR, the
connector should be using the OpenSSL style configuration
described in the APR documentation -->
<!--
<Connector port="8443" protocol="HTTP/1.1"SSLEnabled="true"
maxThreads="150" scheme="https"secure="true"
clientAuth="false" sslProtocol="TLS" />
-->
<!--Define an AJP 1.3 Connector on port 8009 -->
<Connector port="8010" protocol="AJP/1.3"redirectPort="8444" />
<!--An Engine represents the entry point (within Catalina) that processes
every request. The Engineimplementation for Tomcat stand alone
analyzes the HTTP headers included with the request, and passes them
onto the appropriate Host (virtual host).
Documentation at /docs/config/engine.html -->
<!--You should set jvmRoute to support load-balancing via AJP ie :
<Engine name="Catalina" defaultHost="localhost"jvmRoute="jvm1">
-->
<Engine name="Catalina2" defaultHost="localhost"jvmRoute="worker1">
<!--For clustering, please take a look at documentation at:
/docs/cluster-howto.html (simplehow to)
/docs/config/cluster.html (reference documentation) -->
<!--
<ClusterclassName="org.apache.catalina.ha.tcp.SimpleTcpCluster"/>
-->
<!-- Use the LockOutRealm to prevent attempts to guess user passwords
via a brute-force attack -->
<RealmclassName="org.apache.catalina.realm.LockOutRealm">
<!-- This Realm uses the UserDatabase configured in the global JNDI
resources under the key "UserDatabase". Any edits
that are performed against this UserDatabase are immediately
available for use by the Realm. -->
<RealmclassName="org.apache.catalina.realm.UserDatabaseRealm"
resourceName="UserDatabase"/>
</Realm>
<!-- Access log processes all example.
Documentation at: /docs/config/valve.html
Note: The pattern used is equivalent to using pattern="common"-->
<ValveclassName="org.apache.catalina.valves.AccessLogValve"directory="logs"
prefix="localhost_access_log." suffix=".txt"
pattern="%h %l %u %t "%r" %s %b" />