glassfish centos 6

mkdir /usr/java
cd /usr/java
tar -xzf jdk-7u5-linux-i586.tar.gz
vi ‘~/.bash_profile’

export JAVA_HOME=/usr/java/jdk1.7.0_05
export PATH=$JAVA_HOME/bin:$PATH
.bash_profile
echo $JAVA_HOME

cd /opt
wget http://download.java.net/glassfish/3.1.2/release/glassfish-3.1.2.zip
unzip glassfish-3.1.2.zip

groupadd glassfish
useradd -s /bin/bash -g glassfish glassfish
chown -R glassfish: /opt/glassfish3/
passwd glassfish

Create a start/stop/restart script:

vi /etc/init.d/glassfish

#!/usr/bin/env bash
# description: Glassfish start/stop/restart
# processname: glassfish
# chkconfig: 2445 20 80
JAVA_HOME=/usr/java/jdk1.7.0_05
export JAVA_HOME
PATH=$JAVA_HOME/bin:$PATH
export PATH
GLASSFISH_HOME=/opt/glassfish3/glassfish/
GLASSFISH_USER=glassfish

case $1 in
start)
su $GLASSFISH_USER -c "$GLASSFISH_HOME/bin/asadmin start-domain domain1"
;;
stop)
su $GLASSFISH_USER -c "$GLASSFISH_HOME/bin/asadmin stop-domain domain1"
;;
restart)
su $GLASSFISH_USER -c "$GLASSFISH_HOME/bin/asadmin stop-domain domain1"
su $GLASSFISH_USER -c "$GLASSFISH_HOME/bin/asadmin start-domain domain1"
;;
esac
exit 0

chmod +x /etc/init.d/glassfish
:

chkconfig --add glassfish
chkconfig glassfish on

/etc/init.d/glassfish start/stop/restart

Leave a Reply

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