RSS

Tomcat6 to apache2 configuration in ubuntu

22 Aug

Step 1:

Install libapache2-mod-jk in your machine

sudo apt-get install libapache2-mod-jk

sudo service apache2 restart

a2enmod jk

Step 2:

copy your workers.properties file and past in

/etc/apache2

Example:

workers.properties file content below

# Define worker ‘example’
worker.list=application-name

# Set properties for worker ‘example’ (ajp13)
worker.application-name.type=ajp13
worker.application-name.host=localhost
worker.application-name.port=8009

worker.application-name.cachesize=10
worker.application-name.cache_timeout=600
worker.application-name.socket_keepalive=1
worker.application-name.recycle_timeout=300

your need to change your application-name in working property.

Step 3:

create jk.load

/etc/apache2/mods-enabled/jk.load

Example:

jk.load file content

LoadModule jk_module /usr/lib/apache2/modules/mod_jk.so
JkWorkersFile   /etc/apache2/workers.properties
JkLogFile       /var/log/apache2/mod_jk.log
JkLogLevel      info
JkOptions +ForwardKeySize +ForwardURICompat -ForwardDirectories -ForwardLocalAddress
JkRequestLogFormat “%w %V %T”
JkMount /xContext/* ajp

change in content:

/etc/apache2/workers.properties —> workers.properties you created above.

Step 4:

create filename.conf in

/etc/apache2/sites-available/filename.conf

Example:

filename.conf content

<VirtualHost *:80>
ServerName http://localhost
DocumentRoot “/home/user-name/apache-tomcat-6.0.32/webapps/ROOT”
<Directory “/home/user-name/apache-tomcat-6.0.32/webapps/ROOT”>
# Options Indexes FollowSymLinks MultiViews
Options None
AllowOverride None
Order allow,deny
allow from all
</Directory>

# Send ROOT app. to worker named app1
JkMount  /* application-name
JkUnMount  /images/* application-name

</VirtualHost>

changes in content :

ServerName http://localhost   ——–>host name that you have mentioned
  DocumentRoot “/home/ideas2it/apache-tomcat-6.0.32/webapps/ROOT”  ——–> your apache path ROOT
<Directory “/home/ideas2it/apache-tomcat-6.0.32/webapps/ROOT”>  ———> your apache path ROOT

JkMount  /* application-name  ——> your application name same like workers.properties
JkUnMount  /images/* application-name –>your application name same like workers.properties

Step 5:

cd /etc/apache2/mods-enabled

ln -s /etc/apache2/sites-available/filename.conf .

sudo service apache2 restart

Setp 6:

Just confirm default file in

/etc/apache2/sites-available

If it is not there please create file default

Example:

Default file content

<VirtualHost *:80>

ServerAdmin webmaster@localhost

DocumentRoot /var/www
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>

ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory “/usr/lib/cgi-bin”>
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>

ErrorLog ${APACHE_LOG_DIR}/error.log

# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn

CustomLog ${APACHE_LOG_DIR}/access.log combined

Alias /doc/ “/usr/share/doc/”
<Directory “/usr/share/doc/”>
Options Indexes MultiViews FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
Allow from 127.0.0.0/255.0.0.0 ::1/128
</Directory>

</VirtualHost>

Restart apache2.

Go and type http://localhost/ in your browser.

Your application will run perfectly.

 
1 Comment

Posted by on August 22, 2011 in Apache, Ubuntu

 

One response to “Tomcat6 to apache2 configuration in ubuntu

  1. Loganathan N

    August 3, 2012 at 2:45 pm

    its worked for me ..nice
    thanks🙂

    while starting server 1 error occur:
    Syntax error on line 6 of /etc/apache2/mods-enabled/jk.load:
    JkRequestLogFormat takes one argument, The mod_jk module request log format string

    After Commenting this line #JkRequestLogFormat “%w %V %T” in jk.load it’s worked nice🙂

     

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: