Skip to content

Instantly share code, notes, and snippets.

@Abukamel
Created July 27, 2015 08:13
Show Gist options
  • Save Abukamel/084f4882825f6b704c97 to your computer and use it in GitHub Desktop.
Save Abukamel/084f4882825f6b704c97 to your computer and use it in GitHub Desktop.
install and confiugre glassfish version 3.1.2 and serve it via apache 2.4 server in front of glass fish ones using mod_jk
  • glassfish_server:

    • hostname: gf.localdomain
    • ip: 192.168.1.200
  • apache_server:

    • hostname: web.localdomain
    • ip: 192.168.1.100
  • @glassfish_server: 0. packages that needs to be installed: yum -y install wget unzip epel-release vim

    1. make sure that epel repo is installed: yum -y install epel-release
    2. install openjdk-6: yum -y install java-1.6.0-openjdk java-1.6.0-openjdk-devel
    3. download glassfish 3.1.2: cd /opt && wget http://download.java.net/glassfish/3.1.2/release/glassfish-3.1.2.zip
    4. make sure that unzip command is installed: yum -y install unzip
    5. extract glassfish zip file at /opt dir: cd /opt && unzip glassfish-3.1.2.zip
    6. start glassfish domain: /opt/glassfish3/glassfish/bin/asadmin start-domain
    7. create an HTTP listeren on port 8009 and enable jk on it requires 2 commands:
    • /opt/glassfish3/glassfish/bin/asadmin create-http-listener --listenerport 8009 --listeneraddress 192.168.1.200 --defaultvs server jk-connector
      • note: 192.168.1.200 is my glassfish server public ip
    • /opt/glassfish3/glassfish/bin/asadmin set configs.config.server-config.net work-config.network-listeners.network-listener.jk-connector.jk-enabled=true
    1. restart glassfish domain: /opt/glassfish3/glassfish/bin/asadmin restart-domain
    2. use netstat command and make sure that java is listening on public ip and port 8009 like the picture: http://i.imgur.com/6CAuGJd.jpg
    3. now we jump to web server and apache, mod_jk configurations

  • @apache_server: 0. packages that needs to be installed: yum -y install wget unzip epel-release vim telnet gcc
    1. install telnet and make sure that web server is able to talk to port 8009 on GF server:
    1. make sure that epel repo is installed: yum -y install epel-release
    2. install apache 2.4 repo: cd /etc/yum.repos.d/ && wget http://repos.fedorapeople.org/repos/jkaluza/httpd24/epel-httpd24.repo
    3. install apache 2.4 and apache 2.4 devel packages: yum install httpd24 httpd24-httpd-devel
    4. source the enable file to let the system recognize httpd24 binaries: source /opt/rh/httpd24/enable
    5. download mod_jk: cd /usr/local/src && wget http://mirror.tcpdiag.net/apache/tomcat/tomcat-connectors/jk/tomcat-connectors-1.2.40-src.tar.gz
    6. extract downloaded mod_jk file: tar xvf tomcat-connectors-*
    7. remove source file: rm -f /usr/local/src/tomcat-connectors*.tar.gz
    8. install mod_jk: cd /usr/local/src/tomcat*/native && ./configure --with-apxs=/opt/rh/httpd24/root/usr/bin/apxs && make && make install
    9. create a module config file /opt/rh/httpd24/root/etc/httpd/conf.modules.d/00-modjk.conf then open it and paste the following content and save
    LoadModule jk_module /opt/rh/httpd24/root/usr/lib64/httpd/modules/mod_jk.so
    JkWorkersFile /opt/rh/httpd24/root/etc/httpd/conf/workers.properties
    JkLogFile     /opt/rh/httpd24/root/var/log/httpd/mod_jk_log
    JkLogLevel    info
    
    1. create a worker.properties file /opt/rh/httpd24/root/etc/httpd/conf/workers.properties then open it and paste the following content and save
    worker.list=worker1
    worker.worker1.type=ajp13
    worker.worker1.port=8009
    worker.worker1.host=gf.localdomain
    worker.worker1.lbfactor=1
    
    • note: worker.worker1.host should equal the GF server ip or hostname gf.localdomain in our case.
    1. add virtualhost file /opt/rh/httpd24/root/etc/httpd/conf.d/gf.conf for glassfish and paste the following content into it and save
    <VirtualHost *:80>
    ServerName web.localdomain
    JkMount /* worker1
    </VirtualHost>
    
    1. start apache web server: /opt/rh/httpd24/root/usr/sbin/apachectl -k start
    2. make sure that your /etc/hosts file is able to resolve web.localdomain and the try with your browser and you should see this result: http://i.imgur.com/hejQTsh.jpg
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment