Skip to content

Instantly share code, notes, and snippets.

@billerby
Forked from tankchintan/gist:1335220
Last active December 16, 2015 07:59
Show Gist options
  • Save billerby/5402761 to your computer and use it in GitHub Desktop.
Save billerby/5402761 to your computer and use it in GitHub Desktop.
# Get the latest Sun Java SDK from Oracle http://www.oracle.com/technetwork/java/javase/downloads/jdk-7u1-download-513651.html
wget http://download.oracle.com/otn-pub/java/jdk/7u21-b11/jdk-7u21-linux-x64.rpm?AuthParam=1366191299_077cdb0b196500e0d7250707139c1cf7
# Rename the file downloaded, just to be nice
mv jdk-7u21-linux-x64.rpm\?AuthParam\=1366191299_077cdb0b196500e0d7250707139c1cf7 jdk-7u21-linux-x64.rpm
# Install Java
sudo rpm -i jdk-7u21-linux-x64.rpm
# Check if the default java version is set to sun jdk
java -version
# If not then lets create one more alternative for Java for Sun JDK
sudo /usr/sbin/alternatives --install /usr/bin/java java /usr/java/jdk1.7.0_21/bin/java 20000
# Set the SUN JDK as the default java
sudo /usr/sbin/alternatives --config java
# Verify if change in SDK was done.
java -version
# Set JAVA_HOME Globally
sudo vi /etc/profile.d/java.sh
# Add the following to the file
export JAVA_HOME=/usr/java/jdk1.7.0_21
#Source it to pick up the variable instantly without reboot
source /etc/profile.d/java.sh
# link http://cloud.dzone.com/articles/commissioning-glassfish-3
1. Create a user
I decided to create my own GlassFish user that exists solely to run GlassFish. You could use your own existing account as well. I also created a new group for use only by this user. I.e. I don't want this user to have any Linux admin privileges.
sudo groupadd glassfish
sudo useradd -s /bin/bash -d /home/glassfish -m -g glassfish glassfish
UNDO:
sudo userdel glassfish
sudo groupdel glassfish
2. Login as the new user in a terminal window and set a password (if desired)
sudo passwd glassfish
sudo -i -u glassfish
#Download Glassfish
wget http://download.oracle.com/otn-pub/java/glassfish/3122/ogs-3.1.2.2.zip?AuthParam=1366197758_4dfb581ee0548a74d10fd00fe6af1b0f
#Rename
mv ogs-3.1.2.2.zip\?AuthParam\=1366197758_4dfb581ee0548a74d10fd00fe6af1b0f ogs-3.1.2.2.zip
unzip ogs-3.1.2.2.zip
4. Exit the shell from step 2
5. Copy the script to /etc/init.d and configure it as a Service
sudo cp the-script /etc/init.d/glassfish
sudo chkconfig --add glassfish
sudo chkconfig --level 2345 glassfish on
# deamon
http://anandnalya.com/2009/04/07/running-glassfish-as-a-service-on-centos/
#Firewall port forwarding
sudo iptables -A INPUT -p tcp --dport 80 -j ACCEPT
sudo iptables -t nat -A PREROUTING -p tcp -m tcp --dport 80 -j REDIRECT --to-ports 8080
sudo service iptables save
sudo chkconfig --level 345 iptables on
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment