Labels

Saturday, June 16, 2012

Configuring Apache for JBoss

Supported Platforms

Apache for JBoss Prerequisites

1. JBoss 6 server configured for App & running on port 8080

2. Latest version of Apache 2.2 including OpenSSL should be downloaded from following link http://httpd.apache.org/download.cgi
Note: Download appropriate version suitable for your operating system.

3. Download mod_jk2.so file from apache sites mentioned below & place it in D:\Apache2.2\modules

a. http://www.apache.org/dist/tomcat/tomcat-connectors/jk/binaries/

b. http://tomcat.apache.org/connectors-doc/

4. (Optional) Valid SSL certificate files available for your server in case you want to enable HTTPS.
e.g. App.cert & App.key file (file name differs as per your configuration)

Note: Please refer online installation guide for installing Apache2.2 on Linux / Unix. http://httpd.apache.org/docs/2.2/install.html


Installing Apache using MSI Installer in windows.

1. Execute httpd-2.2.20-win32-x86-openssl-0.9.8r.msi.

2. Click Next, Select “I Accept…” and click Next.
clip_image002[4] clip_image004[4]

3. Click Next, Enter Domain Name, Server Name & Support Email Address, Select “for All Users,..” option and then click Next.
clip_image006[4] clip_image008[4]

4. Select Custom & click Next, Open Dropdown next to “Apache HTTP Server 2.2.10” & Select “This Feature, and all subfeatures, will be installed on local Hard drive”, Click Change.
clip_image010[4] clip_image012[4]

5. Change the Path of Apache install directory to non system drive, Click OK, Click Next.
clip_image014[4] clip_image016[4]

6. Click Install,
clip_image018[4] clip_image020[4]

7. Click yes/allow for any security or firewall alerts that may popup.
clip_image022[4] clip_image024[4]

8. Click Finish on the “Installation Wizard Completed” Window.


Configuring apache for JBoss on http with Compression.

By Default Apache starts listening on port 80

1. Open file httpd.conf in editor & add following content after line “<IfModule !mpm_winnt_module>”

   1: ######## APP JBoss START ######### 
   2:  
   3: #Include conf/mod_jk/mod-jk.conf 
   4:  
   5: <IfModule worker.c> 
   6:  
   7: Startservers 6 
   8:  
   9: MAxClients 150 
  10:  
  11: MinSpareThreads 25 
  12:  
  13: MaxSpareThreads 75 
  14:  
  15: ThreadsPerChild 25 
  16:  
  17: MaxRequestsPerChild 0 
  18:  
  19: </IfModule> 
  20:  
  21: LoadModule jk_module modules/mod_jk2.so 
  22:  
  23: JkWorkersFile conf/mod_jk/workers.properties 
  24:  
  25: JkLogFile logs/mod_jk_error.log 
  26:  
  27: JkLogLevel error 
  28:  
  29: JkLogStampFormat "[%a %b %d %H:%M:%S %Y]" 
  30:  
  31: JkRequestLogFormat "%w %V %T" 
  32:  
  33: # JBoss site Start # 
  34:  
  35: <VirtualHost *:80> 
  36:  
  37: ServerAdmin support@JBoss.com 
  38:  
  39: ErrorLog "|bin/rotatelogs logs/App_error.%d.%m.%Y.log 10M" 
  40:  
  41: customLog "|bin/rotatelogs logs/App_Access.%d.%m.%Y.log 10M" common 
  42:  
  43: JkMount /* loadbalancer 
  44:  
  45: LoadModule deflate_module modules/mod_deflate.so 
  46:  
  47: SetOutputFilter DEFLATE 
  48:  
  49: SetInputFilter DEFLATE 
  50:  
  51: AddOutputFilterByType DEFLATE text/html text/plain text/xml text/x-js text/css application/x-javascript 
  52:  
  53: AddInputFilter DEFLATE text/html text/plain text/xml text/x-js text/css application/x-javascript 
  54:  
  55: SetEnvIfNoCase Request_URI \.(?:gif|jpe?g|png)$ no-gzip dont-vary 
  56:  
  57: SetEnvIfNoCase Request_URI \.(?:pdf|exe|zip)$ no-gzip dont-vary 
  58:  
  59: #SetEnvIfNoCase Request_URI \.(?:css|js)$ no-gzip dont-vary 
  60:  
  61: DeflateFilterNote Input instream 
  62:  
  63: DeflateFilterNote Output outstream 
  64:  
  65: DeflateFilterNote Ratio ratio 
  66:  
  67: LogFormat '%{outstream}n/%{instream}n (%{ratio}n%%) :- "%r"' App_small_deflate 
  68:  
  69: CustomLog "|bin/rotatelogs logs/App_small_deflate.%d.%m.%Y.log 10M" App_small_deflate 
  70:  
  71: <FilesMatch "\.(ico|jpg|jpeg|png|gif|js|css|swf)$"> 
  72:  
  73: Header set Cache-Control "public" 
  74:  
  75: Header set Expires "Thu, 31 Mar 2015 20:00:00 GMT" 
  76:  
  77: </FilesMatch> 
  78:  
  79: </VirtualHost> 
  80:  
  81: ######## APP JBoss STOP #########

2. Create folder with name mod_jk in D:\Apache2.2\conf & create following file with name workers.properties with the code mentioned below.


workers.properties



   1: #Define list of workers that will be used 
   2:  
   3: # for mapping requests 
   4:  
   5: worker.list=loadbalancer,App,status 
   6:  
   7: # Define App 
   8:  
   9: # modify the host as your host IP or DNS name. 
  10:  
  11: worker.App.port=8009 
  12:  
  13: worker.App.host=localhost 
  14:  
  15: worker.App.type=ajp13 
  16:  
  17: worker.App.lbfactor=1 
  18:  
  19: worker.App.local_worker=1 (1) 
  20:  
  21: worker.App.cachesize=100 
  22:  
  23: # # Load-balancing behaviour 
  24:  
  25: worker.loadbalancer.type=lb 
  26:  
  27: worker.loadbalancer.balance_workers=App 
  28:  
  29: worker.loadbalancer.sticky_session=1 
  30:  
  31: worker.loadbalancer.local_worker_only=1 
  32:  
  33: worker.list=loadbalancer 
  34:  
  35: # Status worker for managing load balancer 
  36:  
  37: worker.status.type=status

3. Download mod_jk2.so file from apache site & place it in D:\Apache2.2\modules.

4. Open a command Prompt, Run as administrator if required, and type commands in following sequence.

a. Change directory to Apache executable.


   1: cd Apache2.2\bin 

b. Test the syntax in configuration files


   1: httpd.exe –t

c. Stop service


   1: httpd.exe -k stop

d. Start service


   1: httpd.exe -k start

e. Make sure that there is no errors in the output of these commands
clip_image026[4]

f. Refer the screenshot above for desired outputs.

5. Incase if you get any popup like given below then click “Allow access” after checking all Networks.
clip_image027

6. Configuration completed at this stage;

7. Try accessing your server using port 80.

8. In case of any error, please refer the apache2.2\log folder for further diagnostics.






No comments:

Post a Comment