When I run the PHP development server, I see all request appear twice. It could be an explanation why I am having problems validating CSRF codes (they are generated twice, so the one in the form and the one finally in the session are not the same):
[Fri Mar 20 20:29:53 2020] PHP 7.4.1 Development Server (http://0.0.0.0:8080) started
[Fri Mar 20 20:30:07 2020] 127.0.0.1:51335 Accepted
[Fri Mar 20 20:30:07 2020] 127.0.0.1:51336 Accepted
[Fri Mar 20 20:30:07 2020] 127.0.0.1:51335 [200]: GET /
[Fri Mar 20 20:30:07 2020] 127.0.0.1:51335 Closing
[Fri Mar 20 20:30:07 2020] 127.0.0.1:51336 [200]: GET /
[Fri Mar 20 20:30:07 2020] 127.0.0.1:51336 Closing
Anyone an idea why this is happening?
This is how I started the server:
php -S 0.0.0.0:8080 -t public/
I checked FPM config and changed the value of servers to start to 1 (I thought it might be fpm related), but to no avail.
Mac OS X Catalina (10.15.3), PHP 7.4.1
Extra info:
created a new directory public with 1 index.php file in it containing:
hello world
<?php
file_put_contents(__DIR__ . '/../requests.log', date('Y-m-d H:i:s') . PHP_EOL, FILE_APPEND);
Running the server, and calling the page ONCE:
user#server test % php -S 0.0.0.0:8080 -t public/
[Fri Mar 20 21:04:14 2020] PHP 7.4.1 Development Server (http://0.0.0.0:8080) started
[Fri Mar 20 21:04:16 2020] 127.0.0.1:56020 Accepted
[Fri Mar 20 21:04:16 2020] 127.0.0.1:56021 Accepted
[Fri Mar 20 21:04:17 2020] 127.0.0.1:56020 [200]: GET /
[Fri Mar 20 21:04:17 2020] 127.0.0.1:56020 Closing
[Fri Mar 20 21:04:17 2020] 127.0.0.1:56021 [200]: GET /
[Fri Mar 20 21:04:17 2020] 127.0.0.1:56021 Closing
Yields this in the log:
2020-03-20 20:06:58
2020-03-20 20:06:58
processes on the laptop:
user#laptop test % ps -ef | grep php
0 163 1 0 8:25PM ?? 0:00.13 /usr/local/opt/php/sbin/php-fpm --nodaemonize
501 331 163 0 8:25PM ?? 0:00.00 /usr/local/opt/php/sbin/php-fpm --nodaemonize
501 1326 163 0 8:37PM ?? 0:00.00 /usr/local/opt/php/sbin/php-fpm --nodaemonize
Curl 0.0.0.0:8080 as #maartendev proposed yields:
[Fri Mar 20 21:09:21 2020] PHP 7.4.1 Development Server (http://0.0.0.0:8080) started
[Fri Mar 20 21:09:24 2020] 127.0.0.1:56335 Accepted
[Fri Mar 20 21:09:24 2020] 127.0.0.1:56335 [200]: GET /
[Fri Mar 20 21:09:24 2020] 127.0.0.1:56335 Closing
Thanks
Jeroen
Related
I have installed php server on my vscode with a proper php server from php.net used at $PATH
But when I try to press
PHP Server: Serve project
I get the following error:
[Tue Oct 25 21:30:53 2022] PHP 8.1.11 Development Server (http://localhost:3000) started
[Tue Oct 25 21:34:55 2022] [::1]:62162 Accepted
[Tue Oct 25 21:34:55 2022] [::1]:62163 Accepted
[Tue Oct 25 19:34:55 2022] [404] / - No such file or directory
[Tue Oct 25 21:34:55 2022] [::1]:62163 [404]: GET / - No such file or directory
[Tue Oct 25 21:34:55 2022] [::1]:62163 Closing
[Tue Oct 25 21:36:07 2022] [::1]:62162 Closed without sending a request; it was probably just an unused speculative preconnection
[Tue Oct 25 21:36:07 2022] [::1]:62162 Closing
So I created a Laravel project and tried to boot it up,
however every time I do so it closes down again
Laravel development server started on http://localhost:8000
[Sat Jan 15 13:27:20 2022] PHP 7.4.27 Development Server (http://localhost:8000) started
[Sat Jan 15 13:27:42 2022] [::1]:55208 Accepted
[Sat Jan 15 13:27:42 2022] [::1]:55209 Accepted
[Sat Jan 15 13:27:42 2022] [::1]:55208 Closing
[Sat Jan 15 13:27:42 2022] [::1]:55209 [200]: GET /favicon.ico
[Sat Jan 15 13:27:42 2022] [::1]:55209 Closing
I tried changing the port to 9000 but that also didn't work
Laravel development server started on http://localhost:9000
[Sat Jan 15 13:30:02 2022] PHP 7.4.27 Development Server (http://localhost:9000) started
[Sat Jan 15 13:30:16 2022] [::1]:54118 Accepted
[Sat Jan 15 13:30:16 2022] [::1]:54119 Accepted
[Sat Jan 15 13:30:16 2022] [::1]:54118 Closing
[Sat Jan 15 13:30:17 2022] [::1]:54119 [200]: GET /favicon.ico
[Sat Jan 15 13:30:17 2022] [::1]:54119 Closing
[Sat Jan 15 13:30:19 2022] [::1]:54125 Accepted
[Sat Jan 15 13:30:19 2022] [::1]:54126 Accepted
[Sat Jan 15 13:30:19 2022] [::1]:54125 Closing
[Sat Jan 15 13:30:20 2022] [::1]:54126 [200]: GET /favicon.ico
[Sat Jan 15 13:30:20 2022] [::1]:54126 Closing
does anyone know what's happening here?
That is not a problem, it's working fine. By the closing in logs, it means it's closing the specific connection.
Here's a log from my laravel install
I am using php 7.4 and I am trying to built a local devserver with php-cli
I can log requests in my routing file but php-server always logs requests like;
[Fri Jun 25 12:49:59 2021] PHP 7.4.20 Development Server (http://localhost:8100) started
[Fri Jun 25 12:50:01 2021] [::1]:51057 Accepted
[Fri Jun 25 12:50:01 2021] [::1]:51058 Accepted
[Fri Jun 25 12:50:01 2021] Connection: ::1:51058 [200]: /
[Fri Jun 25 12:50:01 2021] [::1]:51058 Closing
[Fri Jun 25 12:50:01 2021] [::1]:51059 Accepted
[Fri Jun 25 12:50:01 2021] [::1]:51060 Accepted
[Fri Jun 25 12:50:01 2021] [::1]:51061 Accepted
[Fri Jun 25 12:50:01 2021] [::1]:51062 Accepted
[Fri Jun 25 12:50:01 2021] [::1]:51063 Accepted
[Fri Jun 25 12:50:01 2021] [::1]:51064 Accepted
[Fri Jun 25 12:50:01 2021] [::1]:51059 Closing
[Fri Jun 25 12:50:01 2021] [::1]:51060 Closing
[Fri Jun 25 12:50:01 2021] [::1]:51061 Closing
[Fri Jun 25 12:50:01 2021] [::1]:51062 Closing
[Fri Jun 25 12:50:01 2021] [::1]:51063 Closing
[Fri Jun 25 12:50:01 2021] [::1]:51065 Accepted
[Fri Jun 25 12:50:01 2021] [::1]:51064 Closing
[Fri Jun 25 12:50:01 2021] [::1]:51066 Accepted
[Fri Jun 25 12:50:01 2021] [::1]:51065 Closing
[Fri Jun 25 12:50:01 2021] [::1]:51067 Accepted
[Fri Jun 25 12:50:01 2021] [::1]:51066 Closing
[Fri Jun 25 12:50:01 2021] [::1]:51068 Accepted
[Fri Jun 25 12:50:01 2021] [::1]:51069 Accepted
[Fri Jun 25 12:50:01 2021] [::1]:51067 Closing
[Fri Jun 25 12:50:01 2021] [::1]:51068 Closing
[Fri Jun 25 12:50:01 2021] [::1]:51069 Closing
[Fri Jun 25 12:50:01 2021] [::1]:51070 Accepted
[Fri Jun 25 12:50:01 2021] [::1]:51071 Accepted
[Fri Jun 25 12:50:01 2021] [::1]:51070 Closing
[Fri Jun 25 12:50:01 2021] [::1]:51071 Closing
[Fri Jun 25 12:51:01 2021] [::1]:51057 Closed without sending a request; it was probably just an unused speculative preconnection
[Fri Jun 25 12:51:01 2021] [::1]:51057 Closing
The [Fri Jun 25 12:50:01 2021] Connection: ::1:51058 [200]: / part is logged by the router.
how can I close other logs? please help me.
Once I have read about starting php server in silent mode. I guess we can use -q flag to avoid request logging which comes by php-fpm.
I am starting my server with a little function like;
function start() {
exec("php -S address:port .router.php")
}
And if I want to use quiet mode I need to add -q flag in this function.
Like;
function start() {
exec("php -q -S address:port .router.php")
}
This not solves my problem. Actually this kills every error_log() function. Please find another solution.
Okay, first of all I understand and ... permit ... you all to laugh: I have a local server running php 4,4 / apache / mysql - installed with xampp distribution. Just simply haven't got the time to upgrade all the code that has been serving me for years and is still serving me well :-)
To the issue - I can't make a try/catch ... beeeecause of the old php version. I have a script that parses a dir and to a lot of things to all the files ... and after several 100 thousand files over the years without problems ... I now find that the server shuts down / browser looses connection probably because of a single file ... but for my life I can't figure out which. So thought maybe I could figure it out through the error log. But ... I didn't learn much - and thought I might ask some wise guys here if there is anything I can learn from the following from my error log - regarding maybe what function/file or whatever it is that causes the breaking...:
[Tue Feb 14 20:47:26 2017] [crit] (22)Invalid argument: unable to replace stderr with error_log
[Tue Feb 14 20:47:26 2017] [crit] (2)No such file or directory: unable to replace stderr with /dev/null
[Tue Feb 14 20:47:26 2017] [notice] Apache/2.0.54 (Win32) mod_ssl/2.0.54 OpenSSL/0.9.8 PHP/4.4.0 mod_autoindex_color configured -- resuming normal operations
[Tue Feb 14 20:47:26 2017] [notice] Server built: Jul 28 2005 18:10:37
[Tue Feb 14 20:47:26 2017] [notice] Parent: Created child process 5384
[Tue Feb 14 20:47:27 2017] [notice] Child 5384: Child process is running
[Tue Feb 14 20:47:27 2017] [notice] Child 5384: Acquired the start mutex.
[Tue Feb 14 20:47:27 2017] [notice] Child 5384: Starting 250 worker threads.
[Tue Feb 14 20:47:36 2017] [notice] Parent: child process exited with status 3221225725 -- Restarting.
[Tue Feb 14 20:47:36 2017] [crit] (22)Invalid argument: unable to replace stderr with error_log
[Tue Feb 14 20:47:36 2017] [crit] (2)No such file or directory: unable to replace stderr with /dev/null
[Tue Feb 14 20:47:36 2017] [notice] Apache/2.0.54 (Win32) mod_ssl/2.0.54 OpenSSL/0.9.8 PHP/4.4.0 mod_autoindex_color configured -- resuming normal operations
[Tue Feb 14 20:47:36 2017] [notice] Server built: Jul 28 2005 18:10:37
[Tue Feb 14 20:47:36 2017] [notice] Parent: Created child process 3136
[Tue Feb 14 20:47:36 2017] [notice] Child 3136: Child process is running
[Tue Feb 14 20:47:36 2017] [notice] Child 3136: Acquired the start mutex.
[Tue Feb 14 20:47:36 2017] [notice] Child 3136: Starting 250 worker threads.
Got it ... filesize() was failing (silent aparently) for some file(s). Ran it w/o this function and it worked. Case closed...
Edit: strange though ... filesize() suddenly fails on all files. And they are local. Subdir to the htdocs folder ... and the top level folder to this structure is set to all my users to have full control of this folder and all subfolders... weird...
I am getting the blank screen. No errors in the Apache logs, nothing.
I was thinking there may be a php syntax error and it quietly dies, but I have configured php.ini to display errors:
display_errors=On
html_errors=On
error_reporting=E_ALL | E_STRICT
display_startup_errors=On
here are relevant php configurations loaded:
display_errors On On
display_startup_errors On
enable_dl Off Off
enable_post_data_reading On On
error_append_string no value no value
error_log no value no value
error_prepend_string no value no value
error_reporting 22527
Why is there no Apache error logs? How to trace Apache execution? any help is much appreciated. Thank you
Update:
I was wrong, Apache writes log only once on restart at the time of restart at the location specified by ErrorLog in the Apache Configuration, but nothing is written afterwards even when I get the blank site. Here logs from ErrorLog:
[Tue Nov 18 17:08:20.372970 2014] [mpm_prefork:notice] [pid 1601] AH00163: Apache/2.4.7 (Ubuntu) PHP/5.5.9-1ubuntu4.4 configured -- resuming normal operations
[Tue Nov 18 17:08:20.376988 2014] [mpm_prefork:info] [pid 1601] AH00164: Server built: Jul 22 2014 14:36:39
[Tue Nov 18 17:08:20.377699 2014] [core:notice] [pid 1601] AH00094: Command line: '/usr/sbin/apache2'
[Tue Nov 18 17:19:32.301203 2014] [mpm_prefork:notice] [pid 1643] AH00163: Apache/2.4.7 (Ubuntu) PHP/5.5.9-1ubuntu4.4 configured -- resuming normal operations
[Tue Nov 18 17:19:32.313839 2014] [mpm_prefork:info] [pid 1643] AH00164: Server built: Jul 22 2014 14:36:39
[Tue Nov 18 17:19:32.314481 2014] [core:notice] [pid 1643] AH00094: Command line: '/usr/sbin/apache2'
[Tue Nov 18 17:50:22.848631 2014] [core:info] [pid 1643] AH00096: removed PID file /var/run/apache2/apache2.pid (pid=1643)
[Tue Nov 18 17:50:22.848631 2014] [mpm_prefork:notice] [pid 1643] AH00169: caught SIGTERM, shutting down
[Tue Nov 18 17:50:25.288368 2014] [mpm_prefork:notice] [pid 3313] AH00163: Apache/2.4.7 (Ubuntu) PHP/5.5.9-1ubuntu4.4 configured -- resuming normal operations
[Tue Nov 18 17:50:25.290696 2014] [mpm_prefork:info] [pid 3313] AH00164: Server built: Jul 22 2014 14:36:39
[Tue Nov 18 17:50:25.291613 2014] [core:notice] [pid 3313] AH00094: Command line: '/usr/sbin/apache2'
How to make Apache log for PHP errors or anything for that matter to be able troubleshoot issues?
It turns out this was neither Apache nor PHP error, but an application level issue where there is ErrorHandler function declared that does hide all the php errors as described here:
PHP's white screen of death
I came to conclusion to the fact that it is neither Apache nor PHP configurations by changing ErrorLevel to trace8 in virtual host settings:
LogLevel trace8
ErrorLog ${APACHE_LOG_DIR}/dev-virtual/error.log
Afterwards, I tail the logs specified in ErrorLog from command line and make requests. The logs showed:
[Tue Nov 18 18:16:37.398720 2014] [http:trace3] [pid 4054] http_filters.c(977): [client 10.88.12.0:49378] Response sent with status 200, headers:
...
[Tue Nov 18 18:16:37.399243 2014] [http:trace4] [pid 4054] http_filters.c(806): [client 10.88.12.0:49378] Content-Length: 0
...
Here, the logs shows 200 response with Content-Length:0. The 200 is good response from Apache, so its not Apache error responsible for the blank page. Seeing the Content-Lenght set to 0, made me think there is something more than PHP setup/configuration issue. It was the ErrorHandler at the Application level.