Saturday, November 12, 2011

Apache, Tomcat, SVN, virtual hosts integration

Ever come across this kind of requirement involving Apache httpd, Tomcat, SVN and virtual hosts?



  • want static sites being served by Apache

  • want dyanmic content (jsps, etc) served by Tomcat

  • want to access your svn via port 80

  • must work in a multiple virtual hosts environment

  • want to do it an easy, extensible and with minimal reliance on 3rd party tools


Sure ... some would say. Easy problem. Just do it via http tunneling, or rewrite rules or some such.


And to an extent they would be valid. However, needs vary.



Here is one way to make all this happen.



Versions:

  • Apache 2.x

  • Tomcat 6.x

  • mod_jk 1.2.32

  • mod_proxy



Files required to be changed



  • Apache
    httpd.conf



  • Tomcat
    server.xml


Files added:



  • Apache
    $APACHE_HOME/conf.d/workers.properties
    $APACHE_HOME/conf.d/mod_jk.conf
    $APACHE_HOME/conf.d/httpd-vhosts.conf



Apache level changes



httpd.conf


Our Apache home is: /etc/httpd and its conf file is at /etc/httpd/conf/httpd.conf


Make sure your Apache conf is setup to autoload all conf files at startup.


Modify ApacheHome/conf.d, as needed




#
# Load config files from the config directory "/etc/httpd/conf.d".
#
Include conf.d/*.conf

If you had any include directives pointing to files in the conf.d directory, they are now redundant and can be removed.



workers.properties


Create the workers properties file $APACHE_HOME/conf.d/workers.properties as below:


# Define 1 real worker using ajp13
worker.list=ajp13,childtracker_ajp13

# Set properties for ajp13
worker.ajp13.type=ajp13
worker.ajp13.host=localhost
worker.ajp13.port=8009

# Set properties for childtracker_ajp13
worker.childtracker_ajp13.type=ajp13
worker.childtracker_ajp13.host=localhost
worker.childtracker_ajp13.port=8009



mod_jk


For linux, mod_jk.so has to be compiled from source. Its a pretty straight-forward process.
Ref: Connections download page



Installation


mod_jk has been installed at -/usr/local/src/mod_jk_


Installation steps from "Build.txt":


$> cd native
$> ./configure --with-apxs=/usr/sbin/apxs (or where ever the apxs/apxs2 is)
$> make
$> su -c 'make install'



mod_jk.conf


Create file $APACHE_HOME/conf.d/mod_jk.conf as below:


#
# Added for Tomcat integration
# by Dheeraj
#

# Load mod_jk
LoadModule jk_module modules/mod_jk.so

# where to find workers.properties
JkWorkersFile /etc/httpd/conf.d/workers.properties

# where to put jk shared memory
JkShmFile /var/run/httpd/mod_jk.shm

# where to put logs
JkLogFile /etc/httpd/logs/mod_jk.log

# Set the jk log level
JkLogLevel info

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

# JkRequestLogFormat - set format
JkRequestLogFormat "%w %V %T"

# Send everything for context /examples to worker ajp13
JkMount /examples ajp13
JkMount /examples/* ajp13

AddHandler jserv-servlet .do
JkOptions +ForwardURICompatUnparsed


The commented lines highlight Windows level changes



Virtual hosts - httpd-vhosts.conf


Create this file in $APACHE_HOME/conf.d/http_vhosts.conf:



#
# Virtual Hosts
#
# If you want to maintain multiple domains/hostnames on your
# machine you can setup VirtualHost containers for them. Most configurations
# use only name-based virtual hosts so the server doesn't need to worry about
# IP addresses. This is indicated by the asterisks in the directives below.
#
# Please see the documentation at
# <URL:http://httpd.apache.org/docs/2.2/vhosts/>
# for further details before you try to setup virtual hosts.
#
# You may use the command line option '-S' to verify your virtual host
# configuration.

#
# Use name-based virtual hosting.
#
NameVirtualHost *:80


<VirtualHost *:80>

ServerName abc.xyz.com
ProxyPass /repos !
ProxyPass / http://abc.xyz.com:8080/
ErrorLog logs/abc-error.log
CustomLog logs/abc-access.log common
</VirtualHost>


Tomcat level changes


Set the AJP connector


<!-- Define an AJP 1.3 Connector on port 8009 -->
<Connector port="8009" protocol="AJP/1.3" redirectPort="8443" enableLookups="false"/>



Verification



mod_jk.log


You should see output like this


[Mon Nov 07 02:38:26: 2011][26261:47626733695808] [info] init_jk::mod_jk.c (3252): mod_jk/1.2.32 () initialized



catalina.out


You should see output like this in catalina.out


Nov 7, 2011 2:43:12 AM org.apache.jk.common.ChannelSocket init
INFO: JK: ajp13 listening on /0.0.0.0:8009
Nov 7, 2011 2:43:12 AM org.apache.jk.server.JkMain start
INFO: Jk running ID=0 time=0/10 config=null


for more details regarding each tool, pls refer to their respective home pages.

Sunday, August 21, 2011

Redmine Mylyn integration howto

There is a dearth of a reasonably complete step by step howto on integrating the latest version of Redmine (1.2) with Eclipse 3.5.2 (onwards). In fact, when I looked, the relevant information was somewhat "splintered" (frustration > progress) across sites that ultimately led me exasperated. This is what I am trying to address by this entry. Hopefully, it helps others get off to a running start.

Pre-requisites:
Eclipse: 3.5.2
Redmine: 1.2
Mylyn: 3.6.1

Install Eclipse plugin
1. In Eclipse: Help - Install New Software - Add
2. Enter the following details:

   The update site is: http://redmin-mylyncon.sourceforge.net/update-site/N/

Install Redmine plugin

This was the tricky part. Took most time to figure out. Git was not behaving. So, had to do things the old fashioned way ... sigh!

These steps need to be done on the server - where Redmine is hosted.

1. Use lynx or browser, open: http://redmin-mylyncon.git.sourceforge.net/git/gitweb-index.cgi
2. Click on "summary". You should see a list of commit log entries for the connector. For Redmine 1.2, one needs at least ver 2.7.4
3. Download the snapshot by clicking on the snapshot link. (I used ver 2.7.4 - use a more recent version, if available). You will get a tar.gz file
4. Unzip and untar it. You should get a "redmin-mylyn-connector" directory
5. Copy directory to <Redmine_HOME>/vendor/plugins (hint: Your cmd would be like: cp -R redmin-mylyn-connector <Redmine_HOME>/vendor/plugins"
6. Shutdown Redmine
7. Restart Redmine
8. Go to Administration - Plugins. Make sure you see "Mylyn Connector plugin" (min ver. 2.7.4)

Configure Redmine

1. Go to Administration - Settings - Authentication

2. Enable: Authentication Required
3. Enable: Enable REST web service

Configure Eclipse

1. Go to Eclipse menu: Window–>Show View–>Other–>Tasks–>Tasks List
2. Right click in the Tasks List area and select New–>Task.
3. Click 'Add Tasks Repository' button and select the Redmine task repository type.
4. In the popup form enter (http://<Redmine_URL>, label == "Redmine", user name, password)
5. Press "Validate Settings" button at the bottom of the form, and you should get a "Connection successful" status message. You should be able to submit issues from your eclipse IDE, now.

Setting up Task List

In Eclipse:

1. Open: Window - Open Perspective - Other
2. Select "Planning"

Create a List of "Open issues Assigned to me"

1. On the task list, right-click and choose New -> Query...
2. Select your newly created repository
3. Click "<<Create a new query>>" , click Next
4. Enter the following:
      Title: All Open Issues assigned to Me
      status_id: Open
      assigned_to_id: <Your name>
      click 'Finish'

You're done! Pat yourself on the back by closing this ticket from your Task list and send me a "Whoohoo" comment on this blog entry!



FAQ:

Q. I have followed the steps but I get a "404 message" when I validate settings
A. This typically happens when:
      - you don't have the right version of the connector installed. Review the Install Redmine plugin steps.