====== GlassFish v3 Prelude on your Accelerator ======
===== Setup the 'glassfish' user =====
- Login as root
- Type ''useradd -s /bin/bash -c "GlassFish Application Server" -m glassfish''
You may see the following error:
"UX: useradd: glassfish name too long."
- ''passwd glassfish''
- Login as the new 'glassfish' user:
sudo su glassfish
- Setup the glassfish user profile:
nano -w ~/.profile
and paste the following:
PATH=/opt/local/bin:/opt/local/sbin:/usr/xpg4/bin:/usr/bin:/usr/sbin:/usr/sfw/bin:/usr/openwin/bin:/usr/ccs/bin:/root/bin MANPATH=/opt/local/man:/opt/local/share/man:/usr/share/man:/usr/sfw/share/man:/usr/openwin/share/man
JAVA_HOME=/usr/jdk/latest
JDK_HOME=/usr/jdk/latest
PAGER=less
FTPMODE=auto
export PATH MANPATH JAVA_HOME JDK_HOME PAGER FTPMODE
# for pkgsrc
PKG_PATH=http://pkgsrc.joyent.com/2008Q2/All
export PKG_PATH
HOSTNAME=`/usr/bin/hostname`
HISTSIZE=1000
===== Get the Software =====
You'll find there is no real installation involved. While its up to you if you want the Sun or the community distribution, make sure you choose a **Platform-independent** distribution (Zip file), as opposed to the GUI distribution (you won't be able to run a Swing GUI installer from your Accelerator).
https://glassfish.dev.java.net/public/downloadsindex.html
wget http://download.java.net/glassfish/v3-prelude/release/glassfish-v3-prelude.zip
unzip glassfish-v3-prelude.zip
cd glassfishv3-prelude
===== Start GlassFish =====
//The Quick Way//
You can start GlassFish as follows:
java -Xms32m -Xmx256m -jar glassfish/modules/admin-cli.jar start-domain
Visit http://www.yourdomain.com:4848/
//A Better Way//
There is a provided ''asadmin'' tool to manage your GlassFish installation. However, it needs a quick patch (see [[http://wiki.joyent.com/accelerators:kb:java|Java Memory Issues]] to make it work on your Accelerator).
Open ''GLASSFISH_INSTALL_DIR/bin/asadmin'' in your favorite editor, and change the last line from:
exec java -jar "$AS_INSTALL_LIB/admin-cli.jar" "$@"
to:
exec java -Xms32m -Xmx256m -jar "$AS_INSTALL_LIB/admin-cli.jar" "$@"
You should then be able to control GlassFish much more succinctly.
/opt/glassfish/bin/asadmin stop-domain
Or, if you've added it to your path:
asadmin stop-domain
===== Stopping GlassFish =====
java -Xms32m -Xmx256m -jar glassfish/modules/admin-cli.jar stop-domain
===== Securing =====
This installation is extremely simple, but not yet secure. By default, the web administration console is setup with anonymous access. This means anyone could deploy a web application by accessing the URL.
To secure the administration console:
- Select **Configuration > Security > Realms > admin-realm** from the left-hand navigation.
- Click **Manage Users**
- Click **New...**
- In the new user form:
- enter a User ID for the admin user
- enter 'asadmin' in the Group List
- type a password in the New Password and Confirm New Password fields.
- and when done, click **OK** to save.
To test you're able to login with the new user:
- Click **Logout** in the top right hand corner of the administration console.
- Attempt to login with the User ID and password you just created.
If you were able to login successfully, proceed to delete the anonymous user:
- Select **Configuration > Security > Realms > admin-realm** from the left-hand navigation.
- Click **Manage Users**
- Check 'Anonymous' in the list of users
- Click **Delete**.
===== Configuring =====
==== Change the default page ====
nano /home/glassfish/glassfishv3-prelude/glassfish/domains/domain1/docroot/index.html
and edit to your heart's content.
===== Proxying from Apache =====
This section makes the assumption that you are on an Accelerator deployed after Nov 4 2008 (using [[accelerators:kb:pkgsrc:2008q2|pkgsrc-2008Q2]]). If not, some paths or versions may be different.
- Install Apache mod_jk: pkg_add ap22-jk-1.2.23
- Change to the ''includes'' subdirectory within your Apache configuration directory:
cd /opt/local/etc/httpd/includes
- Edit ''dao.conf'' and insert t
nano -w dso.conf
LoadModule jk_module lib/httpd/mod_jk.so
touch modjk.conf
nano -w modjk.conf
JkWorkersFile /opt/local/etc/httpd/workers.properties
JkLogFile /var/log/httpd/mod_jk.log
JkLogLevel info
JkLogStampFormat "[%a %b %d %H:%M:%S %Y] "
JkOptions +ForwardKeySize +ForwardURICompat -ForwardDirectories
JkRequestLogFormat "%w %V %T"
cd /opt/local/etc/httpd
* backup httpd.conf
cp httpd.conf httpd.conf.111808-old
add the lines to httpd.conf, towards the end.
after Include etc/httpd/includes/modphp.conf:
touch workers.properties
nano workers.properties
# Define 1 real worker using ajp13
worker.list=worker1
# Set properties for worker1 (ajp13)
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
tail -f /var/log/httpd/error.log
tail -f /var/log/httpd/mod_jk.log
---
sudo as glassfish
glassfishv3-prelude/bin/asadmin set server-config.http-service.http-listener.http-listener-1.port=8009
glassfishv3-prelude/bin/asadmin set server-config.http-service.http-listener.http-listener-1.property.jkEnabled=true
xpowered-by="true"
blocking-enabled="false"
nano glassfishv3-prelude/glassfish/domains/domain1/config/domain.xml
restart the GlassFish application server
==== Setting Up a Site ====
cd /opt/local/etc/httpd/virtualhosts/
touch blogs.ikonoklastik.conf
ServerName yoursite.com
JkMount / worker1
Test what your configuration changes:
httpd -t
----
- http://weblogs.java.net/blog/writtmeyer/archive/2008/02/virtual_servers.html
- http://tomcat.apache.org/connectors-doc/webserver_howto/apache.html
- http://weblogs.java.net/blog/jfarcand/archive/2006/03/running_glassfi_1.html
- http://weblogs.java.net/blog/jfarcand/archive/2008/08/fronting_glassf.html