tomcat php

在服务器上php的安装:
1。下载php-4.4.2 for windows的压缩包
2。解压缩到D:\software\php442
3。将D:\software\php442增加到环境变量PATH中
4。将php.ini-dist做一个备份,然后重命名为php.ini,修改
extension_dir = "D:\software\php442\extensions"
cgi.force_redirect = 0

5。Tomcat的配置:
打开conf\web.xml,增加如下一段:

 <!-- hankjin php -->
 <servlet>
        <servlet-name>cgi</servlet-name>
        <servlet-class>org.apache.catalina.servlets.CGIServlet</servlet-class>
        <init-param>
          <param-name>clientInputTimeout</param-name>
          <param-value>100</param-value>
        </init-param>
        <init-param>
          <param-name>debug</param-name>
          <param-value>0</param-value>
        </init-param>
        <init-param>
          <param-name>executable</param-name>
          <param-value>d:/software/php442/php.exe</param-value>
        </init-param>
        <init-param>
          <param-name>cgiPathPrefix</param-name>
          <param-value>WEB-INF/..</param-value>
        </init-param>
        <load-on-startup>5</load-on-startup>
    </servlet>

    <servlet-mapping>
        <servlet-name>cgi</servlet-name>
        <url-pattern>*.php</url-pattern>
    </servlet-mapping>
 <!-- end hankjin php -->

6。到server\lib目录,将servlets-cgi.renametojar文件重命名为servlets-cgi.jar
7。到一个Web Application下,新建一个test.php,内容为:
<?php phpinfo();?>
8。重启Tomcat服务器,访问这个test.php,OK

9。如果要用mysql,需要在修改my.ini

在max_connections=100下面加一行
enable-named-pipe

并且连接用的IP要用.而且如果mysql服务器的版本比较高,还需要修改密码:

SET PASSWORD FOR modoer@'%'=OLD_PASSWORD('modoer');

 

 

 

 

 

 

 

 

你可能感兴趣的:(tomcat)