Centos-Glassfish安装

lpjk7835 9年前

来自: http://my.oschina.net/lovetyh/blog/613990



1.  官网下载jdk1.8.0_31    glassfish-4.1.zip

2.  cd  /usr/local

3.  tar -xzvf  jdk1.8.0_31

4.  vi /etc/profile   

    JAVA_HOME=/usr/local/jdk1.8.0_31  export CLASSPATH=.:$CLASSPATH:$JAVA_HOME/lib:$JAVA_HOME/jre/lib  export PATH=$PATH:$JAVA_HOME/bin:$JAVA_HOME/jre/bin

5.  source /etc/profile

6.  java -version   查看版本信息

 

7. cd  /root 

8. unzip glassfish-4.1.zip

9. useradd centos  groupadd centos

10. usermod -a -G centos centos

11. mkdir -p /decompress/glassfish

12. chown -R centos:centos /decompress/glassfish

13. cd /decompress/glassfish

14. mv  /root/glassfish4 /decompress/glassfish

15.  /decompress/glassfish/glassfish4/bin/asadmin start-domain

16.  cd /decompress/glassfish/glassfish4/bin

17. ./asadmin

18. /asadmin change-admin-password

    提示输入用户名: 直接按Enter(不要输入,否则会报错)

提示密码: 直接按Enter

输入新密码:[usrname]glassfish

确认密码:[usrname]glassfish

开启远程访问权限并退出glassfish用户

asadmin >enable-secure-admin

asadmin >exit

 

19.关闭服务并重启服务 

   vi /root/.bash_profile    加入以下4

   PATH=$PATH:$HOME/bin

export PATH

PATH=/decompress/glassfish/glassfish4/bin:$PATH

export PATH

加入以上4行,就可以用简短的命令启动:

asadmin stop-domain

asadmin start-domain 


20.   http://localhost:4848(localhost安装glassfish的服务器ip)

as-install  /glassfish4/glassfish  glassfish安装目录

as-install-parent /glassfish4   glassfish目录的父目录(除了galssfish默认还有其他的比如javadb)

domain-root-dir        as-install/domains/domain-dir    默认创建的domain1的位置

domain-dir          domain-root-dir/domain-name    domain1的各种配置目录

instance-dir         domain-dir/instance-name     domain1下面具体应用实例名 


21. 部署应用:1用命令部署:

    /decompress/glassfish/glassfish4/bin/asadmin deploy /root/hello.war   #入径

  登陆网页http://localhost:8080/hello

卸载应用hello.war

/decompress/glassfish/glassfish4/bin/asadmin undeploy hello

 

/decompress/glassfish/glassfish4/bin/asadmin deploy /root/cs.war   #入径


22. 部署应用:2通过控制台部署:

      http://localhost:4848

  


23  自动部署

可以把war包拷贝到自动部署文件夹autodeploy下面

cp sample-dir/hello.war as-install/domains/domain-dir/autodeploy

cp /root/hello.war /decompress/glassfish/glassfish4/glassfish/domains/domain1/autodeploy


24 卸载自动部署

cd as-install\domains\domain-dir\autodeploy

cd /decompress/glassfish/glassfish4/glassfish/domains/domain1/autodeploy
rm hello.war


25 启动javadb数据库(如果需要的话)

as-install/bin/asadmin start-database --dbhome as-install-parent/javadb

/decompress/glassfish/glassfish4/bin/asadmin start-database --dbhome /decompress/glassfish/glassfish4/javadb

停止javadb数据库

as-install/bin/asadmin stop-database

/decompress/glassfish/glassfish4/bin/asadminstop-database


26.端口号更改:

cd /decompress/glassfish/glassfish4/glassfish/domains/domain1/config/

vi domain.xml

将关于8080的端口改成你想要的端口号

 

glassfish域名配置:

1 yum安装httpdhttpd-devel

安装tomcat-connectors-1.2.40-src.tar.gz

tar -zxvf  tomcat-connectors-1.2.40-src.tar.gz

cd tomcat-connectors-1.2.40-src/native

./buildconf.sh

./configure --with-apxs=/etc/httpd/apxs

make

编译完成后就有mod_jk.so文件了,在

/root/tomcat-connectors-1.2.40-src/native/apache-2.0/mod_jk.so

   cp mod_jk.so /etc/httpd/modules

3修改httpd.conf

vi /etc/httpd/conf/httpd.conf

增加:

LoadModule jk_module   modules/mod_jk.so

<IfModule !mod_jk.c>

LoadModule jk_module  /etc/httpd/modules/mod_jk.so

</IfModule>

增加mod_jk参数和虚拟主机内容:

# Where to find workers.properties

JkWorkersFile   conf/workers.properties

# Where to put jk logs

JkLogFile    logs/mod_jk.log

# Set the jk log level [debug/error/info]

JkLogLevel    debug

# Select the log format

JkLogStampFormat "[%a %b %d %H:%M:%S %Y] "

# JkOptions indicate to send SSL KEY SIZE,

JkOptions     +ForwardKeySize +ForwardURICompat -ForwardDirectories

# JkRequestLogFormat set the request format

JkRequestLogFormat     "%w %V %T"

JkShmFile     logs/mod_jk.shm

 

NameVirtualHost *:80

<VirtualHost *:80>

ServerName   www.jolycare.com

# Send jsp,servlet for context * to worker named worker1

JkMount /* worker1

</VirtualHost>

4、新建workers.properties文件:

#cd /etc/httpd/conf/

#vi workers.properties

# Define 1 real worker using ajp13

worker.list=worker1

# Set properties for worker1 (ajp13)

worker.worker1.type=ajp13

worker.worker1.host=127.0.0.1

worker.worker1.port=8080

worker.worker1.lbfactor=1

worker.worker1.cachesize=512

worker.worker1.cache_timeout=600

worker.worker1.socket_keepalive=50

5登陆localhost:4848配置页面(服务器ip)

首先,点configurations-server-config-virtual servers在点new

 

在点save保存。

然后点configurations-server-config-Network config -network listeners 在点http listener-1

 

JK Listener: enabled 打勾在点保存

 

 

 

 

最后测试,在浏览器输入:http://www.xxx.com/可以访问(此处你注册的域名)