Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Apache 2.0 & Tomcat 5.0

Status
Not open for further replies.

tlaurent

Technical User
Oct 2, 2005
6
US
I set up my application with apache 2.0 in front-end and tomcat 5.0 in back-end. Everything works fine except when I try to open my web application from " I can only open static pages. When I type " I would like apache to forward the URL to Tomcat and open the page index.jsp of my application. I tried everything I knew to solve the problem but it still doesn't work. For the moment I am using a static page with apache and I wrote a javascript srcipt to forward to my index.jsp. I don't think this is real professionnal. Any help will be welcome. I went on the web to find some solutions but the only thing I found was to create virtual host with static pages or open a jsp or servlet when you type the URL and I already know how to do that. What I would like to do is when you type " open my web site on with index.jsp through apache 2.0 with tomcat 5.0 without using any static pages. Any ideas?(I am running my own web site on server linux)
 
I have already tryed everything, but is still doesn't work. The only thing I got is the $CATALINA_HOME/webapps/ROOT/index.jsp page from jakarta tomcat 5.5.9 as a default page instead of having my web application. This is a copy of my settings on apache 2.0:

# httpd.conf

# mywebapps add
# Mod_jk settings

JkWorkersFile "/etc/httpd/conf/workers.properties"
JkLogFile "/etc/httpd/logs/mod_jk.log"
JkLogLevel info
JkLogStampFormat "[%a %b %d %H:%M:%S %Y] "

JkMount /mywebapps default
JkMount /mywebapps/* default
# End of mod_jk settings

................


<VirtualHost *:80>

ServerAdmin admin@mywebapps.com
ServerName DocumentRoot /opt/jakarta-tomcat-5.5.9/webapps/mywebapps
ErrorLog /opt/jakarta-tomcat-5.5.9/logs/error_log
CustomLog /opt/jakarta-tomcat-5.5.9/logs/access_log common


JkMount /*.do default
JkMount /*.jsp default
JkMount /servlet/* default

# Deny direct access to WEB-INF
<Directory ".*WEB-INF.*">
Options None
Deny from all
</Directory>

</VirtualHost>


How should I change my settings to open my application in /mywebapps/index.js when I type the URL instead of the tomcat main page? Please I am stuck with this problem. Do I have to change anything on my tomcat? if yes, what should I do? I already do evrything but still have the same problem.
 
This may be a silly question...but since you didn't explicitly detail it in your httpd.conf notes. Have you put the LoadModule config line httpd.conf:

LoadModule jk_module modules/mod_jk.so
 
Yes I did! Sorry I didn't put everything just the essential
and my modifications.I still have the same problems.


# httpd.conf

DirectoryIndex index.html index.jsp index.html.var
..................................

#mywebapps add
LoadModule jk_module modules/mod_jk.so
################

...................

# mywebapps add
# Mod_jk settings

JkWorkersFile "/etc/httpd/conf/workers.properties"
JkLogFile "/etc/httpd/logs/mod_jk.log"
JkLogLevel info
JkLogStampFormat "[%a %b %d %H:%M:%S %Y] "

JkMount /mywebapps default
JkMount /mywebapps/* default
# End of mod_jk settings

................


<VirtualHost *:80>

ServerAdmin admin@mywebapps.com
ServerName DocumentRoot /opt/jakarta-tomcat-5.5.9/webapps/mywebapps
ErrorLog /opt/jakarta-tomcat-5.5.9/logs/error_log
CustomLog /opt/jakarta-tomcat-5.5.9/logs/access_log common


JkMount /*.do default
JkMount /*.jsp default
JkMount /servlet/* default

# Deny direct access to WEB-INF
<Directory ".*WEB-INF.*">
Options None
Deny from all
</Directory>

</VirtualHost>
 
I thought I might be able to help, because I thought I was successfully doing this on my server. Turns out that I had forgotten that along the way...due to config problems of my own, I ended up running my app on a standalone tomcat server install - so I don't actually know for sure if my mod_jk approach ever worked (or would have worked).

But, for whatever it's worth, you might want to provide the applicable <connection> elements and <host> elements from your server.xml file. And you might want to provide the contents of your workers.properties file.

Even with that, I'm not sure how much help we'll be (unless we can see a blatant error). I have found that when I have these kinds of config issues, it almost always ends up being something related to my server environment (that the user list can't possibly help with). I usually discover these errors by doing a fresh installation of a vanilla server (in my case RedHat WS 4) and see if what I'm trying to do works right out the box (before I do all of my custom OS tweaking). A test install like this usually only takes an hour or so, and I am constantly surprised how often I find that I don't have problems on a fresh install...which helps me to tie down what's wrong with my production settings.
 
Thank you guys but I have finally found the solution. Just add in your virtual host

RewriteEngine on
RewriteRule ^/$ /mywebapp/ [R]

Here is the information that I used to solve my problem. :eek:) I am so happy!!!!!!!!!!!!

Moved DocumentRoot
Description:
Usually the DocumentRoot of the webserver directly relates to the URL "/". But often this data is not really of top-level priority, it is perhaps just one entity of a lot of data pools. For instance at our Intranet sites there are /e/www/ (the homepage for /e/sww/ (the homepage for the Intranet) etc. Now because the data of the DocumentRoot stays at /e/www/ we had to make sure that all inlined images and other stuff inside this data pool work for subsequent requests.

Solution:
We redirect the URL / to /e/
RewriteEngine on
RewriteRule ^/$ /e/www/ [R]

Note that this can also be handled using the RedirectMatch directive:

RedirectMatch ^/$
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top