溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊(cè)×
其他方式登錄
點(diǎn)擊 登錄注冊(cè) 即表示同意《億速云用戶服務(wù)條款》

tomcat8支持CGI

發(fā)布時(shí)間:2020-07-30 14:48:51 來源:網(wǎng)絡(luò) 閱讀:215 作者:清視 欄目:web開發(fā)

一、環(huán)境

windows server 2003R2 tomcat8 PHP5 MySQL5

很多文檔要求將server/lib下servlets-cgi改名為servlets-cgi.jar。從6版本以后,好像就沒有server目錄,內(nèi)部已經(jīng)自動(dòng)支持cgi,只需要進(jìn)行配置即可。

Tomcat需要JDK 1.6以上,所以JDK需要先安裝好。


二、配置步驟:

1、到C:\php-5.3.10-Win32-VC9-x86目錄下將php.ini-development復(fù)制一份同一目錄下,命名為php.ini

<1>設(shè)置extension_dir參數(shù):

extension_dir="C:\php-5.3.10-Win32-VC9-x86\ext"

<1>設(shè)置cgi.force_redirect參數(shù):

cgi.force_redirect = 0


2、修改tomcat配置文件

<1>修改conf/web.xml,找到并將cgi的servlet和servlet-mapping的注釋去掉

    <servlet>

        <servlet-name>cgi</servlet-name>

        <servlet-class>org.apache.catalina.servlets.CGIServlet</servlet-class>

        <init-param>

          <param-name>debug</param-name>

          <param-value>0</param-value>

        </init-param>


<init-param>

 <param-name>executable</param-name>

 <param-value>C:\php-5.3.10-Win32-VC9-x86\php-cgi.exe</param-value>

</init-param>


 <init-param>

 <param-name>passShellEnvironment</param-name>

 <param-value>true</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>


<2>修改conf/context.xml

<Context privileged="true">


<3>修改默認(rèn)網(wǎng)站根目錄conf/server.xml

    <Connector port="8080" protocol="HTTP/1.1"

               connectionTimeout="20000"

               redirectPort="8443" />


      <Host name="localhost"  appBase="webapps"

            unpackWARs="true" autoDeploy="true">


<Context path="" docBase="ROOT\WEB-INF\php-bin" debug="0" reloadable="true">

</Context>


三、測(cè)試

建立index.php文件

<?php phpinfo();?>


http://10.0.1.11:8080/index.php

不出意外應(yīng)該能看到PHP的測(cè)試頁


本文參考

http://blog.csdn.net/ge_zhiqiang/article/details/6602511

http://www.cnblogs.com/top5/archive/2012/11/29/2794036.html


向AI問一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI