This "tutorial" is for Ubuntu 10.04 LTS (Lucid).
This is how you would set up Tomcat6 behind Apache2 via mod_jk
I am assuming that you have apache2 installed and tomcat6 installed. I also assume you have deployed and can find your tomcat app possibly on port 8080 of your linode.
This is how you would set up Tomcat6 behind Apache2 via mod_jk
I am assuming that you have apache2 installed and tomcat6 installed. I also assume you have deployed and can find your tomcat app possibly on port 8080 of your linode.
- Install mod_jk:
apt-get install libapache2-mod-jk
- Create workers.properties in /etc/apache2/ and add the following into it:
# this lives in /etc/apache2/workers.properties # workers.properties - ajp13 # # List workers worker.list=worker1 # Define worker1 worker.worker1.port=8009 worker.worker1.host=localhost worker.worker1.type=ajp13
- Edit your apache2 config in /etc/apache2/apache2.conf and add this to the end:
# tomcat connector stuff: JkWorkersFile /etc/apache2/workers.properties # Where to put jk shared memory JkShmFile /var/log/apache2/mod_jk.shm # Where to put jk logs JkLogFile /var/log/apache2/mod_jk.log # Set the jk log level [debug/error/info] JkLogLevel info # Select the timestamp log format JkLogStampFormat "[%a %b %d %H:%M:%S %Y]
- In your /etc/apache2/sites-enabled/ dir find the vhost you want to use tomcat and edit it, at the end of the vhost declaration put:
#Everything under root goes to tomcat JkMount /* worker1 #html files should be served by apache2 JkUnMount /*.html worker1
- Edit /etc/tomcat6/server.xml and make sure that the ajp connector is uncommented:
<connector port="8009" protocol="AJP/1.3" redirectport="8443" />
- restart tomcat: /etc/init.d/tomcat6 restart
- restart apache: /etc/init.d/apache2 restart
- navigate to yourdomain.com/ and you should be all tomcatted
Much appreciated! Very helpful!
ReplyDeleteIndeed...very helpful and succint..cheers!!
ReplyDeleteThanks! Very helpful, simple and straightforward!
ReplyDeleteI have just installed mod_jk on my Apacahe Tomcat server, thank you guidance on this install.
ReplyDeleteVery Helpful, This is exactly what I was looking for.
ReplyDeleteBut how can I make only redirect a VirtualHost and not all requests to Apache to Tomcat
getting error
ReplyDeleteInvalid command 'JkWorkersFile', perhaps misspelled or defined by a module not included in the server configuration
Action 'configtest' failed.
The Apache error log may have more information.
...fail!
* This error drove me crazy!!!
ReplyDeleteSyntax error on line 9 of /etc/apache2/httpd.conf:
JkWorkersFile only allowed once
Action 'configtest' failed.
The Apache error log may have more information.
...fail!
*To solve this,
$ sudo vim /etc/apache2/mods-enabled/jk.conf
# JkWorkersFile /etc/libapache2-mod-jk/workers.properties
Thank very much !
ReplyDeleteThank you very much ! Appreciated..
ReplyDeleteThanks a lot. Quick Google > Found this article > Problem solved
ReplyDelete