继续浏览精彩内容
慕课网APP
程序员的梦工厂
打开
继续
感谢您的支持,我会继续努力的
赞赏金额会直接到老师账户
将二维码发送给自己后长按识别
微信支付
支付宝支付

让apache-tomcat支持php

慕无忌1623718
关注TA
已关注
手记 202
粉丝 11
获赞 53

原环境为 Apache-tomcat-7.0,现在需要支持php

 

先装一个扩展

wget http://ftp.gnu.org/gnu/libiconv/libiconv-1.14.tar.gz

 tar -zxf libiconv-1.14.tar.gz

cdlibiconv-1.14

./configure--prefix=/usr/local/libiconv

 make && make install

 

 

编译php

./configure--prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc--with-openssl --enable-cli --with-mysql=mysqlnd --with-pdo-mysql=mysqlnd--with-iconv=/usr/local/libiconv --with-freetype-dir --enable-maintainer-zts--with-zlib --enable-xml --enable-rpath --enable-bcmath --enable-shmop--enable-sysvsem --enable-inline-optimization --with-curl --enable-exif--enable-mbregex --enable-fpm --enable-mbstring --with-gd --enable-gd-native-ttf --with-mhash --enable-pcntl--enable-sockets --with-xmlrpc --enable-zip --enable-soap--with-mcrypt=/usr/local --enable-force-cgi-redirect --enable-cgi &&make ZEND_EXTRA_LIBS='-liconv' && make install

 

 

 修改Tomcat 配置

Web.xml

<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>

     <param-value>/usr/local/php/bin/php-cgi</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>/</param-value>

    </init-param>

    <load-on-startup>5</load-on-startup>

</servlet>


<servlet-mapping>

   <servlet-name>php</servlet-name>

   <url-pattern>*.php</url-pattern>

</servlet-mapping>

 

 

<welcome-file-list>

   <welcome-file>index.html</welcome-file>

   <welcome-file>index.htm</welcome-file>

   <welcome-file>index.jsp</welcome-file>

   <welcome-file>index.php</welcome-file>

</welcome-file-list>


打开App,阅读手记
0人推荐
发表评论
随时随地看视频慕课网APP