Home >Backend Development >PHP Problem >Can tomcat run php?

Can tomcat run php?

王林
王林Original
2019-09-11 17:52:2112843browse

Can tomcat run php?

php is a server-side language. To run a php program, it must be on the server. Today I will introduce to you how to build a php service in a web server. The selected web service is tomcat service, so first of all, everyone must install tomcat and be able to use it simply.

1. First download the php program, which is a zip compressed package. As shown below.

Can tomcat run php?

2. Unzip the downloaded php compressed package to the installation path of tomcat, and rename it to php, as shown in the figure below.

Can tomcat run php?

3. How to check whether php has been installed on your computer:

Click "Environment Variables" in Computer-Properties-Advanced Settings ", add the PATH environment variable, you can add the Admin environment variable, or you can add the system environment variable, depending on your personal needs, add the php decompression path to the PATH. Then open cmd and enter php -v or php -version.

Can tomcat run php?

Can tomcat run php?

Can tomcat run php?

4. Copy php.ini-development under the php path, Rename the copy to php.ini, and then open php.ini with Notepad. (It can be seen that; is the annotation symbol) Modify two of the settings:

Remove the; in front of extension_dir = "ext"

Change cgi.force_redirect to 0, and remove the previous;

That is, cgi.force_redirect = 0

Can tomcat run php?

5. Open the conf folder of tomcat.

Select the context.xml file, add the attribute privileged="true" to , as shown in the figure below, and save it.

Can tomcat run php?

#6. Still in tomcat’s conf folder.

Modify the web.xml file and add the following

to

    <init-param>  
      <param-name>executable</param-name>  
      <param-value>D:\tomcat\php\php-cgi.exe</param-value>  
    </init-param>

Can tomcat run php?

7. Add the following to to indicate the PHP script path.

Can tomcat run php?

8. Create a new index.php file with the following content.

Create a new phpbin folder under webapps\ROOT\WEB-INF and place index.php in it.

9. Open tomcat (in the bin folder, double-click startup.bat, on Apple systems, double-click the startup.sh file to open the tomcat service).

Open the browser, enter localhost:8080/phpbin/index.php, and see the following page, indicating that the php configuration is successful!

Can tomcat run php?

10. After that, we can happily write PHP code. The written code is placed in the phpbin path and the corresponding code is opened in the browser. script to see the effect.

Recommended video tutorial: PHP video tutorial

The above is the detailed content of Can tomcat run php?. 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
Previous article:Is php worth learning?Next article:Is php worth learning?