PHP: Resource Temporarily Unavailable for simple "hello world" - 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.

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

Related

Laravel development server closing

I am working on a laravel 6 api only application so I am testing the endpoints using postman. I am getting this error when I make request to any of the endpoints
Warning: Unknown: failed to open stream: No such file or directory in Unknown on line 0
Fatal error: Unknown: Failed opening required 'C:\Elo\apiProject\server.php' (include_path='.;C:\php\pear') in Unknown on line 0
From vscode terminal I can see that the development server starts, accepts then closes as seen below
$ php artisan serve
Laravel development server started: http://127.0.0.1:8000
[Thu Apr 2 21:05:53 2020] PHP 7.4.0 Development Server (http://127.0.0.1:8000) started
[Thu Apr 2 21:05:59 2020] 127.0.0.1:53500 Accepted
[Thu Apr 2 21:05:59 2020] 127.0.0.1:53500 Closing
[Thu Apr 2 21:27:23 2020] 127.0.0.1:53668 Accepted
[Thu Apr 2 21:27:23 2020] 127.0.0.1:53668 Closing
I have no idea why it is closing and no information inside the log file. What could be responsible for throwing such error?
I had the same issue and I think it's related to the port 8000.
Maybe it's already in use or something like this because when I changed the port to 9000 (ie: php artisan server --port=9000) it solved the issue and works just fine now.
I had the same issue.In my case it was when I started to work in the project from another computer and so, I did "git clone".
I solved the problem by creating a ".env" copying the .env.example and then, I executed the command "php artisan key:generate" to generate the new API_KEY, which is mandatory for the start of the server.
Hope it helped you !

Symfony 4 Bug Vendor /route.php After server:run

In Symfony 4, I have one bug when I use:
php bin/console serve:run
[Thu Sep 27 19:11:00 2018] PHP Warning: Unknown: failed to open stream: No such file or directory in Unknown on line 0
[Thu Sep 27 19:11:00 2018] PHP Fatal error: Unknown: Failed opening required 'C:\Users\user\Documents\Sites\Symfony4\vendor\symfony\web-server-bundle/Resources/router.php' (include_path='.;C:\php\pear') in Unknown on line 0
I use composer install before this command.
I am running Windows 10.
I discovered that Avast quarantined my file. And since I was using it in silent mode, I did not see the notification.

No such file or directory error CakePHP

I inherited a CakePHP project and I am having issues getting the project running. I am running into these errors
[Fri Feb 02 00:05:35.920569 2018] [:error] [pid 536] [client 172.18.0.1:38124] PHP Warning: include(/home/tablereserv/web/tablereserv.com/public_html/lib/Cake/Error/ErrorHandler.php): failed to open stream: No such file or directory in /src/lib/Cake/Core/App.php on line 547
[Fri Feb 02 00:05:35.920638 2018] [:error] [pid 536] [client 172.18.0.1:38124] PHP Warning: include(): Failed opening '/home/tablereserv/web/tablereserv.com/public_html/lib/Cake/Error/ErrorHandler.php' for inclusion (include_path='.:/usr/share/php') in /src/lib/Cake/Core/App.php on line 547
[Fri Feb 02 00:05:35.920658 2018] [:error] [pid 536] [client 172.18.0.1:38124] PHP Warning: set_error_handler() expects the argument (ErrorHandler::handleError) to be a valid callback in /src/lib/Cake/Core/Configure.php on line 443
The file path that is trying to be included, /home/tablereserv/web/tablereserv.com/public_html/lib/Cake/Error/ErrorHandler.php does exist and the actual path to that file is /src/lib/Cake/Error/ErrorHandler.php
I have found some similar questions like the ones below, but none of the answers were particularly helpful
CakePHP ErrorHandler error
PHP Warning: include(/var/www/html/....../lib/Cake/Error/ErrorHandler.php): failed to open stream Error
When I print out the CAKE_CORE_INCLUDE_PATH variable, I get the correct path but something is obviously going wrong somewhere and I can’t seem to find it.
I also think I should mention that I set up a docker container to run the project in, I’m not sure if that could have an impact on it.
Any help would be greatly appreciated.
In my case, I found out that file mappings are stored in a file with a name similar to appname_cake_core_file_map. Once I deleted the cache file and ran the request again, a new mapping was generated with the correct path.

Call to undefined function pg_connect()

I am running the latest version of PHP (currently 5.6.22) on OSX El Capitan and Apache server.
I am trying to use PostgreSQL database and actually, yesterday already worked but after I haver overridden httpd.conf file with a default one (I guess this is the problem) I got this message:
Call to undefined function pg_connect() in ...
The thing is that I haven't changed php.ini file. If I run phpinfo(); I get etc/php.ini for a Configuration File. So I am positive that Apache choose the right php.ini file and that correct extensions are loaded:
extension=php_pdo_pgsql.dll
extension=php_pdo_sqlite.dll
What can cause this error ? Also I have installed pgAdmin 3 and I can successfully run SQL queries on created database (which I have used yesterday for this site I am working on).
EDIT:
This is what I get in error_log file when I restart Apache server and try to run that specific page (which calls pg_connect):
[Thu Jun 02 15:28:15.595496 2016] [mpm_prefork:notice] [pid 476]
AH00169: caught SIGTERM, shutting down [Thu Jun 02 15:28:16.515774
2016] [so:warn] [pid 670] AH01574: module php5_module is already
loaded, skipping PHP Warning: PHP Startup: Unable to load dynamic
library
'/usr/lib/php/extensions/no-debug-non-zts-20121212/php_curl.dll' -
dlopen(/usr/lib/php/extensions/no-debug-non-zts-20121212/php_curl.dll,
9): image not found in Unknown on line 0 PHP Warning: PHP Startup:
Unable to load dynamic library
'/usr/lib/php/extensions/no-debug-non-zts-20121212/php_mbstring.dll' -
dlopen(/usr/lib/php/extensions/no-debug-non-zts-20121212/php_mbstring.dll,
9): image not found in Unknown on line 0 PHP Warning: PHP Startup:
Unable to load dynamic library
'/usr/lib/php/extensions/no-debug-non-zts-20121212/php_mysqli.dll' -
dlopen(/usr/lib/php/extensions/no-debug-non-zts-20121212/php_mysqli.dll,
9): image not found in Unknown on line 0 PHP Warning: PHP Startup:
Unable to load dynamic library
'/usr/lib/php/extensions/no-debug-non-zts-20121212/php_pdo_pgsql.dll'
- dlopen(/usr/lib/php/extensions/no-debug-non-zts-20121212/php_pdo_pgsql.dll,
9): image not found in Unknown on line 0 PHP Warning: PHP Startup:
Unable to load dynamic library
'/usr/lib/php/extensions/no-debug-non-zts-20121212/php_pdo_sqlite.dll'
- dlopen(/usr/lib/php/extensions/no-debug-non-zts-20121212/php_pdo_sqlite.dll,
9): image not found in Unknown on line 0 PHP Warning: PHP Startup:
Unable to load dynamic library
'/usr/lib/php/extensions/no-debug-non-zts-20121212/php_pgsql.dll' -
dlopen(/usr/lib/php/extensions/no-debug-non-zts-20121212/php_pgsql.dll,
9): image not found in Unknown on line 0 PHP Warning: PHP Startup:
Unable to load dynamic library
'/usr/lib/php/extensions/no-debug-non-zts-20121212/php_soap.dll' -
dlopen(/usr/lib/php/extensions/no-debug-non-zts-20121212/php_soap.dll,
9): image not found in Unknown on line 0 PHP Warning: PHP Startup:
Unable to load dynamic library
'/usr/lib/php/extensions/no-debug-non-zts-20121212/php_sockets.dll' -
dlopen(/usr/lib/php/extensions/no-debug-non-zts-20121212/php_sockets.dll,
9): image not found in Unknown on line 0 PHP Warning: PHP Startup:
Unable to load dynamic library
'/usr/lib/php/extensions/no-debug-non-zts-20121212/php_sqlite3.dll' -
dlopen(/usr/lib/php/extensions/no-debug-non-zts-20121212/php_sqlite3.dll,
9): image not found in Unknown on line 0 [Thu Jun 02 15:28:16.615703
2016] [mpm_prefork:notice] [pid 670] AH00163: Apache/2.4.18 (Unix)
PHP/5.5.31 configured -- resuming normal operations [Thu Jun 02
15:28:16.615786 2016] [core:notice] [pid 670] AH00094: Command line:
'/usr/sbin/httpd -D FOREGROUND' [Thu Jun 02 15:28:20.869683 2016]
[:error] [pid 674] [client 127.0.0.1:49594] PHP Fatal error: Call to
undefined function pg_connect() in
/Library/WebServer/Documents/site/database.php on line 10
This happens when your pgsql extension is not installed or is not compatible with your current server build (x86/x64).
Check if you have the correct file in you ext folder: php_pgsql.so (or php_pgsql.dll if youre running on windows)
Search for the line extension=php_pdo_pgsql.dll in your php.ini. Then just add it if not found or remove the comma if its commented
Run phpinfo() and check if the extension is enabled
If you found it, its good to go

With WP_DEBUG_LOG set to true, no debug output shows in debug.log, why?

I'm trying to enable basic debug output with WordPress for a plugin I'm developing. I managed to get some so far, but failed to redirect it to wp-content/debug.log. I've been roughly following the guide by Douglas Neiner. Here's what I did:
I added this snippet of code to the end of wp-config.php:
#ini_set ('display_errors', 0);
define ('WP_DEBUG', true);
define ('WP_DEBUG_DISPLAY', false);
define ('WP_DEBUG_LOG', true);
I manually created debug.log file and made sure it's accessible by www-data user (I'm running WordPress locally, on Ubuntu 12.04):
septi#norbert:~$ sudo su www-data -c 'ls -l /usr/share/wordpress/wp-content/debug.log'
-rw-rw-r-- 1 root www-data 0 Dec 9 22:12 /usr/share/wordpress/wp-content/debug.log
septi#norbert:~$ sudo su www-data -c 'ls -l /srv/www/localhost/wp-content/debug.log'
-rw-rw-r-- 1 root www-data 0 Dec 9 22:12 /srv/www/localhost/wp-content/debug.log
septi#norbert:~$ sudo su www-data -c 'echo i can write >> /usr/share/wordpress/wp-content/debug.log'
septi#norbert:~$
Added a few supposed debug output statement inside the plugin activation hook, as well as the intentional error:
include ('i fail wp');
register_activation_hook (__FILE__, 'hello_world_activate');
function hello_world_activate()
{
error_log ('I love debug output when it works!');
}
What I expect is an error message about the missing include file in debug.log along with the "I love debug output when it works!" message, and nothing on the page. What I get is the missing include file on the page message and nothing in debug.log. The debug output message is not fully lost, however. I found it in the /var/log/apache2/error.log:
[Sun Dec 09 22:58:18 2012] [error] [client 127.0.0.1] PHP Warning: include(i fail wp): failed to open stream: No such file or directory in /usr/share/wordpress/wp-content/plugins/helloworld2085/helloworld2085.php on line 28, referer: http://localhost/wp/wp-admin/plugins.php?deactivate=true&plugin_status=all&paged=1&s=
[Sun Dec 09 22:58:18 2012] [error] [client 127.0.0.1] PHP Warning: include(): Failed opening 'i fail wp' for inclusion (include_path='.:/usr/share/php:/usr/share/pear') in /usr/share/wordpress/wp-content/plugins/helloworld2085/helloworld2085.php on line 28, referer: http://localhost/wp/wp-admin/plugins.php?deactivate=true&plugin_status=all&paged=1&s=
[Sun Dec 09 22:58:18 2012] [error] [client 127.0.0.1] I love debug output when it works!, referer: http://localhost/wp/wp-admin/plugins.php?deactivate=true&plugin_status=all&paged=1&s=
[Sun Dec 09 22:58:18 2012] [error] [client 127.0.0.1] PHP Warning: include(i fail wp): failed to open stream: No such file or directory in /usr/share/wordpress/wp-content/plugins/helloworld2085/helloworld2085.php on line 28, referer: http://localhost/wp/wp-admin/plugins.php?deactivate=true&plugin_status=all&paged=1&s=
[Sun Dec 09 22:58:18 2012] [error] [client 127.0.0.1] PHP Warning: include(): Failed opening 'i fail wp' for inclusion (include_path='.:/usr/share/php:/usr/share/pear') in /usr/share/wordpress/wp-content/plugins/helloworld2085/helloworld2085.php on line 28, referer: http://localhost/wp/wp-admin/plugins.php?deactivate=true&plugin_status=all&paged=1&s=
I suspect that the error_log() function is not the right one to use to output to debug.log, but I failed to find the right way. Oh, of course I could just hardcode the file path and append to it, but, you know...
I encountered the same problem with WordPress running in Apache 2.4 on Fedora 19. Output of error_log() was landing in /var/log/httpd/error_log instead of wp-content/debug.log. Httpd process had write permission (+775) to /var/www/html/wp-content directory, but it was unable to create the wp-content/debug.log file.
My wp-config.php debug setting was:
#ini_set(‘display_errors’,0);
define('WP_DEBUG', true);
define('WP_DEBUG_DISPLAY', false);
define('WP_DEBUG_LOG', true);
As it turned out, the real cause was SELinux. I made SELinux policy change and allowed httpd to write to wp-content with following commands. (Refer SELinux Troubleshooter to get the actual command for your installation)
semanage fcontext -a -t httpd_sys_rw_content_t '/var/www/html/wp-content'
restorecon -v '/var/www/html/wp-content'
After this debug messages start appearing in wp-content/debug.log.
the error_log() function writes to the web server's error log (e.g. /var/log/httpd/error_log); what you want is trigger_error().

Categories