error starting apache 2.4 with mod_jk - apache

For reference I used this guide to setup integration between tomcat 7 and apache 2.4, with the mod_jk. https://www3.ntu.edu.sg/home/ehchua/programming/howto/ApachePlusTomcat_HowTo.html
When opening cmd in windows and doing a: c:\Apache24\bin> httpd -k start I get the follow error
httpd: Syntax error on line 526 of C:/Apache24/conf/httpd.conf: Syntax error on line 1 of C:/Apache24/conf/mod_jk.conf: Cannot load modules/mod_jk.so into server: access denied.
Below is the two files which has syntax errors.
mod_jk.config
LoadModule jk_module modules/mod_jk.so
JkWorkersFile C:/Program Files/Apache Software Foundation/Tomcat
7.0/conf/workers.properties
JkLogFile C:/Program Files/Apache Software Foundation/Tomcat 7.0/logs
JkLogLevel info
JkOptions +ForwardkeySize +ForwardURICompat +ForwardDirectories
JkRequestLogFormat "%w %V %T"
JkMount /rehavoc ajp13 jkMount /rehavoc/* ajp13
httpd.config
include C:/Apache24/conf/mod_jk.conf
Tomcat 7 is properly setup(I hope) Since I can in tomcat manager, deploy a war file with a test servlet running and see it work on the localhost/url.
Apache 2.4 should also be working seeing my web site is live and can be accessed on the web(just a simple hello world html).
Operating system is vista.
Also, have I understood correctly that with these three 'services' will I be able to deploy a war file into apache htdocs, including jsp/servlets and it will have no trouble running on my site?
Any help is appreciated.

Solved it by not using apache 2.4 and mod_jk. Were better to just use tomcat 7 alone from the start.

Related

Tomcat load-balancing with mod_jk

Newbie to this technology hence pls be gentle. Aim is to setup Tomcat load-balancing with mod_jk.
My setup is below (all on one machine):
Win7 x64
Apache Httpd 2.2
Tomcat 6
mod_jk 1.2.37 (for httpd2.2.x)
2 Tomcat instances (same machine)
I've setup Tomcat correctly and can access the webapps via localhost:8080 and localhost:8081.
But when I try to access the webapps via Httpd (localhost/dept1 or localhost/dept2), I get "404 Not Found " The requested URL /dept1 was not found on this server.
Httpd works when accessed by URL, http: //localhost "It works!"
The only lines added to httpd.conf (Apache2.2) are:
LoadModule jk_module modules/mod_jk.so
JkWorkersFile C:/ApacheHTTPD/conf/workers.properties
JkLogFile C:/ApacheHTTPD/logs/mod_jk.log
JkLogLevel emerg
JkLogStampFormat "[%a %b %d %H:%M:%S %Y]"
JkOptions +ForwardKeySize +ForwardURICompat +ForwardDirectories
JkRequestLogFormat "%w %V %T %p %q %r %v %U"
JkMount /%CATALINA_HOME%/webapps/dept1/* tomcatbase
JkMount /%CATALINA_HOME2%/webapps/dept2/* tomcat1
workers.properties file contains:
worker.list=tomcatbase,tomcat1
worker.tomcatbase.type=ajp13
worker.tomcatbase.host=localhost
worker.tomcatbase.port=8009
worker.tomcat1.type=ajp13
worker.tomcat1.host=localhost
worker.tomcat1.port=8010
All other setup is (Apache and the 2 Tomcat instances) are default.
Now, http:// localhost:8080/dept1 works. So is it that the redirect from Apache to Tomcat isn't working?
Thanks in advance
Bharath
Try this:
JkMount /dept1/* tomcatbase
JkMount /dept2/* tomcat1
The first parameter of the JkMount directive is a URL prefix, not a local path.
JkMount [URL prefix] [Worker name]
Please see http://tomcat.apache.org/connectors-doc/webserver_howto/apache.html for more details.

apache tomcat connector - website configuration

I have deployed website serving traffic from apache which get pages from tomcat. i have configured mod_jk connector and everything is working fine.
say for example my website url is http://<mywebsite.com>
my tomcat deployed application app name test app
Problem is im only able to browse the site when i browse http://<mywebsite.com>/testapp but i want apache to serve pages when i browse just my website http://<mywebsite.com> and it is not happening at the moment. below is my apache httpd.conf file and testapp is my deployed application name on tomcat.
JkWorkersFile conf/workers.properties
JkLogFile logs/mod_jk.log
JkLogStampFormat "[%b %d %Y - %H:%M:%S] "
JkRequestLogFormat "%w %V %T"
JkLogLevel info
JkOptions +ForwardKeySize +ForwardURICompat -ForwardDirectories
Alias /testapp "C:/Items/Installation Directories/Tomcat7.0/webapps/awardio/"
<Directory "C:/Items/Installation Directories/Tomcat7.0/webapps/awardio/">
AllowOverride None
Allow from all
</Directory>
<Location /*/WEB-INF/*>
deny from all
</Location>
JkMount /testapp/* myworker
do i need to mod_rewrite or something or configure virtual host.
it is fairly urgent so appreciate your help?
my tomcat deployed application app name test app
You need to change the deployed app name to ROOT. So you can just rename the war file to ROOT.war

Not able to configure mod_JK in HTTPD.CONF file for load balancing

I am not able to configure the apache load balancer with mod_jk. Each time I channge httpd.conf file apache server doesnot start.
Here is the scenario:
I have 2 apache tomcat instance, Tomcat and tomcat2 and both are running on different ports.
I would like to establish a load balancer for these two instances with apache mod_jk:
I have downloded mod_jk.so file and places in modules folder.
Below configuration I am trying to httpd.conf file:
LoadModule jk_module modules/mod_jk.so
AddModule mod_jk.c
JkWorkersFile conf/workers.properties
JkLogFile log/httpd/mod_jk.log
JkLogLevel info
mod_jk loadbalancer
JkMount /examples/* loadbalancer
Here is my workers.propertise file:
# Define list of workers that will be used
worker.list=loadbalancer
# Define Node1
worker.node1.port=8009
worker.node1.host=localhost
worker.node1.type=ajp13
worker.node1.lbfactor=1
worker.node1.cachesize=10
# Define Node2
worker.node2.port=8010
worker.node2.host=localhost
worker.node2.type=ajp13
worker.node2.lbfactor=1
worker.node2.cachesize=10
# Load-balancing behaviour
worker.loadbalancer.type=lb
worker.loadbalancer.balance_workers=node1,node2
worker.loadbalancer.sticky_session=1
# Status worker for managing load balancer
worker.status.type=status
I am not sure, what is wrong here. May be I am adding the mod_jk conf in httpd.conf file at wrong place.
Can anybody guide. Any sample working HTTPD.CONF file will be great.
Thanks you for the help.
-Santosh
Issue resolve:
I was using the mod_jk.so file compatible with apache version 2.0 and Apache webserver 2.2.
I have downloaded the mod_jk.so file compatible for 2.2 version and now everything is working fine.
You can check detailed error by option:
c:/your_apache_dir/bin> httpd.exe -D mod_jk
Thanks for your help.
JkWorkersFile "conf/workers.properties" this should be this way and also do check for the mod_jk compatibility.

Spring Session Replication Problem

I've currently researching in load balancing my Spring project. I've used Apache web server as front-end to multiple Tomcat instances. I've used mod_jk for the load balancing. When I run it, if I shutdown one server, i had to login again to the system. Previously I also tried it in simpler example with the Tomcat's session example program and the session replication worked fine.
This is my configuration for the Apache's httpd.conf mod_jk part:
LoadModule jk_module modules/mod_jk.so
JkWorkersFile conf/workers.properties
JkLogFile logs/jk.log
JkLogLevel debug
JkLogLevel info
JkLogStampFormat "[%a %b %d %H:%M:%S %Y]"
JkOptions +ForwardKeySize +ForwardURICompat -ForwardDirectories
JkRequestLogFormat "%w %V %T"
JkMount /test balancer <-- this is the spring program
JkMount /test/* balancer <-- this is the spring program
JkMount /jk_status status`
And this is my workers.properties setting:
workers.tomcat_home=/worker1
workers.java_home=$JAVA_HOME
ps=/
worker.list=balancer,status
worker.worker1.port=8009
worker.worker1.host=localhost
worker.worker1.type=ajp13
worker.worker1.lbfactor=1
worker.worker2.port=8109
worker.worker2.host=localhost
worker.worker2.type=ajp13
worker.worker2.lbfactor=1
worker.balancer.type=lb
worker.balancer.balance_workers=worker1,worker2
worker.balancer.method=B
worker.balancer.sticky_session=1
worker.status.type=status
And I've put a sample of one of my tomcat's server.xml here: http://pastebin.com/0j0ta2WA
I've also added <distributable/> tag to my application's web.xml. Is there something I missed here that made the session replication not working?
Tomcat 5.5
Apache 2.2
mod_jk
Spring 2.5.6
JDK 1.6.0_01
Do you have a jvmRoute defined in your server.xml?
Here are the docs:
http://tomcat.apache.org/tomcat-5.5-doc/config/engine.html
I would have looked at your server.xml but the link is wrong.

Apache httpd 2.2.x + mod_jk 1.2.30 + tomcat 6 Error: Could not find worker with name 'XXXXX' in uri map post processing

I am getting the following error while setting up the load balancer with two Tomcat instances:
[info] mod_jk.c (3189): mod_jk/1.2.30 initialized
[error] jk_uri_worker_map.c (506): Could not find worker with name 'loadmanager' in uri map post processing.
Following are my configuration settings:
httpd.conf changes
# Include mod_jk configuration file
Include conf/mod_jk.conf
mod_jk.conf
LoadModule jk_module modules/mod_jk.so
JkWorkersFile conf/workers.properties
JkLogFile logs/mod_jk.log
JkLogLevel info
JkLogStampFormat "[%a %b %d %H:%M:%S %Y]"
JkOptions +ForwardKeySize +ForwardURICompat -ForwardDirectories
JkRequestLogFormat "%w %V %T"
JkMount /TestLB1/ loadmanager
JkMount /TestLB1/* loadmanager
JkShmFile logs/jk.shm
workers.properties
worker.list=loadmanager
worker.tomcat1.port=18081
worker.tomcat1.host=localhost
worker.tomcat1.type=ajp13
worker.tomcat1.lbfactor=1
worker.tomcat2.port=28081
worker.tomcat2.host=localhost
worker.tomcat2.type=ajp13
worker.tomcat2.lbfactor=1
worker.loadmanager.type=lb
worker.loadmanager.balance_workers=tomcat1,tomcat2
worker.loadmanager.sticky_session=True
In Tomcat's server.xml I have set the jvmRoute attribute to Engine also
<Engine defaultHost="localhost" name="Catalina" jvmRoute="tomcat1">
<Engine defaultHost="localhost" name="Catalina" jvmRoute="tomcat2">
Both the Tomcat instances are up and running fine with AJP ports 18081 & 28081 respectively.
But while starting the Apache httpd.exe the mod_jk log files always shows the above error, and when I try to access my web app through http://localhost/TestLB1 nothing comes up.
Any Solution?
Got the problem....
Issues is with the text editor in which i was editing my worker.properties file , it adds few special chars to files.
I found them when i opend the files in notepad only.
After removing all unwanted chars everythings works perfect.
Create your worker.properties file with a good text editor like notepad++. Not doing so may add some unseen special characters and workers.properties file wont parse by mod_jk.