#### 1. 前言 --- PHP从5.4开始,就提供了一个内置的web服务器。 这个主要是用来做本地的开发测试用的,不能用于线上环境。 **将PHP的安装路径配置到电脑的系统环境变量Path中,下图是win7,win10中会看的更清楚** ![](https://img.itqaq.com/art/content/e792fb695db8bc795f98e69532a74963.png) #### 2. 进入项目目录,执行命令 --- **a. 启动php内置服务器** ``` php -S localhost:8080 ``` ![](https://img.itqaq.com/art/content/d2b709048e51b67b6a47cb98b37d71dd.png) **b. 浏览器测试访问** ![](https://img.itqaq.com/art/content/e8cebf6cdf3388a9f650e2868b3963cb.png) #### 3. 命令参数 --- **-S 访问地址:端口,通过内置web服务运行php** ``` php -S localhost:8080 ``` **-t 站点根目录,指定web服务的网站根目录** ``` php -S localhost:8080 -t 运行目录 ``` ![](https://img.itqaq.com/art/content/517fa7c90540288d74141c00ac9af3fa.png) **访问指定的文件** ``` php -S localhost:8080 index.php ```