1. 安裝jdkjava
2. 下載並安裝glassfish4linux
[root@linuxidc ~]# mv glassfish-4.0-ml.zip /usr/share/glassfish-4.0-ml.zip
[root@linuxidc ~]# cd /usr/share
[root@linuxidc share]# unzip -q glassfish-4.0-ml.zip
[root@linuxidc share]# groupadd webserver
[root@linuxidc share]# useradd -m -g webserver -G webserver webapp
[root@linuxidc share]# id webapp
[root@linuxidc share]# passwd webapp
[root@linuxidc share]# chown -R webapp:webserve /user/share/glassfish4web
3. 將運行的glassfish 設置爲服務bash
[root@linuxidc ~]# cd /etc/init.d
[root@linuxidc init.d]# vi glassfish
#!/bin/bash
# description: Glassfish Start Stop Restart
# processname: glassfish
# chkconfig: 234 20 80
JAVA_HOME=/usr/java/jdk1.7.0_55
export JAVA_HOME
PATH=$JAVA_HOME/bin:$PATH
export PATH
GLASSFISH_HOME=/usr/share/glassfish4/glassfish
case $1 in
start)
sh $GLASSFISH_HOME/bin/asadmin start-domain domain1
;;
stop)
sh $GLASSFISH_HOME/bin/asadmin stop-domain domain1
;;
restart)
sh $GLASSFISH_HOME/bin/asadmin stop-domain domain1
sh $GLASSFISH_HOME/bin/asadmin start-domain domain1
;;
esac
exit 0
[root@linuxidc init.d]# chmod 755 glassfish
[root@linuxidc init.d]# chkconfig --add glassfish
[root@linuxidc init.d]# chkconfig --level 234 glassfish onapp
4. 啓動glassfishdom
[root@linuxidc init.d]# service glassfish start
Waiting for domain1 to start .........
Successfully started the domain : domain1
domain Location: /usr/share/glassfish4/glassfish/domains/domain1
Log File: /usr/share/glassfish4/glassfish/domains/domain1/logs/server.log
Admin Port: 4848
Command start-domain executed successfully.webapp
5. 修改管理員admin賬戶密碼tcp
[root@linuxidc init.d]#cd /usr/share/glassfish4/glassfish/bin
[root@linuxidc bin]#./asadmin change-admin-passwordrest
6. 設置遠程訪問server
[root@linuxidc bin]#./asadmin --host 192.168.1.114 --port 4848 enable-secure-admin
7. 重啓glassfish
[root@linuxidc ~]#service glassfish restart
8. 若是訪問不到,注意開啓防火牆484八、80端口
[root@linuxidc ~]#vi /etc/sysconfig/iptables
-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 4848 -j ACCEPT
[root@linuxidc ~]#/etc/init.d/iptables restart
9. 關閉glassfish服務
[root@linuxidc ~]# service glassfish stopWaiting for the domain to stop ....Command stop-domain executed successfully.