Support for JSP & PHP on a single website

Posted on 2007-10-06
Last Modified: 2013-12-02
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 ( to

Question by:swsbuyer
    LVL 21

    Accepted Solution

    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.

    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.
    LVL 15

    Expert Comment

    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 /

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


    another method is to use apache proxy module (

    Specifically ProxyPass and ProxyPassReverse:

    ProxyPass              /
    ProxyPassReverse /

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


    Author Comment

    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.


    Author Comment

    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


    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?

    Featured Post

    Threat Intelligence Starter Resources

    Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

    Join & Write a Comment

    Configure Web Service (server application) I. Configure security for Web Services methods First, we need to protect Session bean which implements the service: 1. Open EJB deployment descriptor (ejb-jar.xml) in the EJB project that contains you…
    Most of the developers using Tomcat find it easy to configure the datasource in Server.xml and use the JNDI name in the code to get the connection.  So the default connection pool using DBCP (or any other framework) is made available and the life go…
    Internet Business Fax to Email Made Easy - With eFax Corporate (, you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
    In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

    746 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    17 Experts available now in Live!

    Get 1:1 Help Now