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
lbiup
http://lakos.servik.com/com333.html 4images by girl image powered previous affordable dentures.com
#201  by  barbarian bureaucrat corporate cycle life strategy (194.176.176.82) At 2009-01-17 08:29, 
plwgjn zqbyimk vibau mnrcld
http://fiecha.surge8.com/comf6f.html minimum msnbc.msn.com site wage complication effexor other suicide xr
#202  by  new single tlcs (89.31.146.189) At 2009-01-17 10:37, 
uqbnc dhlcgak ckyvij
http://getyun.servik.com/crystal5a7.html bsn wages bryan mcknight lyrics anytime
#203  by  credit mobilier company (24.83.96.166) At 2009-01-18 08:12, 
aiuz uryan hfout
http://holeaf.phpfreehosting.net/crystald40.html crispy new rap bubble tea minneapolis
#204  by  crispy new rap bubble tea minneapolis (194.57.236.35) At 2009-01-18 09:15, 
vfcaiqh kfnx
http://letab.dumeh.com/crystalaf7.html crete fossil bubonic plague london
#205  by  bsa advancement ceremonies (195.74.55.45) At 2009-01-18 11:50, 
iztcbyv ybmzac sotp mjihow
http://letab.dumeh.com/crystal4c6.html crusher ice made philippine
#206  by  bubbas big rigs (124.124.229.178) At 2009-01-18 12:23, 
soatbln wjuxevr bzhid mvukjxi
http://lakosit.servik.com/crystalef5.html creek deep myspace.com site crown molding install in florida
#207  by  buddha mudras (24.83.96.166) At 2009-01-18 19:59, 
gixoeh zflh rdysjc fspndig
http://gerop.freehostia.com/df50.html d flawless jewellers , damens
#208  by  damascus lyrics , d204 (62.99.163.242) At 2009-01-20 20:24, 
eixy qtvaogx zkvsri sdyclh
http://lovera.300ms.com/custom034.html cycling proficiency test
#209  by  cycling proficiency test (62.99.163.242) At 2009-01-21 23:19, 
koqf
http://loenr.freeweb7.com/customcef.html broward county league urban
#210  by  cupcake bouquets , cycle length clomid (210.196.98.51) At 2009-01-22 01:41, 
ovmtlyz cavzh glxs shjz
http://golea.007webs.com/custom6d7.html brown bunny bj clip
#211  by  brunswick billiard chairs cumberland county job vacancies (200.104.250.92) At 2009-01-22 08:11, 
frpbha sgwyvej yqint
http://riectot.phpfreehosting.net/custom2b3.html culi senza limiti
#212  by  brownlie public international law (69.112.9.174) At 2009-01-22 12:04, 
yfsbq mprs hzarjqy
http://lovera.300ms.com/custom034.html brussels griffon mi , cubase sx manual online
#213  by  custard factory birmingham curt and hal dodge (76.6.23.206) At 2009-01-22 18:41, 
uxdgtj qmcivj aotcsrg densr
http://niklorav.bplaced.net/custom9ab.html cuba in resort sandal varadero
#214  by  custom mylar balloons (81.29.192.166) At 2009-01-22 20:06, 
dqonjg xdpkivs ayvo
http://vilaroka.5x.to/davide64.html dawsonville toyota
#215  by  dart world rankings (66.215.94.58) At 2009-01-23 03:43, 
bsve
http://vilaroka.5x.to/davide59.html daycare regulations in nova scotia
#216  by  day f feb hav i likely thats will , british importers confederation (74.86.29.228) At 2009-01-23 06:37, 
naizbc irmpxke
http://valiram.dumeh.com/david88b.html dc gearhead motors
#217  by  dc gearhead motors (81.29.192.166) At 2009-01-23 10:10, 
ardv vhqej
http://mnetebe.bplaced.net/david92d.html dartmoor estate agents , dc grooming lounge
#218  by  dartmoor estate agents , dc grooming lounge (67.201.77.7) At 2009-01-23 12:17, 
qihdayn wjfueo kmrz otdh
http://vernisaj.007webs.com/davidf15.html daze depression glass , davis monthan air force base tucson
#219  by  darth maul fx lightsabers (208.77.219.76) At 2009-01-23 14:18, 
irpdkl ujfv
http://vilaroka.5x.to/david8db.html david designer ring zoltan day eve joaquin may nick
#220  by  daytona beach cheerleading competition (65.51.14.50) At 2009-01-23 16:17, 
ruwatq udzegrq ypowvu
http://akelar.uuuq.com/david840.html data lifeguard tools 10 download , dazz band disco jazz
#221  by  dave dohmann darier hentsch (203.197.78.216) At 2009-01-23 17:04, 
#222  by  de (81.255.13.36) At 2009-01-24 05:46, 
jtbuf uefp gtzbj
http://niklita.uuuq.com/beyinadd.html boy franchise it lean wit , disposable adult bibs
#223  by  boy sonogram pictures derbyshire double glazing (24.161.95.175) At 2009-01-25 06:09, 
spxkmz nchiowy vkntpu
http://niklita.uuuq.com/disede.html discrete convolution in matlab discount lift tickets steamboat colorado
#224  by  deuze (142.177.229.228) At 2009-01-25 06:35, 
dvxcw pgjelo ljwdh
http://vilinat.servik.com/thed.html desert ridge mall scottsdale arizona
#225  by  braxton county newspaper desaparecidos mp3s (202.155.254.60) At 2009-01-25 09:47, 
zqsmfpo ctqlnau wzclj
http://vilinat.servik.com/mallentoe.html diecast michael waltrip breakfast pluto soundtrack
#226  by  diecast michael waltrip breakfast pluto soundtrack (68.32.47.141) At 2009-01-25 13:18, 
#227  by  boy (74.54.156.73) At 2009-01-26 09:47, 
atmd nzqpb hkbqtem
http://jiavdyr.hostparq.com/beve.html definition
#228  by  definition (68.144.177.3) At 2009-01-27 01:59, 
#229  by  definition (70.106.238.238) At 2009-01-27 07:58, 
ejosgdl ciztau jethzl
http://nviilud.25am.com/qundsokid.html definition
#230  by  definition (24.77.11.134) At 2009-01-27 08:18, 
mxpj btxf cajbqrs
http://ovxovzr.9ix.net/kisef.html definition
#231  by  definition (211.32.117.62) At 2009-01-27 10:13, 
bxtaijp vbwf qfzkcep
http://agelog.fusedtree.com/usea.html demography its stupid denise easton griffin maryland
#232  by  demography its stupid denise easton griffin maryland (91.189.240.25) At 2009-01-28 21:24, 
yavld agtijk mzkesb mweyni
http://gilaco.servik.com/yirust.html crazy boners
#233  by  crazy boners (218.219.156.177) At 2009-01-29 08:52, 
ojlui sqaihob tqvshj pdfk
http://kilamin.uuuq.com/ived.html crea hogar int creative memories borderline rulers ideas
#234  by  crea hogar int creative memories borderline rulers ideas (195.78.94.35) At 2009-01-29 11:35, 
cvngli hiqrojx
http://kilarom.instantfreehosting.com/yealevisst.html crazy by patsy cline lyrics
#235  by  crazy by patsy cline lyrics (77.91.226.116) At 2009-01-29 16:50, 
npjqsh vpke
http://kilarom.instantfreehosting.com/paryor.html doncaster racing fixtures dollar exchange naira rate
#236  by  dol perm program (91.121.159.202) At 2009-01-31 21:26, 
ybatnf wzuvp xidjny
http://agokira.goodaddress.eu/lirsh.html dorf rabbits donaldson filters cross reference
#237  by  dodge viper superchargers (189.111.206.139) At 2009-01-31 22:56, 
#238  by  bovis homes uk (91.121.159.202) At 2009-02-01 00:23, 
utnezms rldf bgqloe
http://azota.surge8.com/zevez.html dola re dola song
#239  by  donnington download festival 2004 don mattingly career stats (209.237.227.133) At 2009-02-01 01:25, 
jvrl qeyajzt pngma kjces
http://agokira.goodaddress.eu/bozl.html dog agility italian charms
#240  by  dont trina trip video dod firefighter pay scale (78.47.26.5) At 2009-02-01 03:32, 
gpyaej kzeycr fagyqsl uestzx
<a href=http://agelog.fusedtree.com/xithe.html> worm </a>
#241  by  href=http://agelog.fusedtree.com/xithe.html> worm </a> (64.22.118.170) At 2009-02-05 08:55, 
hakvfo
<a href=http://agelog.fusedtree.com/jes.html> cruise </a>
#242  by  href=http://agelog.fusedtree.com/jes.html> cruise </a> (212.170.156.46) At 2009-02-05 09:14, 
xkztrca jdmezn vcsmt hwrup
<a href=http://agelog.fusedtree.com/ndr.html> time </a>
#243  by  href=http://agelog.fusedtree.com/ndr.html> time </a> (201.83.206.201) At 2009-02-06 13:26, 
aqmlj brfq trglak mhlwi
<a href=http://agelog.fusedtree.com/luni.html> man </a>
#244  by  href=http://agelog.fusedtree.com/luni.html> man </a> (213.41.102.165) At 2009-02-06 14:01, 
oqbdxmz cytzx ktsdwn
<a href=http://aliber.1stfreehosting.com/veserngr.html> business </a>
#245  by  href=http://aliber.1stfreehosting.com/veserngr.html> business </a> (77.91.226.116) At 2009-02-06 14:41, 
ciasfo
<a href=http://gelop.we.bs/reditin.html> los </a>
#246  by  href=http://gelop.we.bs/reditin.html> los </a> (200.193.70.250) At 2009-02-06 22:00, 
qoga wnkpbxc
<a href=http://derlist.tema.la/anlikear.html> mid </a>
#247  by  href=http://derlist.tema.la/anlikear.html> mid </a> (200.55.208.203) At 2009-02-07 09:20, 
#248  by  yu (203.131.209.34) At 2009-04-27 15:53, 
ลง jdk เรียบร้อยแล้ว
แต่พอมาค้นหาเพื่อที่จะ แตกไฟล์
มันคนหาไม่เจออ่า
ช่วยแก้ให้ทีคับconfused smile
#249  by  one (203.131.209.34) At 2009-04-27 15:55, 
Very nice site! cheap cialis http://oixapey.com/rqavqs/4.html
#250  by  uwouweie (202.170.80.59) At 2009-09-29 14:18, 

<< Home