Apache2 + Tomcat5.5 + JK on FreeBSD

After serveral time that I try to config Apache to serve jsp, servelet i got fail.
Yesterday I try it again and WoooLa success.... , so i want to share and write
it as my memo..

Before begin i suggest that you already familiar with FreeBSD alittle at least
you should able to install program such as Apache, Tomcat, and JK from ports.
So, in this howto you should already installed Apache2.2, Tomcat5.5 and mod_jk
already, then I will write only howto config the things work.

How to
In configuration file of Apache you have to uncomment the line that load mod_jk

/usr/local/etc/apache22/httpd.conf
LoadModule jk_module libexec/apache22/mod_jk.so # un comment this line

and then you have to told Apache to know that where it can find the configuration of
mod_jk by add a line that include mod_jk.conf at the last line of httpd.conf

Include /usr/local/tomcat5.5/conf/jk/mod_jk.conf

then.... where is mod_jk.conf ??
mod_jk.conf and worker.properties are the configuration file for mod_jk that after
you installed mod_jk the files appear in /usr/local/etc/apache22/ as a sample file
mod_jk.conf.sample and worker.properties.sample then you should copy and rename
it to /usr/local/tomcat5.5/conf/jk/mod_jk.conf and worker.properties.

In mod_jk.config
# Replace jsp-hostname with the hostname of your JSP server, as
# specified in workers.properties.
#

JkWorkersFile /usr/local/tomcat5.5/conf/jk/workers.properties
JkLogFile /var/log/jk.log
JkShmFile /var/log/jk-runtime-status
JkLogLevel error
# Sample JkMounts. Replace these with the paths you would
# like to mount from your JSP server.
JkMount /*.jsp jsp-hostname
JkMount /servlet/* jsp-hostname
JkMount /examples/* jsp-hostname



======
in workers.properties

# Incredibly simple workers.properties file, intended for connecting
# to one host, via AJP13. See the tomcat documentation for
# information on more exotic configuration options.
#
# Change jsp-hostname to the hostname of your JSP server.
#
worker.list=jsp-hostname
worker.jsp-hostname.port=8009
worker.jsp-hostname.host=jsp-hostname
worker.jsp-hostname.type=ajp13
worker.jsp-hostname.lbfactor=1

in workers.properties and mod_jk.conf change jsp-hostname to your hostname
for example change it to localhost

restart apache and tomcat then test it.
it should work properly now.

ณ.บัด NOW! Kasikorn still use OpenCMS!

Kasikorn bank still using OpenCMS... 11/07/2007

Just wanna told you, that was my implemention, Thanks for OpenCms an one good open source cms.
:)

อะไรเอ่ย..มีก็ทุกข์ ไม่มีก็ทุกข์

....

ขอพอดีๆ เป็นมั๊ย

ความพอดี...ก็อย่างนี้
ขออะไรที่มันพอดีๆ แบบว่า ให้เอาใจทำได้ อย่าให้มาก..กูก็เหนื่อยเป็น
ช่วยเหลือ...ช่วยได้ อยากช่วยถ้ากูช่วยได้ กูช่วยอะไรไม่ได้ ขอให้กูช่วย
กูก็รับฟัง พอฟังแล้วกูก็จะขัดใจ เพราะว่ากูช่วยไม่ได้ ทำให้กูเป็นทุกข์

สาดเอ๊ย...ขอจบเท่านี้แหละ

Apache 2 autoindex customization.

Autoindex คืออะไรวะ?

ปกติ index ของ folder ใน web มันมีสองแบบคือ
1. เรา(คนทำเว็บ)เขียน ขึ้นมาเองแล้วตั้งชื่อไฟล์นั้นๆ ให้ตรงกับที่กำหนดไว้ใน DirectoryIndex directive
ปกติไฟล์นี้ชื่อว่า index.html, default.html หรืออะไรก็ตามที่ตรงกับที่กำหนดไว้ใน DirectoryIndex directive
2. ก็มาจาก การ listing generated โดย server ซึ่งในส่วนนี้จะมี directive ที่ควบคุมรูปแบบของ listing นี้
เช่น The AddIcon, AddIconByEncoding and AddIconByType ใช้เพื่อกำหนด icons ในการ list ไฟล์ สำหรับ
ไฟล์ประเภทต่างๆ สำหรับแต่ละรายการที่แสดง icon แรกที่ตรงกับทีกำหนดจะถูกใช้ ส่วนนี้ควบคุมโดย
mod_autoindex.

อันนี้เหมาะกับ พวกขี้เกียจ แต่ต้องการให้ autindex listing ดูดีนิดหน่อย
หรืออย่างผม สามารถเอา google adsence ใส่เข้าไปใน listing นี้ได้ด้วยนะจะบอก!!!

แล้วทำยังไงถึงจะ enable มันได้

อันแรกเลย ไปที่ httpd.conf แล้ว search หา autoindex ถ้าเจอ LoadModule autoindex_module โดน comment
อยู่ก็ ไปเอา comment ออกซะ
จาก >>>> #LoadModule autoindex_module modules/mod_autoindex.so
เป็น >>>> LoadModule autoindex_module modules/mod_autoindex.so

พอลองไป refresh webdir ที่เป็น autoindex อยู่ก็จะเห็นว่า >>> มันยังหน้าตาเหมือนเดิม (เกาหัว) ตูลืมอะไรหว่า??
อ่อ... ลืมครับยังต้อง uncomment อีกบรรทัดนึง Include conf/extra/httpd-autoindex.conf (ใน apache 2 มันแยก
config ไว้หลายๆ ไฟล์แล้วใน httpd.conf ก็จะมี include อย่างนี้หลายๆ อัน!! )

# Fancy directory listings
Include conf/extra/httpd-autoindex.conf


หลังจากนี้ก็ refreh webdir ของเราอีกที ก็จะเห็นหน้าตา autoindex ที่ fancy ขึ้น มี icons มีไฟล์ไซต์ ตามที่กำหนดใน
http-autoindex.conf

ส่วนว่าต้องการเห็นอะไรบ้างก็ไปดูเอกสารกันเองนะกรั๊บ...ตาม link
http://httpd.apache.org/docs/2.2/mod/mod_autoindex.html

อ่อ...จะใส่ adsence ลงใน autoindex ก็ไป edit ไฟล์ Header.html นะครับเอา code adsence ใส่เข้าไปใน header.html
แล้้วลองดูผลกันเอาเอง :)

อาดิโอส...อรุณสวัสดิ์ครับผม