Pixie Blog

Installing JK Connector for Tomcat 6 with Apache2


This is a simple howto for those who want to run tomcat applications and/or services without having to always specify the port (8080).

Step 1: Install libapache2-mod-jk
 
sudo apt-get install libapache2-mod-jk

Step 2: Check whether there is jk.load in the apache 2 modules


sudo ls /etc/apache2/mods-enabled/

If it is not there, enable it.


a2enmod jk

Step 3: Edit and save workers.properties


sudo vi /etc/libapache2-mod-jk/workers.properties

and set:

workers.tomcat_home=/var/lib/tomcat6
workers.java_home=/usr/lib/jvm/java-6-sun

Please enter the correct paths for your system.

Step 4: Let Apache2 know where to find the workers file and where to log, etc


sudo vi /etc/apache2/mods-enabled/jk.load

and add the following:


# Where to find workers.properties
JkWorkersFile /etc/libapache2-mod-jk/workers.properties

# Where to put jk logs
JkLogFile /var/log/apache2/mod_jk.log

# Set the jk log level [debug/error/info]
JkLogLevel debug

# Select the log format
JkLogStampFormat "[%a %b %d %H:%M:%S %Y] "

# JkOptions indicate to send SSL KEY SIZE,
JkOptions +ForwardKeySize +ForwardURICompat -ForwardDirectories

# JkRequestLogFormat set the request format
JkRequestLogFormat "%w %V %T"

Step 5: Edit 000-default to mount a directory to use Tomcat


sudo vi /etc/apache2/sites-enabled/000-default

Then paste the following content just before the </VirtualHost> tag.


# Configuration for mod_jk
# Send servlet for context / jsp-examples to worker named ajp13_worker
JkMount /examples ajp13_worker
# Send JSPs for context /jsp-examples/* to worker named ajp13_worker
JkMount /examples/* ajp13_worker

Step 6: Edit server.xml and uncomment a line


sudo vi /etc/tomcat6/server.xml

Remove the comments around the following.


<Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />

Step 7: Restart apache2


sudo /etc/init.d/apache2 restart

Step 8: Restart tomcat


sudo /etc/init.d/tomcat6 restart


Now the basic setting is finished. You can test by loading the following two urls:

http://your.domain:8080/examples/
http://your.domain/examples/

Both should load the page. The second uses mod_jk.

By Brian

Sending Email with PHP

This is something I have needed to do a number of times. I have also seen numerous requests on the web and in forums for instructions on how to do this. So here are a couple of simple PHP classes I have written to accomplish this.

You can download the complete source code from here: SendEmail

 

Continue reading Sending Email with PHP...

By Brian

PHP Email Validation

Here is a simple PHP function that validates an email address. Please read the complete article on how this is achieved at: 

http://www.linuxjournal.com/article/9585?page=0,0

Continue reading PHP Email Validation...

By Brian

SSH Directly Into A Remote Directory

Ever wanted to ssh directly into a directory other than /home/user? Here is a simple way.

ssh user@<domain or IP address> -t 'cd /path/to/folder ; bash'

You can use dash or any other shell.
By Brian

Updating your computer is almost complete - Restart Now?

Anyone who is running Windows XP SP2 knows what I'm talking about. That stupid, annoying, most ill-designed dialog box ever invented in the history of the computer science that asks "Updating your computer is almost complete. You must restart your computer for the updates to take effect. Do you want to restart your computer now?"

And there are only two options: Restart Now/Restart Later. "Restart Later" means that this stupid thing will ask you again in 10 minutes. Yes, if you're willing to work for the next 4 hours until lunch before rebooting, this means you'll need to answer this question 24 times. Did I mention that the dialog steals the focus?

Now, to get rid of it:

 

Continue reading Updating your computer is almost complete - Restart Now?...

By Brian

Sub Navigation