PHP从5.4.0起,内置了一个http服务器,开发人员可以借助这个内置服务器来做一些本地测试。

启动服务器:

打开终端,进入php安装目录,然后执行

php -S localhost:8000

这样就可以开启了,我本地测试时会报错,上网查了下原因可能是我php不是默认装在C盘,

解决这个问题也很简单,只要在后面加上 -c 的配置项就可以了

php -S localhost:8000 -c php.ini

php.ini(就是php配置文件)

可指定目录和不同的php.ini配置

php -S localhost:8000 -t E:\php\test\web_server\ -c php.ini

启动成功:

php 内置http服务器

退出服务器:Ctrl + c 

相关文章:

  • 2021-06-02
  • 2021-09-18
  • 2022-12-23
  • 2021-09-10
  • 2022-12-23
  • 2022-12-23
  • 2021-11-26
  • 2022-12-23
猜你喜欢
  • 2021-07-12
  • 2021-10-22
  • 2021-07-18
  • 2021-06-13
  • 2021-11-12
  • 2022-12-23
相关资源
相似解决方案