简体   繁体   中英

Two different languages PHP and Java on same application with PHP on Apache and Java on Tomcat

I am also finding tough to categorize this question. So please bear with me to explain the issue.

We have two different applications:

  1. PHP on XAMPP and
  2. Java on Tomcat

Now we have a business case to merge both the products. ie., PHP product should be looking no different from the Java application and also it should be part of Java app. (appears in the one of the tab in Java app)

The CSS part can be taken care. But the complex part is how to collate these two application?

Also we are using Tomcat for Java and Apache for PHP,
in such case how do we bundle the product as one.

I tried googling, but most of them point to having apache and tomcat connector etc.
But I am still not clear on how to achieve this seamless integration.

Misc Info:

--- Java App: DB: MySQL, Maven, Servlet, Spring, Struts, Hibernate
--- PHP App: XAMPP (or somecases LAMP)

Please let me know if I had missed out any details.

通过apache服务的两个应用程序在mod_jk上应该不是问题,这意味着您的Java Web应用程序仍在tomcat上运行,无论如何它仍必须这样做。

Maybe this tutorial will help. Though I haven't tried it myself so I can't say for sure.

I am able to get Apache talk to Tomcat through mod_proxy. I actually referred to the below links to get this working (mostly changes to httpd.conf in Apache and server.xml in Tomcat):

http://tomcat.apache.org/tomcat-5.5-doc/proxy-howto.html http://confluence.atlassian.com/display/DOC/Using+Apache+with+mod_proxy http://publib.boulder.ibm.com/infocenter/cqhelp/v7r0m0/index.jsp?topic=/com.ibm.rational.clearquest.webadmin.doc/rwp/t_config_mod_proxy_support.htm

I then configured PHP with Apache following [this link][1] and got the PHP configured with Apache.

So as a test program, I am able to reach servlet programs (Tomcat) from a Apache like http://localhost/example/servlet then access PHP programs too with a URL like http://localhost/phptest

ZeissS, Paul and Vincent. Thanks all for your help. Even though I have a long way to go, this looks like the starting point.

=== httpd.conf in Apache server ===

# enable the below or add new
LoadModule proxy_module modules/mod_proxy.so

LoadModule proxy_http_module modules/mod_proxy_http.so

# Start Modules for PHP
LoadModule php5_module "c:/php/php5apache2_2.dll"

AddHandler application/x-httpd-php .php

# configure the path to php.ini
PHPIniDir "c:/windows"

# Just at the end of 'Main' server configuration - add the below
ProxyRequests On 
ProxyVia On 
<Proxy *>
    Order deny,allow
    Allow from all
</Proxy>

ProxyPass /examples http://localhost:8080/examples/
ProxyPass /servlets http://localhost:8080/examples/servlets/
ProxyPass /jsp http://localhost:8080/examples/jsp/
ProxyPassReverse /examples http://localhost:8080/examples/

# Finish Modules for PHP

=== server.xml in Tomcat ===
<!-- searched the below connector port=8080 and I replaced that tag with the below -->
 <Connector port="8080" maxHttpHeaderSize="8192"
           maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
           enableLookups="false" redirectPort="8443" acceptCount="100"
           connectionTimeout="20000" disableUploadTimeout="true"
           proxyName="http://localhost" proxyPort="80"/>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM