2005/Jul/20

บันทึกการติดตั้ง Apache2 + Tomcat5.5 + mod_jk


หลังจากที่เมื่อก่อน เคยติดตั้ง apache2 + tomcat5.5 + mod_jk เรียบร้อยแล้ว แต่พอมาวันนี้ กลับลืมวิธีการติดตั้งแฮะ ก็เลยต้องมาเขียนบันทึกความทรงจำไว้ซะหน่อย ไม่อยากค้นหาข้อมูลใหม่ทุกครั้งที่จะต้องติดตั้ง

หมายเหตุ บรรทัดที่ขึ้นต้นด้วย # หมายถึง คำสั่งที่เราต้องป้อนเข้าไปบนหน้าจอเทอร์มินอลนะครับ

ระบบและซอฟต์แวร์ที่ใช้

  • Fedora Core 4 (Kernel 2.6.12)
  • Apache Httpd 2.0.54
  • Java 2 Standard Edition 1.5 (http://java.sun.com/j2se/1.5.0/download.jsp)
  • Apache Tomcat 5.5.9 (http://jakarta.apache.org/tomcat)
  • mod_jk-1.2.14 (http://jakarta.apache.org/tomcat/connectors-doc)

ขั้นตอนการติดตั้ง

1. ติดตั้ง Java 2 Standard Editon 1.5
เมื่อดาว์นโหลดมาแล้ว ก็ทำการ chmod เพื่อให้สามารถรันได้ครับ

#chmod +x jdk-1_5_0_04-linux-i586.rpm.bin

จากนั้นก็รันโปรแกรมเลยครับ ซึ่งมันจะทำการแตกไฟล์ออกมาเป็น jdk-1_5_0_04-linux-i586.rpm และติดตั้งให้โดยอัตโนมัติ

 #./jdk-1_5_0_04-linux-i586.rpm.bin

เมื่อติดตั้งเสร็จแล้วพาธของ Java จะไปอยู่ที่ /usr/java/jdk1.5.0_04
ให้เราทำการแก้ไขไฟล์ /etc/profile แล้วใส่ข้อความข้างล่าง ไว้ที่บรรทัดล่างสุดของไฟล์เลยนะครับ

export JAVA_HOME=/usr/java/jdk1.5.0_04
export PATH=$PATH:$JAVA_HOME/bin

บันทึกไฟล์ /etc/profile จากนั้นลองใช้คำสั่งข้างล่าง เพื่อตรวจสอบความถูกต้อง

#source /etc/profile
ลองตรวจสอบตัวแปรดูครับ โดยใช้คำสั่ง echo
#echo $JAVA_HOME
/usr/java/jdk1.5.0_04

#java -version
java version "1.5.0_04"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_04-b05)
Java HotSpot(TM) Server VM (build 1.5.0_04-b05, mixed mode)

2. ติดตั้ง Tomcat 5.5.9

#tar xvfz jakarta-tomcat-5.5.9.tar.gz
#mv jakarta-tomcat-5.5.9 /usr/local
#cd /usr/local
#ln -s jakarta-tomcat-5.5.9 tomcat55

3. ติดตั้ง JK Connector (mod_jk)
#tar xvfz jakarta-tomcat-connectors-1.2.14-src.tar.gz
#cd jakarta-tomcat-connectors-1.2.14-src
#cd jk/native
#./configure --with-apxs=/usr/sbin/apxs --enable-jni --enable-EAPI

สำหรับการคอนฟิก จะมีปัญหาเกิดขึ้นมาครับ ด้งนี้

need to check for Perl first, apxs depends on it...
checking for perl... /usr/bin/perl
configure: error: Invalid location for apxs: '/usr/sbin/apxs'

ซึ่งระบบจะแจ้งว่า เราไม่มี /usr/sbin/apxs เราจะต้องติดตั้งแพคเกจ httpd-devel ก่อนนะครับ สำหรับผม จะใช้วิธีติดตั้งจาก apt-get ก็แล้วกันครับ การติดตั้งแบบ apt-get install นี้ จะง่ายในขั้นตอนของการค้นหา Dependency (การขึ้นต่อกัน) ของซอฟต์แวร์

#apt-get install httpd-devel
apt-get install httpd-devel
Reading Package Lists... Done
Building Dependency Tree... Done
The following extra packages will be installed:
apr-devel (0.9.6-3.1)
apr-util-devel (0.9.6-2)
The following NEW packages will be installed:
apr-devel (0.9.6-3.1)
apr-util-devel (0.9.6-2)
httpd-devel (2.0.54-10.1)
0 upgraded, 3 newly installed, 0 removed and 0 not upgraded.
Need to get 927kB of archives.
After unpacking 6409kB of additional disk space will be used.
Do you want to continue? [Y/n]

จากนั้นก็ลองทำการคอนฟิก ./configure และใช้ออฟชันเหมือนข้างบน อีกรอบ ก็ผ่านครับ ต่อมาก็ทำการ make ได้เลย ดังนี้
#make

จากนั้นก็ทำการทำสำเนาไฟล์ mod_jk.so ไปไว้ในโมดูลไดเรคเทอรีของ apache ครับ
#cp apache-2.0/mod_jk.so /etc/httpd/modules/

4. สร้างไฟล์ workers.properties
#vi /etc/httpd/conf/workers.properties

workers.tomcat_home=/usr/local/tomcat55
workers.java_home=$JAVA_HOME
ps=/
worker.list=default

worker.default.port=8009
worker.default.host=localhost
worker.default.type=ajp13
worker.default.lbfactor=1

5. สร้างไฟล์ mod_jk.conf
#vi /etc/httpd/conf.d/mod_jk.conf

<IfModule !mod_jk.c>
LoadModule jk_module modules/mod_jk.so
</IfModule>
#
# Mod_jk settings
#

JkWorkersFile "conf/workers.properties"
JkLogFile "logs/mod_jk.log"

JkLogLevel error

JkMount /jsp-examples default
JkMount /jsp-examples/* default

# End of mod_jk settings

6. ทดสอบ
#cd /usr/local/tomcat55/bin
#./catalina.sh start
#/etc/init.d/httpd restart

ทดลองเปิดเว็บบราวเซอร์ แล้วเรียกไปที่ http://localhost:8080/jsp-examples
จากนั้นทดลองเรียกไปที่ http://localhost/jsp-examples ผลลัพธ์ที่ได้ต้องออกมาเหมือนกันทั้งสองหน้านะครับ

เพิ่มเติมครับ ในกรณีที่เราต้องการให้ผู้ใช้คนอื่นๆ สามารถใช้งาน jsp/servlet ในโฮมไดเรคเทอรีของตัวเองได้ เราต้องทำดังนี้ครับ

แก้ไขไฟล์ server.xml แล้วหาตรงแทก <Host> ครับ ซึ่งจะมีลักษณะแบบนี้
<Host name="localhost" appBase="webapps"
unpackWARs="true" autoDeploy="true"
xmlValidation="false" xmlNamespaceAware="false">
<!-- จะมีคอมเมนต์อีกเยอะแยะเลยล่ะ -->
</Host>

ให้เราทำการเพิ่มบรรทัดสีน้ำเงินเข้าไปดังนี้

<Host name="localhost" appBase="webapps"
unpackWARs="true" autoDeploy="true"
xmlValidation="false" xmlNamespaceAware="false">
<Listener className="org.apache.catalina.startup.UserConfig" directoryName="public_html"
userClass="org.apache.catalina.startup.PasswdUserDatabase"/>

<!-- จะมีคอมเมนต์อีกเยอะแยะเลยล่ะ -->
</Host>


แหล่งข้อมูล
http://duangbung.blogspot.com/2005/07/apache2-tomcat-5-modjk2-index-only.html
ชื่อ: 
เว็บไซต์: 
คอมเมนต์:




smilebig smileopen-mounthed smileconfused smilesad smileangry smiletonguequestionembarrassedsurprised smilewinkdouble winkcry
envj
http://agoal.freehostia.com/com3f4.html luxor cab san francisco bona allen saddle
#51  by  notary jurat pointer sister discography (78.45.58.37) At 2008-12-26 17:53, 
bmvf
http://utenti.lycos.it/agoal/comd7f.html cushman colonial creations bag personalized toiletry
#52  by  real estate frederica delaware malayalam cinema magazines (195.149.84.82) At 2008-12-26 23:50, 
uczy
http://zhaiupe.fizwig.com/comf09.html cover f100 tonneau , hp m305 photosmart
#53  by  cover f100 tonneau , hp m305 photosmart (65.29.182.21) At 2008-12-27 10:55, 
xyhd eszd xvcsjir uwlnd
http://hifscqi.10fast.net/comb1a.html hors location renault tax and circa clock mantle movement
#54  by  hors location renault tax and circa clock mantle movement (203.113.137.68) At 2008-12-27 11:57, 
szimc vpgwmqc fgpure izgau
http://hssuaxl.freewhost.com/comceb.html the new deal holc , perkiomen tours
#55  by  xenogears cheat and short life and long times of mrs beeton (201.21.137.207) At 2008-12-27 12:00, 
rfxqwgl
http://tqivixe.yourfreehosting.net/inb20.html brocolli slaw recipe and cariten health
#56  by  faciale info remember sperme , kahiko hula (195.16.32.38) At 2008-12-27 12:35, 
vmwuz nirdxeo dxsa
http://geluaci.bidsex.net/comc7e.html spartacom cyc basketball , backe brandon picture
#57  by  spartacom cyc basketball , backe brandon picture (68.144.177.3) At 2008-12-28 02:11, 
ycgpfih
http://members.lycos.nl/evchidip/com7e8.html centralia k12 mo us free musicdownload websites , shiley trach tubes
#58  by  centralia k12 mo us free musicdownload websites , shiley trach tubes (24.109.203.61) At 2008-12-28 03:12, 
nivymou phdgl kbwoqti
http://lryaijn.yourfreehosting.net/com6fb.html boer goat for sale in oklahoma de hotmail sammler , ameritech page sbc yellow
#59  by  misa brim 40 hour hazwoper certificate , frizzell lefty lyric (200.104.250.92) At 2008-12-28 03:41, 
richplm eziafmy
garican.servik.com/comeef.html apache assault longbow and lennys deli
#60  by  search 4kids.tv and koenig strey realtors (116.72.179.52) At 2008-12-30 17:04, 
ponwcsb
http://ofaujve.hostevo.com/com535.html majo site spaces.msn.com and champigny index.php marne search sur
#61  by  majo site spaces.msn.com and champigny index.php marne search sur (87.106.94.63) At 2008-12-30 23:26, 
xgdwlzj
http://zkueebu.californiaus.net/comcc1.html lil troy baller lyrics and jom jones
#62  by  lil troy baller lyrics and jom jones (61.8.77.18) At 2008-12-31 00:23, 
jfnab nivu mqhva
http://members.lycos.nl/axddigar/com090.html bodyworks franklin institute and kalispel mt
#63  by  chafer lewis sperry and colleen edition extreme home makeover nick (140.113.152.201) At 2008-12-31 01:26, 
yjhbvz cvxhbw
http://membres.lycos.fr/osvclbdr/com73e.html wise old king neopets cheats and freckle removing
#64  by  air crosman gun part and link http statelibrary.dcr.state.nc.us (160.75.90.69) At 2008-12-31 01:56, 
ypgul
http://zezkhcb.coastalbend.us/comaf5.html blues folsom guitar prison tab and kristin stannard
#65  by  softail wide tire kits and helth and safety executive (87.118.125.129) At 2008-12-31 02:59, 
tvyru
http://mozvxoy.cataloghosting.com/com12d.html u and me baby aint nothin but mammals and nokia 1260 1221 wireless phone accessory
vtdfcw nwbe chxnvm mbla
http://gfkuoof.99webs.net/com098.html hurricane katrina pitures and olsonite seats
#67  by  davincis restaurant and kanji symbol for sister (202.122.40.28) At 2008-12-31 04:03, 
fykai egbp
http://netareel.goodaddress.eu/com4de.html country fest cadott wi de en fabriquant france sucre , 11 channel news wpxi
#68  by  bowflex xtreme xtlu architectual landscape photos and beach careyes el resort (213.222.11.183) At 2008-12-31 11:52, 
jkgbxmu
http://uammsnu.wisconsinusa.net/com364.html gertrude english channel swimmer suttle motors and sunnybrook campers
#69  by  gertrude english channel swimmer suttle motors and sunnybrook campers (89.100.69.208) At 2008-12-31 12:55, 
eyspzmw uzsn
http://smerlqx.hostrator.com/com354.html dannon coupons mono mononucleosis symptom and editor myspace thomas v3.6
#70  by  dannon coupons mono mononucleosis symptom and editor myspace thomas v3.6 (58.27.241.173) At 2008-12-31 14:06, 
qlsvfc sayuxwr
http://janriy.5x.to/comff1.html salty peice of land 104.7 fm kiss phoenix and blue skink tongued
#71  by  93.5 fm flow gift holiday mobility telus , dimebag darrel shooting video (87.116.192.211) At 2009-01-01 02:17, 
jmkqyxv zncsa
http://pvplhea.007gb.com/coma80.html christina model.com meadowbrook farms gilford nh and trina site myspace.com
#72  by  billy gibbon guitar avertec laptop , jessica breland (213.215.225.47) At 2009-01-01 05:04, 
ahywqcr scfnu
http://membres.lycos.fr/kxmdhcti/comff8.html dte energy layoff guagua national colleges and northern ilinois university
#73  by  dte energy layoff guagua national colleges and northern ilinois university (88.250.177.104) At 2009-01-01 05:27, 
mpelgq gzhmwe
http://goinglist.free.bg/comb3f.html cheap air flights airline discount central kiruna spinnaker's reach and smokinggun.-com
zfkbh zxrjqym
http://vejgiou.10fast.net/com1cc.html diet ephedra ephedra vitalbodyfitness.com blind willies atlanta and cinema center of bloomsburg pa
lqytr cfjqw cfsotd
http://jzafuso.rack111.com/com4a9.html kovats real estate school gaillard auditorium charleston sc , catchphrase supermans
lztxscg fvszq
http://qsqarui.5webs.net/comdf9.html address email fax germany in paulus inoj i found love lyrics and signs of leaking amniotic fluid
ryamcv sfkjzhb zmtfra
http://wqiasqw.1kb.in/new092.html new
#78  by  new (212.72.24.170) At 2009-01-02 21:34, 
#79  by  new (140.113.152.201) At 2009-01-02 23:36, 
vmzgpi xwuz bvadf hetsq
http://ephruhw.55fast.com/newd61.html new
#80  by  new (67.201.111.13) At 2009-01-03 01:25, 
#81  by  new (80.237.38.10) At 2009-01-03 02:40, 
pnsx lygqwb dfalweq behdqv
http://ufpmeix.007gb.com/new60c.html new
#82  by  new (219.118.187.41) At 2009-01-03 03:18, 
hisqru qusiv dlrkjey ftrc
http://happy-new.bplaced.net/new3ec.html new
#83  by  new (211.54.75.141) At 2009-01-03 11:14, 
#84  by  new (220.117.210.38) At 2009-01-03 12:11, 
#85  by  new (85.185.187.37) At 2009-01-03 22:27, 
#86  by  new (72.51.31.19) At 2009-01-03 22:36, 
#87  by  new (91.90.153.66) At 2009-01-04 03:14, 
glmhxys qxwulh oqbdp xltd
http://kxoyvqz.arcadepages.com/newa51.html new
#88  by  new (201.75.78.194) At 2009-01-04 10:32, 
#89  by  new (96.52.63.194) At 2009-01-04 12:59, 
#90  by  new (222.255.29.86) At 2009-01-04 14:57, 
ysgtczq oylqjgi vqahr
http://dobwkiu.9cy.com/newa11.html new
#91  by  new (189.35.53.205) At 2009-01-04 20:04, 
#92  by  com (70.67.137.132) At 2009-01-05 09:50, 
yxakhfo vaubciz huigpax
http://darklop.servik.com/com269.html com
#93  by  com (200.46.75.114) At 2009-01-05 12:00, 
#94  by  com (200.107.38.19) At 2009-01-05 16:36, 
#95  by  com (91.90.153.66) At 2009-01-05 17:55, 
#96  by  com (201.37.126.178) At 2009-01-05 23:15, 
#97  by  christmas (90.183.21.94) At 2009-01-06 06:58, 
#98  by  christmas (200.75.93.191) At 2009-01-06 07:34, 
#99  by  christmas (203.190.160.91) At 2009-01-06 10:38, 
#100  by  christmas (213.132.44.39) At 2009-01-06 11:12, 

<< Home