Two different languages PHP and Java on same appli

2019-03-22 14:45发布

问题:

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.

回答1:

The two applications served via apache should not be a problem look at mod_jk This will mean your java web app is still running on tomcat which it has to do anyway.



回答2:

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



回答3:

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"/>