centos 6.5上安装glassfish4 步骤

  1. 安装JDK, 注意操作系统的位数, 64 or 32:

[root@kakaka ~]# mkdir /usr/java  
[root@kakaka ~]# cd /usr/java
[root@kakaka java]#rpm -Uvh /bak/jdk-7u55-linux-x64.rpm 

[root@kakaka java]# JAVA_HOME=/usr/java/jdk1.7.0_55
[root@kakaka java]# export JAVA_HOME
[root@kakaka java]# PATH=$JAVA_HOME/bin:$PATH
[root@kakaka java]# export PATH

[root@kakaka java]# vi /etc/profile
JAVA_HOME=/usr/java/jdk1.7.0_55
export JAVA_HOME
CLASSPATH=.:$JAVA_HOME/jre/lib/rt.jar:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
export CLASSPATH
PATH=$JAVA_HOME/bin:$PATH 
export PATH
[root@kakaka java]# source /etc/profile

[root@kakaka ~]#  echo $JAVA_HOME
/usr/java/jdk1.7.0_55

   2. 下载并安装glassfish 4, ml多语言版

[root@kakaka ~]# mv glassfish-4.0-ml.zip /usr/share/glassfish-4.0-ml.zip 
[root@kakaka ~]# cd /usr/share
[root@kakaka share]# unzip -q glassfish-4.0-ml.zip

[root@kakaka share]# groupadd webserver
[root@kakaka share]#  useradd -m -g webserver -G webserver webapp
[root@kakaka share]#  id webapp
[root@kakaka share]#  passwd webapp
[root@kakaka share]# chown -R webapp:webserver /usr/share/glassfish4

   3. 将运行的glassfish 设置为服务

[root@kakaka ~]# cd /etc/init.d
[root@kakaka 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@kakaka init.d]# chmod 755 glassfish
[root@kakaka init.d]# chkconfig --add glassfish
[root@kakaka init.d]# chkconfig --level 234 glassfish on

   4. 启动glassfish

[root@kakaka 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.

   5. 修改管理员admin帐户密码

[root@kakaka init.d]#cd /usr/share/glassfish4/glassfish/bin
[root@kakaka bin]#./asadmin change-admin-password

   6. 设置远程访问

[root@kakaka bin]#./asadmin --host 192.168.1.114 --port 4848 enable-secure-admin

   7. 重启glassfish

[root@kakaka ~]#service glassfish restart

   8. 如果访问不到,注意开启防火墙4848、80端口

[root@kakaka ~]#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@kakaka ~]#/etc/init.d/iptables restart

   9. 关闭glassfish服务

[root@kakaka ~]# service glassfish stop
Waiting for the domain to stop ....
Command stop-domain executed successfully.


你可能感兴趣的:(centos6.5,glassfish4)