can I use both php and java for a same web application
I want to use php in place of jsp/servlets for my web app whose service layer and database layer has been writ开发者_运维技巧ten in java. It is possible to do so? If yes, can a web hosting server run both of them simultaneously?
Take a look at Palava. Our main goal of this framework is exactly want you want:
- PHP Scripts instead of JSP/Servlets, but
- a reliable and fast Java backend
You can take a look at http://php-java-bridge.sourceforge.net/pjb/FAQ.html Or, as mentioned before use mod_proxy. Yet another way would be to setup java locally and have php call some sort of REST or SOAP java api to get the data and then display it.
The easiest way is probably to have one php webserver and one servlet container such as tomcat. You can configure tomcat to run on a different port such as 8080 and use apaches mod_proxy to make the servlet container available on port 80.
Here's what my configuration looks like:
<VirtualHost *:80>
ServerAdmin emil@mydomain.com
ServerName mydomain.com
ProxyRequests Off
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
ProxyPass / http://localhost:8080/
ProxyPassReverse / http://localhost:8080/
</VirtualHost>
There's also a PHP implementation in Java called Quercus. I haven't tried it, but it might be worth checking out.
The last time it tried the php-java-bridge, it seemed rather slow. However, that was back in 2007, so things might have changed.
精彩评论