PHP:资源暂时不可用于简单的“hello world”

时间:2014-01-06 04:07:39

标签: php

我刚刚安装了PHP。

$ php -v
PHP 5.5.7 (cli) (built: Dec 11 2013 20:55:14) 
Copyright (c) 1997-2013 The PHP Group
Zend Engine v2.5.0, Copyright (c) 1998-2013 Zend Technologies

我创建了一个名为test/的新目录,其中包含一个名为test.php的文件,其中包含以下内容:

<?php echo "hello world";

当我启动php服务器并尝试在浏览器中加载它时,我收到“资源暂时不可用”错误:

johnny at arch in ~/Projects/test
$ php -S localhost:8080 .
PHP 5.5.7 Development Server started at Sun Jan  5 22:34:01 2014
Listening on http://localhost:8080
Document root is /home/johnny/Projects/test
Press Ctrl-C to quit.
[Sun Jan  5 22:34:18 2014] PHP Warning:  Unknown: failed to open stream: Resource temporarily unavailable in Unknown on line 0
[Sun Jan  5 22:34:18 2014] PHP Fatal error:  Unknown: Failed opening required '.' (include_path='.:/usr/share/pear') in Unknown on line 0
[Sun Jan  5 22:34:19 2014] PHP Warning:  Unknown: failed to open stream: No such file or directory in Unknown on line 0
[Sun Jan  5 22:34:19 2014] PHP Fatal error:  Unknown: Failed opening required '.' (include_path='.:/usr/share/pear') in Unknown on line 0

我用谷歌搜索了这个,我发现的所有问题都是以某种方式尝试include()另一个文件的人(使用其他PHP方法)。没有找到任何类似于我正在经历的简单回声声明。

注意:我已尝试为test.php文件和test/目录提供完整的读/写/执行权限;相同的结果。

1 个答案:

答案 0 :(得分:19)

啊,不要添加.。内置服务器使用CWD作为文档根(或通过-t标志指定的路径)。您尝试将.用作router script。只需运行......

php -S localhost:8080

请参阅http://php.net/manual/features.commandline.webserver.php