上一个主题< Cherokee 安装说明(Cherokee Installation Notes) 下一个主题教程 1:让我们通过例子来学习(Tutorial 1: Let’s learn by example) > 本页 |
使用 PHP 内置 web 服务器(Using PHP Built-in webserver)¶对于PHP 5.4.0或以上版本, 你可以为项目开发使用PHP内置的web服务器。 为了启动web服务器,需要: php -S localhost:8000 -t /public
如果你想重写URI并指向index.php文件,可以使用以下路由文件(.htrouter.php): <?php
if (!file_exists(__DIR__ . '/' . $_SERVER['REQUEST_URI'])) {
$_GET['_url'] = $_SERVER['REQUEST_URI'];
}
return false;
然后这样启动服务器: php -S localhost:8000 -t /public .htrouter.php
最然打开浏览器输入并跳转到 http://localhost:8000/,检测是否可以正常访问。 |