How to install Tomcat6 + Mod_JK

Posted: กันยายน 10, 2010 in Computers and Internet
เริ่มต้นติดตั้ง Java และ jsvc
apt-get update
apt-get install sun-java6-jdk jsvc

ดาวน์โหลด Tomcat6
cd /usr/src
wget http://mirror.kapook.com/apache/tomcat/tomcat-6/v6.0.29/bin/apache-tomcat-6.0.29-deployer.tar.gz

แตกไฟล์ และย้ายไปที่ /usr/share
tar zxvf apache-tomcat-6.0.29.tar.gz
cd apache-tomcat-6.0.29
mv
apache-tomcat-6.0.29 /usr/share/tomcat6

เพิ่ม user และกำหนดสิทธิ์
useradd tomcat6
chown -R tomcat6: /usr/share/tomcat6


สร้างไฟล์เพื่อเรียกใช้งาน
vi /etc/init.d/tomcat6
export JAVA_HOME=/usr/lib/jvm/java-6-sun

case $1 in
start)

sh /usr/share/tomcat6/bin/startup.sh
;;

stop)

sh /usr/share/tomcat6/bin/shutdown.sh
;;

restart)

sh /usr/share/tomcat6/bin/shutdown.sh
sh /usr/share/tomcat6/bin/startup.sh
;;

esac

exit 0

chmod +x /etc/init.d/tomcat6

กำหนดให้ทำงานทุกครั้งที่เปิดเครื่อง
update-rc.d tomcat6 defaults

ลองทดสอบ
/etc/init.d/tomcat6 start

wget http://localhost:8080

ตั้งค่าในไฟล์ server.xml
<Server port="8005" shutdown="SHUTDOWN">
  <Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListen
er" />
  <Listener className="org.apache.catalina.storeconfig.StoreConfigLifecycleListe
ner"/>
 
  <!– Global JNDI resources –>
  <GlobalNamingResources>
 
    <!– Test entry for demonstration purposes –>
    <Environment name="simpleValue" type="java.lang.Integer" value="30"/>
 
    <!– 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>
 
 
  <!– Define the Tomcat Stand-Alone Service –>
  <Service name="Catalina">
 
    <!– A "Connector" represents an endpoint by which requests are received
         and responses are returned.  Each Connector passes requests on to the
         associated "Container" (normally an Engine) for processing.
    –>
 
    <!– Define a non-SSL HTTP/1.1 Connector on port 2117 (default 8080) –>
    <!– <Connector port="8080" maxHttpHeaderSize="8192"
               maxThreads="150" minSpareThreads="5" maxSpareThreads="75"
               enableLookups="false" redirectPort="8443" acceptCount="100"
               connectionTimeout="20000" disableUploadTimeout="true" />–>
 
    <!– Define an AJP 1.3 Connector on port 8009 –>
    <Connector port="8009"
               enableLookups="false" redirectPort="8443" protocol="AJP/1.3" />
 
    <!– Define a Proxied HTTP/1.1 Connector on port 8082 –>
    <!– See proxy documentation for more information about using this. –>
    <!–
    <Connector port="8082"
               maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
               enableLookups="false" acceptCount="100" connectionTimeout="20000"
               proxyPort="80" disableUploadTimeout="true" />
    –>
 
    <!– An Engine represents the entry point (within Catalina) that processes
         every request.  The Engine implementation for Tomcat stand alone
         analyzes the HTTP headers included with the request, and passes them
         on to the appropriate Host (virtual host). –>
     
    <!– Define the top level container in our container hierarchy –>
    <Engine name="Catalina" defaultHost="localhost">
 
      <Realm className="org.apache.catalina.realm.UserDatabaseRealm"
             resourceName="UserDatabase"/>
 
      <!– Define the default virtual host –>
      <Host name="www.example.com" appBase="/var/www/example.com/htdocs"
        unpackWARs="true" autoDeploy="true">
 
        <Context path="" docBase="appname" debug="0" reloadable="true"/>
 
        <Valve className="org.apache.catalina.valves.AccessLogValve"
                 directory="logs"  prefix="example.com_access_log." suffix=".txt"
                 pattern="common" resolveHosts="false"/>
      </Host>     
    </Engine>
  </Service>
</Server>
ติดตั้ง mod_jk
apt-get install libapache2-mod-jk


Advertisements

ใส่ความเห็น

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / เปลี่ยนแปลง )

Twitter picture

You are commenting using your Twitter account. Log Out / เปลี่ยนแปลง )

Facebook photo

You are commenting using your Facebook account. Log Out / เปลี่ยนแปลง )

Google+ photo

You are commenting using your Google+ account. Log Out / เปลี่ยนแปลง )

Connecting to %s