CentOS 6.5上安装GlassFish4.0 过程笔记
1.安装JDK, 注意操作系统的位数, 64 or 32:
[root@linuxidc ~]# mkdir /usr/java
[root@linuxidc ~]# cd /usr/java
[root@linuxidc java]#rpm -Uvh /bak/jdk-7u55-linux-x64.rpm
[root@linuxidc java]# JAVA_HOME=/usr/java/jdk1.7.0_55
[root@linuxidc java]# export JAVA_HOME
[root@linuxidc java]# PATH=$JAVA_HOME/bin:$PATH
[root@linuxidc java]# export PATH
[root@linuxidc java]# vi /etc/profile
JAVA_HOME=/usr/java/jdk1.7.0_55
export JAVA_HOME
PATH=$JAVA_HOME/bin:$PATH
export PATH
[root@linuxidc java]# source /etc/profile
[root@linuxidc ~]# echo $JAVA_HOME
/usr/java/jdk1.7.0_55
2. 下载并安装glassfish 4, ml多语言版
[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/glassfish4
3. 将运行的glassfish 设置为服务
[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 on
4. 启动glassfish
[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.
5. 修改管理员admin帐户密码
[root@linuxidc init.d]#cd /usr/share/glassfish4/glassfish/bin
[root@linuxidc bin]#./asadmin change-admin-password
6. 设置远程访问
[root@linuxidc bin]#./asadmin --host 192.168.1.114 --port 4848 enable-secure-admin
7. 重启glassfish
[root@linuxidc ~]#service glassfish restart
8. 如果访问不到,注意开启防火墙4848、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 stop
Waiting for the domain to stop ....
Command stop-domain executed successfully.
Ubuntu 12.04 安装 GlassFish3.1.2 http://www.linuxidc.com/Linux/2012-06/62545.htm
CentOS安装GlassFish4.0 配置JDBC连接MySQL http://www.linuxidc.com/Linux/2014-07/104572.htm
GlassFish 的详细介绍:请点这里
GlassFish 的下载地址:请点这里
转自:http://www.linuxidc.com/Linux/2014-10/108419.htm