I can’t believe how much time I spent on this simple task … couldn’t find a straight answer anywhere. Hope this posting may help some other souls looking for the same thing –

Goal –
Setup a production environment that includes –
Debian (5.0.3) OS (Lenny)
Java SE 5 (1.5x)
MySQL 5.0.50+ (already installed)
Apache2 as Web server, SSL enabled
Sun Glassfish application server connecting through
mod_proxy, AJP

The problem
Getting Glassfish to talk to Apache2

Steps:
1. To get rid off Apache2 startup warnings “apache2: Could not reliably determine the server’s fully qualified domain name, using 127.0.0.1 for ServerName”
edit /etc/apache2/httpd.conf add:
ServerName localhost
restart:
/etc/init.d/apache2 restart

1. Components needed
apt-get install apache2
apt-get install mysql-server
apt-get install openjdk-6-jdk
apt-get install libapache2-mod-proxy-html

2. To install and enable SSL (for dev/test only. Not for production site where a real certificate is needed!)
a2ensite default-ssl
a2enmod ssl

For production, read the document that comes with apache2 –
/usr/share/doc/apache2.2-common/README.Debian

3. Enable proxy ajp
a2enmod proxy
a2enmod proxy_http
a2enmod proxy_html
a2enmod proxy_ajp
a2enmod proxy_balancer

4. Install Glassfish
Add user –
useradd -d /home/glassfish -g apptest glassfish

java -jar -mx1024M glassfish-installer-v2.1-b60e-linux.jar
mv glassfish /usr/local/.
chown -R glassfish /usr/local/glassfish
chgrp -R apptest /usr/local/glassfish
login as “glassfish”
java -jar -mx1024M glassfish-installer-v2.1-b60e-linux.jar
mv glassfish /usr/local/.
chmod 755 /usr/local/glassfish/lib/ant/bin/ant
cd /usr/local/glassfish
/opt/glassfish/lib/ant/bin/ant -f setup.xml
Add glassfish to /etc/init.d (see bottom)
Add to auto restart –
update-rc.d glassfish defaults

5. Config ajp for Apache
vi /etc/apache2/mods-enabled/proxy.conf
Change “Deny from All” to “Allow from All”
Change to –
#ProxyVia On

Order allow,deny
Allow from all
ProxyPass ajp://localhost:8009/minnow
ProxyPassReverse ajp://localhost:8009/minnow

6. Config ajp for Glassfish
cp commons-logging-1.1.1.jar commons-modeler-2.0.1.jar tomcat-ajp.jar /usr/local/glassfish/lib
(Find the jar files somewhere)
cd /usr/local/glassfish
bin/asadmin start-domain domain1

7. Config. application
From GUI – always go to http://server:4848
Go to left bar, Configuration/System Properties (see Manual alternative below)
Go to left bar
Applicaton Server/JVM Settings/JVM Options
Add new option –
-Dcom.sun.enterprise.web.connector.enableJK=8009

Manual –
vi /usr/local/glassfish/domains/domain1/config/domain.xml
search for where it says –

Insert

(and more)
between management-rules and config

** NOTE **
For dev – REMOVE ALL IP-related entries and then restart!

————-/etc/init.d/glassfish——————————————
#! /bin/sh
### BEGIN INIT INFO
# Provides: glassfish
# Required-Start: $local_fs $remote_fs $network $syslog
# Required-Stop: $local_fs $remote_fs $network $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start/stop glassfish application server
### END INIT INFO

GLASSFISHPATH=/usr/local/glassfish/bin

case “$1″ in
start)
echo “starting glassfish from $GLASSFISHPATH”
su – glassfish $GLASSFISHPATH/asadmin start-domain domain1
;;
restart)
$0 stop
$0 start
;;
stop)
echo “stopping glassfish from $GLASSFISHPATH”
su – glassfish $GLASSFISHPATH/asadmin stop-domain domain1
;;
*)
echo $”usage: $0 {start|stop|restart}”
exit 3
;;
esac

Advertisements