Glassfish Open Source installation step by step procedure
Create User Account
#Create new usersudo adduser --home /home/glassfish --system --shell /bin/bash glassfish
#Create new user group
sudo groupadd glassfishadmin
#Assign glassfish user to glassfishadmin group
sudo usermod -a -G glassfishadmin glassfish
Configure Java
#Remove openjdk if installed
sudo apt-get remove openjdk-6-jre openjdk-6-jdk
#Remove sun's jdk if installed
sudo apt-get remove sun-java6-jdk sun-java6-jre
#Remove unwanted automatically installed packages
sudo apt-get autoremove
sudo apt-get autoclean
#Extract jdk 7 tar file
tar -xvf jdk-7u7-linux-x64.tar.gz
#Remove previous jdk 7 installations
rm -rf /usr/lib/jvm/jdk1.7
#If jvm folder doesn't exist, create a new one
sudo mkdir /usr/lib/jvm
#Move extracted files
sudo mv ./jdk1.7 /usr/lib/jvm/jdk1.7
sudo chgrp -R root /usr/lib/jvm/jdk1.7
sudo chown -R root /usr/lib/jvm/jdk1.7
#Update alternatives
sudo update-alternatives --install "/usr/bin/java" "java" "/usr/lib/jvm/jdk1.7/bin/java" 1
sudo update-alternatives --install "/usr/bin/javac" "javac" "/usr/lib/jvm/jdk1.7/bin/javac" 1
sudo update-alternatives --install "/usr/bin/javaws" "javaws" "/usr/lib/jvm/jdk1.7/bin/javaws" 1
sudo update-alternatives --config java
#Check jdk installation
cd /etc/alternatives
ls -lrt java*
#Setting environment variables JAVA_HOMEfor all users(only for bash)
sudo nano /etc/bash.bashrc
#append the following lines:
export GLASSFISH_HOME=/home/glassfish
export JAVA_HOME=/usr/lib/jvm/jdk1.7
export PATH=$PATH:$JAVA_HOME/bin:$GLASSFISH_HOME/bin
#Setting JAVA_HOME and AS_JAVA for everyone
sudo nano /etc/environment
#append the following lines:
JAVA_HOME=/usr/lib/jvm/jdk1.7
AS_JAVA=/usr/lib/jvm/jdk1.7
#Finally check the installation in /etc/alternatives directoy
cd /etc/alternatives
ls -lrt java*
Glassfish installation
#switch over to glassfish user account
sudo su glassfish
#Change to home directory of glassfish
cd /home/glassfish/
#Create downloads directory
mkdir downloads
#Go to downloads directory
cd /home/glassfish/downloads/
#Download and install glassfish 3.1.2
unzip glassfish-3.1.2.zip
#Move extracted contents to glassfish home directory
mv /home/glassfish/downloads/glassfish3.1.2/* /home/glassfish/
#Exit from glassfish user
exit
#change group of glassfish home directory to glassfishadmin
sudo chgrp -R glassfishadmin /home/glassfish
#change owner of glassfish home directory to glassfish
sudo chown -R glassfish /home/glassfish
#make sure the files are executable/modifyable/readable for owner and group
sudo chmod -R ug+rwx /home/glassfish/bin/
sudo chmod -R ug+rwx /home/glassfish/glassfish/bin/
#others are not allowed to execute/modify/read them
sudo chmod -R o-rwx /home/glassfish/bin/
sudo chmod -R o-rwx /home/glassfish/glassfish/bin/
#Now you can start and stop glassfish
#Switch over to glassfish user
sudo su glassfish
#Start glassfish
/home/glassfish/bin/asadmin start-domain domain1
#Stop glassfish
/home/glassfish/bin/asadmin stop-domain domain1
#Exit
exit
Configure glassfish init script
#Now you need an init script to automatically start glassfish on system reboot.
#Create init script
sudo nano /etc/init.d/glassfish
#(paste the lines below into the file and save it)
#! /bin/sh
export AS_JAVA=/usr/lib/jvm/jdk1.7
GLASSFISHPATH=/home/glassfish/bin
case "$1" in
start)
echo "starting glassfish from $GLASSFISHPATH"
sudo -u glassfish $GLASSFISHPATH/asadmin start-domain domain1
;;
restart)
$0 stop
$0 start
;;
stop)
echo "stopping glassfish from $GLASSFISHPATH"
sudo -u glassfish $GLASSFISHPATH/asadmin stop-domain domain1
;;
*)
echo $"usage: $0 {start|stop|restart}"
exit 3
;;
esac
:
#To start this init script automatically issue the following commands
#Make the init script executable
sudo chmod a+x /etc/init.d/glassfish
#configure Glassfish for autostart on linux boot
sudo update-rc.d glassfish defaults
#if apache2 is installed, remove that from startup
#stopping apache2
sudo /etc/init.d/apache2 stop
#removing apache2 from autostart
update-rc.d -f apache2 remove
#Now we can start glassfish easily be the following commands
#start
/etc/init.d/glassfish start
#stop
/etc/init.d/glassfish stop
#restart
/etc/init.d/glassfish restart
No comments:
Post a Comment