-
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
- make sure that epel repo is installed:
yum -y install epel-release
- install openjdk-6:
yum -y install java-1.6.0-openjdk java-1.6.0-openjdk-devel
- download glassfish 3.1.2:
cd /opt && wget http://download.java.net/glassfish/3.1.2/release/glassfish-3.1.2.zip
- make sure that unzip command is installed:
yum -y install unzip
- extract glassfish zip file at /opt dir:
cd /opt && unzip glassfish-3.1.2.zip
- start glassfish domain:
/opt/glassfish3/glassfish/bin/asadmin start-domain
- 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
- restart glassfish domain:
/opt/glassfish3/glassfish/bin/asadmin restart-domain
- 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
- now we jump to web server and apache, mod_jk configurations
- make sure that epel repo is installed:
- @apache_server:
0. packages that needs to be installed:
yum -y install wget unzip epel-release vim telnet gcc
- install telnet and make sure that web server is able to talk to port 8009 on GF server:
yum -y install telnet
telnet 192.168.1.200 8009
- you should see a picture like this: http://i.imgur.com/15OFplr.jpg
- make sure that epel repo is installed:
yum -y install epel-release
- install apache 2.4 repo:
cd /etc/yum.repos.d/ && wget http://repos.fedorapeople.org/repos/jkaluza/httpd24/epel-httpd24.repo
- install apache 2.4 and apache 2.4 devel packages:
yum install httpd24 httpd24-httpd-devel
- source the enable file to let the system recognize httpd24 binaries:
source /opt/rh/httpd24/enable
- 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
- extract downloaded mod_jk file:
tar xvf tomcat-connectors-*
- remove source file:
rm -f /usr/local/src/tomcat-connectors*.tar.gz
- install mod_jk:
cd /usr/local/src/tomcat*/native && ./configure --with-apxs=/opt/rh/httpd24/root/usr/bin/apxs && make && make install
- 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
- 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.
- 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>
- start apache web server:
/opt/rh/httpd24/root/usr/sbin/apachectl -k start
- 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