Home  >  Article  >  Operation and Maintenance  >  How to configure tomcat to run PHP projects

How to configure tomcat to run PHP projects

坏嘻嘻
坏嘻嘻Original
2018-09-15 17:20:337475browse

The content of this article is about how to configure tomcat to run PHP projects. It has certain reference value. Friends in need can refer to it. I hope it will be helpful to you.

1. Foreword

Due to the needs of the company, the author needs to build a PHP project, but the author has not been exposed to any PHP-related development before, so I have basic knowledge about PHP development and environment construction. Neither the requirements nor the compiler understand it. However, the author found during research that even if he integrates the PHP development environment, he still needs the support of the Apache server. Since the tomacat hot deployment project is often used in the recent development of j2ee, it naturally comes to mind that tomcat is also an apache product. Can PHP projects be deployed in tomcat? ? After some research, it was determined to be feasible.

2. Install the PHP environment

Although you can run the PHP project on tomcat, it does not mean that you do not need to configure the PHP environment, so the first step is to install the PHP environment. Currently, it is common to use apache php mysql to develop a php project, which can be installed separately. But the author is lazy and not interested in studying PHP in depth, so I used xampp, which can install all the environments required for PHP development including the compiler at once.

xampp download address: Download address

Just choose the download version according to our environment:

How to configure tomcat to run PHP projects

Install after downloading, as long as Just keep going to the next step. But one of the more important steps is to choose the environment content for installation. Below:

How to configure tomcat to run PHP projects

#Two of the uncheckable ones are necessary. That php is the Php development environment we want. The rest are not installed because mysql and tomcat are already installed on my computer. Readers can choose to install it according to their own circumstances.

3. Configure tomcat to support PHP projects

First we need to download the jar package to support PHP projects.

Download address: Download address

We will put the decompressed jar package into the tomcat lib directory:

How to configure tomcat to run PHP projects


Then we need to configure web.xml, which is in the conf directory of tomcat:

We add some content to the node:

	

 php.java.servlet.ContextLoaderListener

 

 

 PhpJavaServlet

 php.java.servlet.PhpJavaServlet

 

 

 PhpCGIServlet

 php.java.servlet.fastcgi.FastCGIServlet

 

 prefer_system_php_exec

 On

 

 

 php_include_java

 Off

 

 

 

 PhpJavaServlet

 *.phpjavabridge

 

 

 PhpCGIServlet

 *.php

 

and then find node, add the following welcome content:

index.php

At this point, our basic configuration is complete.

4. Add the php project to tomcat

I copied our php project into the webapp directory of tomcat.

How to configure tomcat to run PHP projects

The above is the detailed content of How to configure tomcat to run PHP projects. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn