Deploying the PHP development environment in a tomcat environment

Source: Internet
Author: User
Tags php development environment php script zend

Resources: http://windows.php.net/download/

1, download the PHP package, this environment for the Windows environment, so download as a ZIP package


2, decompression to Tomcat installation path, renamed to PHP


3, set the environment variable, path add just the path D:\apache-tomcat-8.0.36\php;

CMD input php-v or php-version authentication, if return the following information then PHP setup succeeds

C:\users\administrator>php-v
php 7.2.1 (CLI) (Built:jan  4 2018 04:00:18) (NTS MSVC15 (Visual C + + 2017) x64
  )
Copyright (c) 1997-2017 the PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2017 Zend
4. Configure PHP.ini

Backup php.ini-development to the PHP path and modify the original file to PHP.ini

Modify the following configuration:

(1) Remove extension_dir = "ext" front;

(2) Removing the front of the cgi.force_redirect and modifying the value to 0

5. Configure Tomcat

Open Tomcat's Conf folder, modify the Context.xml file, and add the attribute privileged= "true" in the context, as shown in


Then modify the Web.xml file and add the following <servlet> to the <web-app>, where executable is the php-cgi execution path

    <servlet> <servlet-name>php</servlet-name> <servlet-class>org.apache.catalina. Servlets. Cgiservlet</servlet-class> <init-param> <param-name>clientinputtimeout</param-name&
          Gt <param-value>200</param-value> </init-param> <init-param> <param-name>de 
          bug</param-name> <param-value>0</param-value> </init-param> <init-param> <param-name>executable</param-name> &LT;PARAM-VALUE&GT;D:\APACHE-TOMCAT-8.0.36\PHP\PHP-CG i.exe</param-value> </init-param> <init-param> <param-name>passshellenvironmen t</param-name> <param-value>true</param-value> </init-param> <init-pa Ram> <param-name>cgiPathPrefix</param-name> <param-value>web-inf/phpbin</param -value> </init-param> <load-on-startup>5</load-on-startup> </servlet> 
and add the following <servlet-mapping> where Url-pattern is the PHP script path
    <servlet-mapping>
        <servlet-name>php</servlet-name>
        <url-pattern>/phpbin/*</ Url-pattern>
    </servlet-mapping>


6, testing

Create a new Phpbin folder under Webapps\root\web-inf and place the index.php in the following

<?php phpinfo ();? >
Restart Tomcat, and when the browser enters http://localhost:8080/phpbin/index.php, the configuration succeeds when the interface is opened as follows


The subsequent code is also placed under the Phpbin path and can be opened in the browser.





Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.