Use PHP built-in web server to realize simple debugging application

Time:2021-9-11

Because I often execute some PHP code fragments or temporary projects for testing. The office environment is in the virtual machine. I don’t want to destroy the office environment because of some personal tests;

Therefore, only one PHP can be installed locally in win (the installation is omitted), or PHP can be installed on Linux in the virtual machine to run the test task; (Linux mode in virtual machine is recommended)

Remind again that this method is only used for local testing;

#Create a WWW directory in your home directory

requesthttp://192.168.204.151:8000/ , the return effect is as follows

Use PHP built-in web server to realize simple debugging application

requesthttp://192.168.204.151:8000/info.php , the return effect is as follows

Use PHP built-in web server to realize simple debugging application

Specify a root directory at startup

#Create a test directory under ~ / www and add the PHP script file (~ / www / test / index. PHP)

Access test

Use PHP built-in web server to realize simple debugging application

Specify a script as a router

#First create a router.php

Direct request192.168.204.151:8000/

Use PHP built-in web server to realize simple debugging application

Request a TXT file and return the contents of the modified file

Use PHP built-in web server to realize simple debugging application

Conclusion: using this method, it is more convenient for individuals to do tests. If there are mistakes, please correct them!

This work adoptsCC agreement, reprint must indicate the author and the link to this article

June wind