KB: Running Glassfish behind Apache on Ubuntu

Configuration guide for running Glassfish behind Apache on Ubuntu Linux.

Contents

Overview

This guide was created to document part of the process of installing Hudson and making it available through Apache. This guide assumes that one will be installing Glassfish to /opt/SDK and Apache is already configured and running. The final result is the ability to access Hudson from the following URL:

http://projects.zunisoft.com/hudson

Install Glassfish

1. Install mod_jk from libapache-mod-jk:

apt-get install libapache-mod-jk

2. Create Glassfish user:

adduser sjas

3. Create a new directory:

mkdir /opt/SDK
chown sjas:sjas /opt/SDK

4. Run the Glassfish installer as the user ‘sjas’.

AJP Configuration

1. Copy from Tomcat 5.5.16 and Jakarta Commons copy the following files to /opt/JEE/lib:

tomcat-ajp.jar
commons-logging.jar
commons-modeler.jar

2. Create directory ‘projects’ under /var/www:

mkdir /var/projects

3. Create file /etc/apache2/worker.properties:

 
worker.list = worker1

worker.worker1.type=ajp13
worker.worker1.host=localhost
worker.worker1.port=8009
worker.worker1.lbfactor=50
worker.worker1.cachesize=10
worker.worker1.cache_timeout=600
worker.worker1.socket_keepalive=1
worker.worker1.socket_timeout=300

MOD_JK Configuration

1. Create file /etc/apache2/mods-available/jk.load:

LoadModule jk_module /usr/lib/apache2/modules/mod_jk.so

2. Create file /etc/apache2/mods-available/jk.conf:


# mod_jk configuration

JkWorkersFile /etc/apache2/worker.properties
JkLogFile /var/log/apache2/mod_jk.log
JkLogLevel error
JkLogStampFormat "[%a %b %d %H:%M:%S %Y] "
JkOptions +ForwardKeySize +ForwardURICompat -ForwardDirectories
JkRequestLogFormat "%w %V %T"
#JkMount /*.jsp worker1

3. Create the following links in /etc/mods-enabled:

ln -s /etc/apache2/mods-available/jk.load jk.load
ln -s /etc/apache2/mods-available/jk.conf jk.conf

4. Append this section to the end of /etc/apache2/sites-available/zunisoft:

  
<virtualhost *:80>
        ServerName build.zunisoft.com
        ServerAdmin webmaster@zunisoft.com

        JkMount /hudson/* worker1

        DocumentRoot /var/www/projects

        ErrorLog /var/log/apache2/build.error.log

        # Possible values include: debug, info, notice, warn, error, crit,
        # alert, emerg.
        LogLevel warn

        CustomLog /var/log/apache2/build.access.log combined
        ServerSignature On
</virtualhost>

5. Restart Apache:

/etc/init.d/apache2 restart

6. Enable AJP on Glassfish:

/opt/SDK/bin/asadmin create-jvm-options -Dcom.sun.enterprise.web.connector.enableJK=8009

7. Restart Glassfish

Startup Script

  #! /bin/sh
  #
  # Keith Davis - 11/25/06
  # ADD: update-rc.d sjas defaults
  # REMOVE: update-rc.d sjas remove
  # /etc/init.d/sjas: start and stop the SJAS

  test -f /lib/lsb/init-functions || exit 1
  . /lib/lsb/init-functions

  case "$1" in
      start)
          log_begin_msg "Starting SJAS..."
          su sjas -c '/opt/SDK/bin/asadmin start-domain domain1'
          log_end_msg 0
          ;;
      stop)
          log_begin_msg "Stopping SJAS..."
          su sjas -c '/opt/SDK/bin/asadmin stop-domain domain1'
          log_end_msg 0
          ;;
      *)
          log_success_msg "Usage: /etc/init.d/sjas {start|stop}"
          exit 1
      esac
  exit 0

To Top

Please follow and like us:

One Reply to “KB: Running Glassfish behind Apache on Ubuntu”

Leave a Reply

Your email address will not be published. Required fields are marked *