Coming soon...
The Java Development kit (JDK) is an important dependency for Tomcat. Unfortunately, due to licensing restrictions, the files needed for installation are only available to download manually. Just play along and download all the files.
- # java -version
- # pkg_info | grep jdk
If you did not get any results in either grep, you will need to install the Java Development Kit (JDK)
Dependency: Java Development Kit (JDK)
- # cd /usr/ports/java/jdk16
- # make install clean
You will most likely end on with a stalled JDK installation and a screen full of links to download various JDK components. Make sure you go to each link and download the respective component. Double check that the filenames match exactly! I would strongly recommend putting all these files in a directory for later use to save you some time in the future.
- # mkdir ~/jdk16
To give you an idea on what you will need (at the time of this writing...)
- bsd-jdk16-patches-5.tar.bz2
- tzupdater-1_3_25-2009u.zip
- jdk-6u3-fcs-mozilla_headers-b05-unix-24_sep_2007,jar
- jdk-6u3-fcs-src-b05-unix-24_sep_2007,jar
- jdk-6u3-fcs-bin-b05-unix-24_sep_2007,jar
- diablo-caffe-freebsd7-i386-1.6.0_07-b02.tar.gz
Once you have all the files downloaded, copy them over to /usr/ports/distfiles (where port archives are stored).
- # cp ~/jdk16/* /usr/ports/distfiles
- # cd /usr/ports/java/jdk16
- # make install clean
Install tomcat, apache22, & mod_jk
Now that we have tomcat on our system, install the Apache webserver and the apache/tomcat connector.
- # cd /usr/ports/www/tomcat6
- # make install clean
- # cd /usr/ports/www/apache22
- # make install clean distclean
- # cd /usr/ports/www/mod_jk-apache2
- # make install clean
Enable everything to start at system boot.
- # echo 'tomcat60_enable="YES"' >> /etc/rc.conf
- # echo 'tomcat60_java_home="/usr/local/diablo-jdk1.6.0"' >> /etc/rc.conf
- # echo 'tomcat60_stdout_log="/var/log/tomcat6.log"' >> /etc/rc.conf
- # echo 'tomcat60_stderr_log="/var/log/tomcat6.log"' >> /etc/rc.conf
Install apache 2.2, tomcat 6, & mod_jk
- # cd /usr/ports/www/apache22
- # make install clean
- # cd /usr/ports/www/tomcat6
- # make install clean
- # cd /usr/ports/www/mod_jk
- # make install clean distclean
- # rehash
Configure tomcat 6
- # touch /var/log/tomcat6.log
- # chgrp www /var/log/tomcat6.log
- # chmod g+w /var/log/tomcat6.log
- # /usr/local/etc/rc.d/tomcat6 start
- # tail -n 30 /var/log/tomcat6.log
- # sockstat -l4 | grep java
- www java 4824 27 tcp4 *:8180 *:*
- www java 4824 43 tcp4 *:8009 *:*
- www java 4824 46 tcp4 127.0.0.1:8005 *:*
Wait about 10 seconds and go to http://tomcat_hostname_or_ip:8180 or http://localhost:8180 if you are on the Tomcat box. If you got a generic Tomcat page similar to the one pictured below, all is well in the world. If you have problems, check out /var/log/tomcat6.log for errors and use /usr/local/etc/rc.d/tomcat6 stop and /usr/local/etc/rc.d/tomcat6 start to restart the Tomcat server, as tomcat can restart slowly and trip over it's own port when trying to reconnect when issued a /usr/local/etc/rc.d/tomcat6/restart!
Running Tomcat in Users' Home Directories
Give Apache permission to serve out files from users' home directories.
- # vi /usr/local/etc/apache22/httpd.conf
- ... ... ... ... ...
- Include etc/apache22/extra/httpd-userdir.conf
- ... ... ... ... ...
- # apachectl restart
Give Tomcat a host to serve up requests for.
- # vim /usr/local/apache-tomcat-6.0/conf/server.xml
- </Host>
- ... ... ... ... ...
- <Host name="10.10.20.105">
- <Listener className="org.apache.catalina.startup.UserConfig"
- directoryName="public_html"
- userClass="org.apache.caralina.startup.PasswdUserDatabase"/>
- </Host>
- ... ... ... ... ...
- </Engine>
- </Service>
- </Server>
Restart the server so changes take effect. Also, watch the logs for any garbage!
- # /usr/local/etc/rc.d/tomcat6 restart
- # tail -n 30 /var/log/tomcat6.log
- # sockstat -l4 | grep java
- www java 4824 27 tcp4 *:8180 *:*
- www java 4824 43 tcp4 *:8009 *:*
- www java 4824 46 tcp4 127.0.0.1:8005 *:*
Make a test file to make sure you can parse a .jsp file correctly in an unspecified user's directory.
- # su some_user
- $ mkdir -p ~/public_html
- $ vi ~/public_html/hello.jsp
- TESTING: <% out.println("Hello World!"); %>!
Now open up a web browser and visit http://hostname_or_ip:8180:/~some_user/hello.jsp or http://localhost:8180:/~some_user/hello.jsp if you are physically on the server. You should be able to parse any .jsp file in the web root directory (/home/some_user/public_html in our case) and any file in /home/some_user/public_html/servlets.
Configure apache 2.2
- # echo 'apache22_enable="YES"' >> /etc/rc.conf
- # kldload accf_http
- # echo 'acct_http_load="YES"' >> /boot/loader.conf
- # /usr/local/etc/rc.d/apache22 start
Verify that the webserver is working correctly by entering the new webserver's IP address in a browser on the local network and make sure you get a page that says It Works!.
http://localhost would work if you are in a browser on the new webserver box.
Now do some generic Apache configuration.
- # vi /usr/local/etc/apache22/httpd.conf
- ... ... ... ... ...
- ServerAdmin user@emailaddr.com
- ... ... ... ... ...
- Include etc/apache22/extra/httpd-default.conf
- ... ... ... ... ...
- # vi /usr/local/etc/apache22/extra/httpd-default.conf .
- ... ... ... ... ...
- ServerTokens Prod
- ... ... ... ... ...
- ServerSignature Off
- ... ... ... ... ...
Apache VHOST
- # cd /usr/local/etc/apache22/extra
- # mv httpd-vhosts.conf httpd-vhosts.conf.original
- # mkdir /var/log/httpd
- # vi /usr/local/etc/apache22/extra/httpd-vhosts.conf
- NameVirtualHost *:80
- <VirtualHost *:80>
- ServerAdmin webmaster@example.com
- DocumentRoot "/usr/local/www/apache22/data/example.com"
- ServerName www.example.com
- ServerAlias example.com web.example.com
- ErrorLog "/var/log/httpd/example.com-error_log"
- CustomLog "/var/log/httpd/example.com-access_log" common
- ... ... ... ... ...
- JkMount /∗.jsp
- JkMount /servlets/∗
- ... ... ... ... ...
- </VirtualHost>
- # mkdir /var/log/httpd
- # mkdir -p /usr/local/www/apache22/data/example.com
- # apachectl restart
- # vi /usr/local/www/apache22/data/example.com/test.jsp
- TESTING: <% out.println("Hello World!"); %>!
Don't forget that each vhost hostname must have a corresponding <Host> directive in Tomcat's conf/server.xml file to answer requests properly.
- # vim /usr/local/apache-tomcat-6.0/conf/server.xml
- </Host>
- ... ... ... ... ...
- <Host name="example.com"
- appBase="/usr/local/www/apache22/data/example.com"
- unpackWARs="true" autoDeploy="true">
- <Context path="" docBase="public_html" debug="0" reloadable="true"/>
- <Valve className="org.apache.catalina.valves.AccessLogValve"
- directory="/var/log/tomcat6"
- prefix="tomcat_access_"
- suffix=".log" pattern="common" resolveHosts="false"/>
- </Host>
- ... ... ... ... ...
- </Engine>
- </Service>
- </Server>
- # mkdir /var/log/tomcat6
- # chgrp www /var/log/tomcat6
- # chmod g+w /var/log/tomcat6
- # /usr/local/etc/rc.d/tomcat6 restart
- # tail -n 30 /var/log/tomcat6.log
- # sockstat -l4 | grep java
- www java 4824 27 tcp4 *:8180 *:*
- www java 4824 43 tcp4 *:8009 *:*
- www java 4824 46 tcp4 127.0.0.1:8005 *:*
Now go to http://example.com/test.jsp (but with the hostname you chose!) in a web browser. You should see the text "TESTING: Hello World!" printed out if everything went smoothly.
Configure mod_jk
- # cd /usr/local/etc/apache22
- # cp workers.properties.sample workers.properties
- # vi workers.properties
- worker.list=localhost
- worker.localhost.port=8009
- worker.localhost.host=localhost
- worker.localhost.type=ajp13
- worker.localhost.lbfactor=1
- workers.tomcat_home=/usr/local/apache-tomcat6.0
- workers.java_home=/usr/local/diablo-jdk1.6.0
- # vi /usr/local/etc/apache22/Includes/mod_jk.conf
- LoadModule jk_module libexec/apache22/mod_jk.so
- JkWorkersFile /usr/local/etc/apache22/workers.properties
- JkLogFile /var/log/mod_jk.log
- JkShmFile /var/log/mod_jk-runtime-status
- JkLogLevel error
- # apachectl restart
- Tags
- AI (1)
- ALIX (1)
- digitalfoo.net (2)
- embedded (6)
- FreeBSD (30)
- Java (1)
- Linux (26)
- misc (7)
- my projects (1)
- MySQL (2)
- NanoBSD (3)
- opensource (7)
- perl (1)
- PHP (3)
- programming (11)
- Python (1)
- security (4)
- Archives
- 2011
- February (1)
- March (1)
- June (1)
- July (1)
- August (1)
- 2010
- June (5)
- July (2)
- December (4)
- April (6)
- March (2)
- May (1)
- August (2)
- October (1)
- November (1)
- 2009
- August (7)
- July (8)
- April (4)
- May (4)
- December (2)
- June (1)
- September (1)
- November (4)
- October (1)
- Web Tools
- Index
- dig-shovel Live
- SQL Injection Encoder
- Links
-

