Home >Backend Development >PHP Problem >How to set up tomcat php environment
How to build tomcat php environment: 1. Copy the downloaded php to the corresponding directory; 2. Unzip and rename it to "php"; 3. Modify content.xml; 4. Modify the conf in tomcat web.xml in the folder.
The operating environment of this article: Windows 7 system, PHP version 7.1, Dell G3 computer.
How to set up tomcat php environment?
php tomcat configures the running environment
Screenshot when completed!
Although you can run php projects 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.
Copy the downloaded php to this directory, then unzip it and rename it to "php". If you have not downloaded php, please xampp download address:
https://www.apachefriends.org/zh_cn/index.html
Just choose the download version according to our environment:
##Two of them cannot be removed. It is 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.
extension_dir = "ext"cgi.force_redirect = 0
3. Modify content.xml
Or just copy the code below
The content.xml of conf in Tomcat
4f44fd2efe99fd1e4b3f6ded96018d07 d715b34a458de497ac7347a8f2f56eb0 a391ba37a516346ea01e57a79c45718e c37336e149127b2130b09e7e862affd8WEB-INF/web.xmlcfabfff5dd0af77999fe2d5496dbcc63 c37336e149127b2130b09e7e862affd8WEB-INF/tomcat-web.xmlcfabfff5dd0af77999fe2d5496dbcc63 c37336e149127b2130b09e7e862affd8${catalina.base}/conf/web.xmlcfabfff5dd0af77999fe2d5496dbcc63 bbb5fc2b222006d9bb13551b79f5d45b 214c06e98961eac83cec67ea372e7eda --> eb08cd6cbb5bbfe6574686a6a841fa4b4. Modify web.xml, modify the web.xml under the conf folder in tomcat
拷贝以下代码到web.xml。建立一个servlet (xml格式可以会有变化,建议你去格式化xml以修正博客编写时以及复制造成的误差)
拷贝到第一个默认的servlet下面即可
46309ed845064fdb06e746051efff9e0 700b5f17c4d842e4bd410f680f40946bphp72eca723e64ddd01187c8b4d58572fcb b472d9135dbff3dd7fcc77f5995c97d0org.apache.catalina.servlets.CGIServlet4f01b97d64aea37f699ead4eb7bd2bbd 380fae52cc7d04565d26dd4bbf4b5460 c13d9669d2c8f87a36a39c8f95f41552clientInputTimeout02b9ad8b27bc78bd91c18db845cdde4a f226acac8cb0e4a9d59fcba58b57a89920022c8aeb51b7638a9da01bd5a66154ac1 8f161518881ffd7712eaaadc573a3556 380fae52cc7d04565d26dd4bbf4b5460 c13d9669d2c8f87a36a39c8f95f41552debug02b9ad8b27bc78bd91c18db845cdde4a f226acac8cb0e4a9d59fcba58b57a899022c8aeb51b7638a9da01bd5a66154ac1 8f161518881ffd7712eaaadc573a3556 380fae52cc7d04565d26dd4bbf4b5460 c13d9669d2c8f87a36a39c8f95f41552executable02b9ad8b27bc78bd91c18db845cdde4a 3f547a760277f1afc8956d250f61bab7 f226acac8cb0e4a9d59fcba58b57a899F:\tomcat\php\php-cgi.exe22c8aeb51b7638a9da01bd5a66154ac1 8f161518881ffd7712eaaadc573a3556 380fae52cc7d04565d26dd4bbf4b5460 c13d9669d2c8f87a36a39c8f95f41552passShellEnvironment02b9ad8b27bc78bd91c18db845cdde4a f226acac8cb0e4a9d59fcba58b57a899true22c8aeb51b7638a9da01bd5a66154ac1 8f161518881ffd7712eaaadc573a3556 380fae52cc7d04565d26dd4bbf4b5460 c13d9669d2c8f87a36a39c8f95f41552cgiPathPrefix02b9ad8b27bc78bd91c18db845cdde4a 2e6c579986093ff6a939d7929d06c342 f226acac8cb0e4a9d59fcba58b57a899WEB-INF/phpbin22c8aeb51b7638a9da01bd5a66154ac1 8f161518881ffd7712eaaadc573a3556 4781e2cbaa93c386271b418d3a01af0853065abc64b27fbca30c0905ab93e8ea0 20d42bb762ac7d7e594da3a264e47fcc 870ae7edaa11700bcea972d006efb06e 700b5f17c4d842e4bd410f680f40946bphp72eca723e64ddd01187c8b4d58572fcb 66e1775cbd9d5002635ae3285442ba88/phpbin/*3ec4a5583206d351b61ed79c1a0f9c66 cb808b0e21d3ee32c89fe10adc3f12ec
5.新建一个文件夹phpbin ,然后里面放php文件
测试文件是:
index.php
代码如下(copy复制即可)
6ee07e5f4ae1348553fd546fdbbb400f
测试地址是:
本地地址
推荐学习:《PHP视频教程》
The above is the detailed content of How to set up tomcat php environment. For more information, please follow other related articles on the PHP Chinese website!