php+tomcat 配置運行環境

爲了學習php,本教程始於:2017.11.16php

 

完成時的截圖!web

 

 

1.首先下載: VC 2015++apache

  點擊下載windows

 

2.tomcat

把下載好的php複製到本目錄,而後解壓而且重命名爲「php」,若是沒有下載php,請 點擊下載session

 

 

extension_dir = "ext"
cgi.force_redirect = 0

 

3.修改content.xmlapp

 

或者直接把下面的代碼拷貝進去便可  Tomcat裏面conf的content.xml 學習

<Context privileged="true">

    <!-- Default set of monitored resources. If one of these changes, the    -->
    <!-- web application will be reloaded.                                   -->
    <WatchedResource>WEB-INF/web.xml</WatchedResource>
    <WatchedResource>WEB-INF/tomcat-web.xml</WatchedResource>
    <WatchedResource>${catalina.base}/conf/web.xml</WatchedResource>
    <!-- Uncomment this to disable session persistence across Tomcat restarts -->
    <!--
    <Manager pathname="" />
    -->
</Context>

 

4.修改web.xml,在tomcat裏面的conf文件夾下面的web.xml修改一下測試

 

拷貝如下代碼到web.xml。創建一個servlet (xml格式能夠會有變化,建議你去格式化xml以修正博客編寫時以及複製形成的偏差)this

拷貝到第一個默認的servlet下面便可

 

<servlet>
        <servlet-name>php</servlet-name>
        <servlet-class>org.apache.catalina.servlets.CGIServlet</servlet-class>
        <init-param>
            <param-name>clientInputTimeout</param-name>
            <param-value>200</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>
            <!--php下載解壓/安裝的路徑-->
            <param-value>F:\tomcat\php\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>
            <!--本身tomcat下對應的url-->
            <param-value>WEB-INF/phpbin</param-value>
        </init-param>
        <load-on-startup>5</load-on-startup>
    </servlet>
    <servlet-mapping>
        <servlet-name>php</servlet-name>
        <url-pattern>/phpbin/*</url-pattern>
    </servlet-mapping>

 5.新建一個文件夾phpbin ,而後裏面放php文件

測試文件是:

index.php

代碼以下(copy複製便可)

<?php phpinfo()?>

 

測試地址是:

本地地址

 

相關文章
相關標籤/搜索