使用 tomcat 运行 php 应用程序? [英] Run a php app using tomcat?

查看:26
本文介绍了使用 tomcat 运行 php 应用程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以使用 tomcat 运行 PHP 应用程序?

在你告诉我只使用 httpd 之前,我已经在我的网络服务器上运行了一个 Java 应用程序,位于 host/myapp.现在我想在 host/roundcube 上安装 RoundCube.

一个是 PHP,一个是 Java.我一直看到临时引用说这是可能的,但没有真正的说明.我不想将它们放在单独的端口上,我需要标准的 HTTP 和 HTTPS 端口.

有人有这方面的资源吗?

解决方案

Yes it is possible Will Den.我们可以使用自己的端口号 localhost:8080 在 tomcat 服务器中运行 PHP 代码

这里我写了一些对你非常有用的步骤.

如何在 windows 中的 Tomcat 6 上安装或运行 PHP

  1. 将 PHP 5 下载并解压到一个目录,c:\php-5.2.6-Win32 - php-5.2.9-2-Win32.zip 下载

  2. 下载 PECL 5.2.5 Win32 二进制文件 - PECL 5.2.5 Win32 下载

  3. c:\php-5.2.6-Win32中将php.ini-dist重命名为php.ini>

  4. php.ini 中取消注释或添加行(去掉开头的分号):;extension=php_java.dll

  5. php5servlet.dll 从 PECL 5.2.5 复制到 c:\php-5.2.6-Win32

  6. php_java.dllPECL 5.2.5 复制到 c:\php-5.2.6-Win32\ext

  7. php_java.jarPECL 5.2.5 复制到 tomcat\lib

  8. tomcat\webapps目录

  9. 中创建一个名为"php"(或者你喜欢的任何名字)的目录
  10. phpsrvlt.jarPECL 5.2.5 复制到 tomcat\webapps\php\WEB-INF\lib

  11. Unjar 或 unzip phpsrvlt.jar 解压使用 winrar 或 winzip 解压使用:jar xfv phpsrvlt.jar

  12. net\php\reflect.propertiesnet\php\servlet.properties 都更改为 library=php5servlet

  13. 重新创建jar文件-> jar cvf php5srvlt.jar net/php/.PS:如果jar文件没有运行你必须为我添加系统变量的路径我添加了C:\Program Files\Java\jdk1.6.0\bin;到系统变量/路径

  14. 使用以下内容在 tomcat\webapps\php\WEB-INF 中创建 web.xml:

    <小服务程序><servlet-name>php-formatter</servlet-name><servlet-class>net.php.formatter</servlet-class><servlet-mapping><servlet-name>php</servlet-name><url-pattern>*.php</url-pattern></servlet-mapping><servlet-mapping><servlet-name>php-formatter</servlet-name><url-pattern>*.phps</url-pattern></servlet-mapping></web-app>

  15. 将 PHP 路径(c:\php-5.2.6-Win32)添加到 Windows 环境中的系统或用户路径(提示:右键单击并从 中选择属性我的电脑

  16. tomcat\webapps\php下创建test.php用于测试

  17. 重启tomcat

  18. 浏览localhost:8080/php/test.php

Is it possible to run a PHP app using tomcat?

Before you tell me to just use httpd, I already have a Java application running on my webserver at host/myapp. Now I want to install RoundCube at host/roundcube.

One is PHP and one is Java. I keep seeing offhand references saying this is possible but no real instructions. I do not want to put them on separate ports, I need the standard HTTP and HTTPS ports.

Does anyone have any resources for this?

解决方案

Yes it is Possible Will Den. we can run PHP code in tomcat server using it's own port number localhost:8080

here I'm writing some step which is so much useful for you.

How to install or run PHP on Tomcat 6 in windows

  1. download and unzip PHP 5 to a directory, c:\php-5.2.6-Win32 - php-5.2.9-2-Win32.zip Download

  2. download PECL 5.2.5 Win32 binaries - PECL 5.2.5 Win32 Download

  3. rename php.ini-dist to php.ini in c:\php-5.2.6-Win32

  4. Uncomment or add the line (remove semi-colon at the beginning) in php.ini: ;extension=php_java.dll

  5. copy php5servlet.dll from PECL 5.2.5 to c:\php-5.2.6-Win32

  6. copy php_java.dll from PECL 5.2.5 to c:\php-5.2.6-Win32\ext

  7. copy php_java.jar from PECL 5.2.5 to tomcat\lib

  8. create a directory named "php" (or what ever u like) in tomcat\webapps directory

  9. copy phpsrvlt.jar from PECL 5.2.5 to tomcat\webapps\php\WEB-INF\lib

  10. Unjar or unzip phpsrvlt.jar for unzip use winrar or winzip for unjar use : jar xfv phpsrvlt.jar

  11. change both net\php\reflect.properties and net\php\servlet.properties to library=php5servlet

  12. Recreate the jar file -> jar cvf php5srvlt.jar net/php/. PS: if the jar file doesnt run you have to add the Path to system variables for me I added C:\Program Files\Java\jdk1.6.0\bin; to System variables/Path

  13. create web.xml in tomcat\webapps\php\WEB-INF with this content:

    <web-app version="2.4" 
      xmlns="http://java.sun.com/xml/ns/j2ee"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance "
      xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee 
      http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd ">
      <servlet>
        <servlet-name>php</servlet-name>
        <servlet-class>net.php.servlet</servlet-class>
      </servlet>
      <servlet>
        <servlet-name>php-formatter</servlet-name>
        <servlet-class>net.php.formatter</servlet-class>
      </servlet>
      <servlet-mapping>
        <servlet-name>php</servlet-name>
        <url-pattern>*.php</url-pattern>
      </servlet-mapping>
      <servlet-mapping>
        <servlet-name>php-formatter</servlet-name>
        <url-pattern>*.phps</url-pattern>
      </servlet-mapping>
    </web-app>
    

  14. Add PHP path( c:\php-5.2.6-Win32) to your System or User Path in Windows enironment (Hint: Right-click and select Properties from My Computer

  15. create test.php for testing under tomcat\webapps\php like

  16. Restart tomcat

  17. browse localhost:8080/php/test.php

这篇关于使用 tomcat 运行 php 应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆