红联Linux门户
Linux帮助

CentOS 6.5上安装GlassFish4.0过程笔记

发布时间:2015-03-31 22:24:44来源:linux网站作者:linux人

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

[root@linux ~]# mkdir /usr/java
[root@linux ~]# cd /usr/java
[root@linux java]#rpm -Uvh /bak/jdk-7u55-linux-x64.rpm
 
[root@linux java]# JAVA_HOME=/usr/java/jdk1.7.0_55
[root@linux java]# export JAVA_HOME
[root@linux java]# PATH=$JAVA_HOME/bin:$PATH
[root@linux java]# export PATH
 
[root@linux java]# vi /etc/profile
JAVA_HOME=/usr/java/jdk1.7.0_55
export JAVA_HOME
PATH=$JAVA_HOME/bin:$PATH
export PATH
[root@linux java]# source /etc/profile
 
[root@linux ~]#  echo $JAVA_HOME
/usr/java/jdk1.7.0_55


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

[root@linux ~]# mv glassfish-4.0-ml.zip /usr/share/glassfish-4.0-ml.zip
[root@linux ~]# cd /usr/share
[root@linux share]# unzip -q glassfish-4.0-ml.zip
 
[root@linux share]# groupadd webserver
[root@linux share]#  useradd -m -g webserver -G webserver webapp
[root@linux share]#  id webapp
[root@linux share]#  passwd webapp
[root@linux share]# chown -R webapp:webserve /user/share/glassfish4


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

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


4. 启动glassfish

[root@linux 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@linux init.d]#cd /usr/share/glassfish4/glassfish/bin
[root@linux bin]#./asadmin change-admin-password


6. 设置远程访问

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


7. 重启glassfish
 
[root@linux ~]#service glassfish restart


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

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


9. 关闭glassfish服务

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