Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP: Resource Temporarily Unavailable for simple "hello world"

Tags:

php

I've just installed 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

I created a new directory called test/ with one file called test.php containing this:

<?php echo "hello world";

When I start a php server and try to load it in the browser, I get a "Resource temporarily unavailable" error:

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

I have Googled this and all issues I've found are people who are trying to include() another file in some way (using other PHP methods). Haven't found anything similar to what I'm experiencing with just a simple echo statement.

NOTE: I've tried giving full read/write/execute permissions to both the test.php file and the test/ directory; same results.

like image 689
Johnny Avatar asked Jan 06 '14 04:01

Johnny


1 Answers

Ah, don't add the .. The built-in server uses the CWD as document root (or the path specified via the -t flag). You're attempting to use . as a router script. Simply run...

php -S localhost:8080

See http://php.net/manual/features.commandline.webserver.php

like image 76
Phil Avatar answered Nov 09 '22 07:11

Phil