• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 185
  • Last Modified:

Support for JSP & PHP on a single website

I have to support JSP as well as PHP pages using Apache Web Server & Apache Tomcat. Currently the website homepage is served by Tomcat (on port 8080). There is a link for PHP content from this site which is served by Apache Web Server (port 80). I have two questions:

1) Is there a better way (preferred way) to accomodate JSP & PHP.
2) How can I forward my company URL (www.somecompany.com) to www.comecompany.com:8080/someurl.

Thanks
0
swsbuyer
Asked:
swsbuyer
  • 2
1 Solution
 
nizsmoDeveloperCommented:
So what we want is to configure apache to locate PHP pages within JSP web context and handling all PHP request while letting TOMCAT handle all other requests.

http://www.devx.com/webdev/Article/32110/0/page/2

The above will show you just how to do that, there's also 3 ways of going about doing it, all mentioned in the article.

Let me know how you go.
0
 
samriCommented:
in my personal opinion, what you had is very much what most people would be doing - apache to serve PHP, and tomcat to handle the JSP stuff.

the link mentioned by nizsmo is excellent. to be honest, i never got a chance to finish going thru the link :(

in the 2nd part -- you could either do a "Redirect".

Redirect /    http://www.comecompany.com:8080/someurl/

in the global server config, or the Vhost container for www.somecompany.com.  This however, would cause the URL in the client web browser to change

from http://www.somecompany.com/ 
to    http://www.somecompany.com:8080/someurl/

another method is to use apache proxy module (http://httpd.apache.org/docs/2.2/mod/mod_proxy.html).

Specifically ProxyPass and ProxyPassReverse:

http://httpd.apache.org/docs/2.2/mod/mod_proxy.html#proxypass
http://httpd.apache.org/docs/2.2/mod/mod_proxy.html#proxypassreverse

--
ProxyPass              /  http://www.somecompany.com:8080/someurl/
ProxyPassReverse /  http://www.somecompany.com:8080/someurl/

in the Apache global configuration (if you do not have vhost), or in the Vhost container for www.somecompany.com.

cheers.
0
 
swsbuyerAuthor Commented:
Thanks for your responses. I am currently stuck on some other emergencies. As soon as I am released from that I will start work on this issue and provide my feedback.

Regards.
0
 
swsbuyerAuthor Commented:
All right. I am back to this issue.

I tried following the document nizsmo pointed. I am able to make connection between Apache & Tomcat. The only problem is that the PHP files are also being forwarded to tomcat.

My httpd.conf is as follows:

<VirtualHost *:88>
    DocumentRoot "/root/tomcat/apache-tomcat-5.5.23/webapps"

    # Excluse PHP & CGI (let apache handle)
    SetEnvIf Request_URI \.php no-jk
    SetEnvIf Request_URI \.cgi no-jk

    JkMount /approot/ tomcat
    JkMount /approot/* tomcat

</VirtualHost>

So, now http://<server addr>/approot/ is forwarded to Tomcat - perfect.

However, http://<server addr>/approot/foo.php is also forwarded to Tomcat. This should be handled by Apache as in the example.

Any ideas?
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now