Activities

March 2008
M T W T F S S
    May »
 12
3456789
10111213141516
17181920212223
24252627282930
31  

Depolying Java application using Apache +Tomcat

Apache is very useful for deploying most of the applications. It is easy to configure multiple java applications over a single Apache server using it as a proxy server. Actually Apache will bypass the all the request to tomcat server.Here is the documentation.

There are 3 way to run java application using Apache

1, Using apache proxy server
2, using apache (mod_jk module) AJP connector
3, Running Tomcat itself a primary Web server

For the beginners and a easy way

We recommend to use the first step using apache as proxy server for tomcat
before doing this you have to verify the following things
a,Tomcat is running on the server
$ nestat -nlp |grep “8080”
if there is any entry there it’s okay
take a copy of apache.conf or http.conf file from apache installation directory
#cp http.conf httpd.conf.bk
b,Comment out the Namevirtusl host in httpd.conf file
Eg: NameVirtualHost *:80

c,Uncomment the following module from apache for working apache proxy server.Always make

1, mod_proxy.so

2, mod_proxy_connect.so

3, mod_proxy_http.so

Eg: LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_connect_module /usr/lib/apache2/modules/mod_proxy_connect.so
LoadModule proxy_http_module /usr/lib/apache2/modules/mod_proxy_http.so

d,Create a file named nanowebtech.conf inside the apache conf.d folder (/etc/httpd/conf.d)

<VirtualHost *:80>
ServerName myjavasite.com
ServerAlias www.myjavasite.com
ProxyPass / http://localhost:8080/project1/
ProxyPassReverse / http://localhost:8080/project1/
ProxyPreserveHost on
</VirtualHost>

save it and restart the apache
#/etc/init.d/httpd restart or service httpd restart

e, Browse the site(http://myjavasite.com) and then you can see that site index page is listed there without specifying any port.

You have successfully complete the java application deployment.

################ Another Method ###########

Here’s what you can do if you want to run Confluence and Jira on a single Tomcat instance behind an Apache server and you want to make them available at addresses like confluence.notatlassian.com and jira.notatlassian.com.

1. Set up virtual hosts in Apache:

<VirtualHost xxx.xxx.xxx.xxx>
ServerName confluence.notatlassian.com
ProxyPass / http://confluence.notatlassian.com:8080/
ProxyPassReverse / http://confluence.notatlassian.com:8080/
</VirtualHost>

Note the use of confluence.notatlassian.com in the ProxyPass directives; if you use localhost, Tomcat won’t be able to choose the correct virtual host.

2. Set up virtual hosts in Tomcat:
add this to $TOMCAT/conf/server.xml in the <Engine> section

<Host name=”confluence.notatlassian.com” appBase=”confluence”
unpackWARs=”true” autoDeploy=”true”
xmlValidation=”false” xmlNamespaceAware=”false”>
<Context path=”” docBase=”” debug=”0″/>
</Host>

Note: if your site requires an SSL then we need to configure apache for doing that not tomcat

Leave a Reply

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>