PHP 5.4起就在CLI SAPI中内置了web服务器,这给开发者带来了方便。
只需在项目目录下执行
php -S localhost:8001
访问链接,终端就会产生access log
E:\php\test\web_server>php -S localhost:8001
PHP 5.4.33 Development Server started at Sat Sep 26 12:10:01 2015
Listening on http://localhost:8001
Document root is E:\php\test\web_server
Press Ctrl-C to quit.
[Sat Sep 26 12:10:07 2015] 127.0.0.1:65349 [200]: /phpinfo.php
[Sat Sep 26 12:10:07 2015] 127.0.0.1:65350 [200]: /phpinfo.php?=PHPE9568F34-D428-11d2-A769-00AA001ACF42
[Sat Sep 26 12:10:07 2015] 127.0.0.1:65351 [200]: /phpinfo.php?=PHPE9568F35-D428-11d2-A769-00AA001ACF42
[Sat Sep 26 12:10:07 2015] 127.0.0.1:65352 [404]: /favicon.ico - No such file or directory
可指定目录和不同的php.ini配置
php -S localhost:8001 -t E:\php\test\web_server\ -c D:\software\amp\php-5.6.5-Win32-VC11-x64\php.ini
原来PHP 5.4起就在CLI SAPI内置了服务器哦,小编使用的最高版本也是php5.3哦。