Installing and configuring Glassfish 4.1 on RHEL and Centos

Reading Time: 1 minute

cd /opt

wget http://dlc.sun.com.edgesuite.net/glassfish/4.1/release/glassfish-4.1.zip

unzip glassfish-4.1.zip

mv glassfish4 glassfish

create glassfish user

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

change the user password

passwd glassfish

nano /etc/init.d/glassfish

add the below line

#!/usr/bin/env bash
# description: Glassfish start/stop/restart
# processname: glassfish
# chkconfig: 2445 20 80
JAVA_HOME=/usr/java/jdk1.7.0_75
export JAVA_HOME
PATH=$JAVA_HOME/bin:$PATH
export PATH
GLASSFISH_HOME=/opt/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

save it

chmod +x /etc/init.d/glassfish

chkconfig --add glassfish

chkconfig glassfish on

reboot

 

cd /opt/glassfish/bin

change admin password

./asadmin --port 4848 change-admin-password

default admin password is empty just push on enter for default password

Enter admin user name [default: admin]>admin
Enter the admin password>
Enter the new admin password>
Enter the new admin password again>
Command change-admin-password executed successfully.

enable remote admin

./asadmin --port 4848 enable-secure-admin

Enter admin user name> admin
Enter admin password for user “admin”>
You must restart all running servers for the change in secure admin to take effect.
Command enable-secure-admin executed successfully.

reboot

add the firewall rule

firewall-cmd --permanent --add-port=8080/tcp
firewall-cmd --permanent --add-port=4848/tcp
firewall-cmd --reload

Leave a Reply

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