如何在不添加 Java Bridge 的 tomcat 服务器的情况下将 Java 后端添加到现有 PHP 站点?
目前我们的网站使用 PHP。现在我们正在考虑用 Java 编写后端,因为该语言的类型安全性以及 Java 各种工具的可用性。 我一直在阅读有关 Java Bridge 的内容,现在我想知道如何设置它。
我们已经通过 Apache 使用 PHP。我读到要使用 Java Bridge 我还需要安装 Tomcat。这意味着我有两台服务器(Apache 和 Tomcat),我需要为后端添加安全性,因为它突然向整个世界开放......我错过了什么吗?是否有另一种方法可以在不使用额外服务器的情况下建立 PHP-Java 连接?这通常是如何完成的?
非常感谢有关如何执行此操作的任何指示或链接或有关如何设置的任何最佳实践。我没有找到Java Bridge的官方网站很清楚。 谢谢!
Currently we're using PHP for our websites. Now we're thinking about writing the backend in Java, because of the type safety of the language, and the availability of all kind of tools for Java.
I've been reading about Java Bridge and now I'm wondering how to set this up.
We're using PHP already through Apache. I read that to use Java Bridge I need to install Tomcat as well. That means I have two servers (Apache and Tomcat), and I need to add security to the backend, because it is open to the whole wide world suddenly... Am I missing something? Is there another way to make the PHP-Java connection without an additional server? How is this usually done?
Any directions or links on how to to do this or any best practices on how to set it up are greatly appreciated. I didn't find the official Java Bridge site very clear.
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
我目前正在测试 Zend Java 桥的使用。两周前,我测试了 PHP/Java 桥接开源解决方案 。这确实需要您将 java 类放入部署在 Web 服务器中的 war 中(我确实使用了 Tomcat 6)。 Zend 解决方案不需要 Web 服务器。如果将业务逻辑放在普通的 java 类中,则只需将类包装在一个(或多个)jar 中即可。然后,您将 Zend java 桥守护进程启动到 JVM 中,将 Zend Java 桥 jar 以及您自己的 jar 的
Ex 从 dos windows 传递到 -classpath:
C:\Development\ToolsPHP\ZendServer\bin>java -classpath javamw.jar;mybusinesslogic.jar -Dzend.javamw.port=10002 com.zend.javamw.JavaServer。
在这里,我必须指定一个端口,因为网桥的默认端口 10001 已在使用中(使用 netstat -a 来检测端口冲突)。请注意,只有当您的 php 脚本在由 Zend 服务器(社区版或商业版)管理的 Apache 服务器上执行并且 Zend Java 桥接服务正在运行且使用 Zend 服务器管理控制台将其端口设置为 10002 时,Zend 解决方案才有效。 。
为了实现我的业务逻辑,我计划使用简单的 Java pojo、Spring、JPA 和 Hibernate。
I am currently testing the use of the Zend Java bridge. Two weeks ago, I did test the PHP/Java bridge open source solution. This one does require that you put your java classes into a war deployed in a web server (I did use Tomcat 6). The Zend solution does not require a web server. If you put your business logic in plain java classes, you simply wrap your classes in one (or several) jars. You then start the Zend java bridge daemon into a JVM, passing to the -classpath the Zend Java bridge jar aswell as your own jar's
Ex from a dos windows:
C:\Development\ToolsPHP\ZendServer\bin>java -classpath javamw.jar;mybusinesslogic.jar -Dzend.javamw.port=10002 com.zend.javamw.JavaServer.
Here, I had to specify a port since the 10001 port, which is the default for the bridge, was already in use (use netstat -a to detect port conflicts). Note that the Zend solution only works if your php script is executed on the Apache server managed by the Zend server (community or commercial edition) and that the Zend Java bridge service is running, with its port set to 10002 with the Zend server admin console.
To implement my business logic, I plan using simple Java pojo's, Spring, JPA and Hibernate.
你不需要tomcat。按照说明,您可以启动 Java 作为
java -Djava.ext.dirs=lib -jar JavaBridge.jar HTTP_LOCAL:8080 2 logfile &
lib 包含您要使用的 Java 库。
彼得
You don't need tomcat. As per instructions you can start Java as
java -Djava.ext.dirs=lib -jar JavaBridge.jar HTTP_LOCAL:8080 2 logfile &
lib contains the Java libraries you want to use.
Peter
好吧,我不是这方面的专家。基本上连一只眼睛都没有。但据我所知,您的选择几乎如下
对于 JavaBridge 您必须有一个 TomCat 服务器。
Zend Server CE 中还有一个 JavaBridge。< br>
还有 Quercus
嗯,还有 旧的 PHP4 扩展
Ok, I am not expert on this. Basically, not even one-eyed. But afaik your options are pretty much the following
For the JavaBridge you have to have a TomCat server.
There is also a JavaBridge in Zend Server CE.
And there is Quercus
Well, and the old PHP4 extension
你可以看看吉尔曼。这并不完全是您正在寻找的,但它允许客户和工作人员使用不同的语言。作为一个很好的副作用,它允许与后台作业并行处理;)
You can look at Gearman. its not exactly, what you are looking for, but it allows Clients and Workers in different languages. As a nice side effect it allows parallel processing with background jobs ;)