The infamous Apache error "Parent: child process exited with status 3221225477" - php

I've read some questions and responses related to the infamous Apache error
Apache error [notice] Parent: child process exited with status 3221225477 — Restarting
But nothing could help me so far. What I'm asking to you is if I used a Linux version, could the script crash Apache for the same reason?
By the way if anyone has any suggestion for my case here is Apache's error.log
[Mon Aug 08 14:31:44 2011] [notice] Parent: child process exited with status 3221225477 -- Restarting.
[Mon Aug 08 14:31:44 2011] [crit] (22)Invalid argument: unable to replace stderr with error_log
[Mon Aug 08 14:31:44 2011] [crit] (2)No such file or directory: unable to replace stderr with /dev/null
[Mon Aug 08 14:31:44 2011] [notice] Apache/2.2.3 (Win32) DAV/2 mod_ssl/2.2.3 OpenSSL/0.9.8c mod_autoindex_color PHP/5.1.6 configured -- resuming normal operations
[Mon Aug 08 14:31:44 2011] [notice] Server built: Aug 13 2006 19:16:43
[Mon Aug 08 14:31:44 2011] [notice] Parent: Created child process 4364
[Mon Aug 08 14:31:45 2011] [notice] Child 4364: Child process is running
[Mon Aug 08 14:31:45 2011] [notice] Child 4364: Acquired the start mutex.
[Mon Aug 08 14:31:45 2011] [notice] Child 4364: Starting 250 worker threads.
[Mon Aug 08 14:31:45 2011] [notice] Child 4364: Starting thread to listen on port 8088.
[Mon Aug 08 14:31:45 2011] [notice] Child 4364: Starting thread to listen on port 8086.
I can't understand why moving dlls around the filesystem solve most problems and all the suggestions in the related questions which were about moving libraries didn't work for me.
I'm running an old XAMPP release with PHP 5.1.6 (XAMPP for Windows 1.5.4) and working with Doctrine ORM (Yes, I'm aware that Doctrine requires PHP 5.2.3+).

I've just had this same problem on a WAMP installation. I tracked it down to a bit of my own rubbish code. I had a method calling itself.
Here's an example:-
<?php
echo "Welcome to stupid class!";
class stupid_class {
public $example_data;
function stupid_function($Data) {
self::stupid_function($Data);
if($Data=="Hello") return true;
else die("Incorrect data passed through.".$Data."<br />");
}
}
$myClass = new stupid_class();
$myvalue = $myClass->stupid_function("Hello");
?>
I know this is hardly an ideal example of great code, (it was actually a typo) but I would have expected there to be some error thrown before getting a 'connection was reset' message.
So I guess an answer would be, check through all your methods to make sure that you're not calling one infinitely.
I hope this helps someone to figure out why this is happening in PHP, Apache.
Cheers
Tee

In my case it was the php extension APC (php_apc.dll, 3.1.10-5.4-vc9-x86, threadsafe), which caused the error.
I used XAMPP 1.8.2 with PHP 5.4.19 and Apache 2.4.4
Since it could be caused by another extension as well, it might be a good starting point to restore the original php.ini from the xampp distribution. If this one works well, try to change it line by line to your desired configuration (starting with the extension list).

Related

PHP XAMPP log interpretation - server shutting down / connecton lost from browser

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...

Apache - Parent: Received shutdown signal

I tried to set CakePHP in localhost. It works great except when the page goes to the one that need to read the database.
It just shows:
Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator, webmaster#dummy-host.example.com and inform them of the time the error occurred, and anything you might have done that may have caused the error.
More information about this error may be available in the server error log.
Here's the error log:
[Thu May 09 12:07:44 2013] [notice] Parent: Received shutdown signal -- Shutting down the server.
[Thu May 09 12:07:44 2013] [notice] Child 844: Exit event signaled. Child process is ending.
[Thu May 09 12:07:45 2013] [notice] Child 844: Released the start mutex
[Thu May 09 12:08:00 2013] [notice] Child 844: All worker threads have exited.
[Thu May 09 12:08:00 2013] [notice] Child 844: Child process is exiting
[Thu May 09 12:08:00 2013] [notice] Parent: Child process exited successfully.
Warning: DocumentRoot [C:/apache2/docs/dummy-host.example.com] does not exist
Warning: DocumentRoot [C:/apache2/docs/dummy-host2.example.com] does not exist
[Thu May 09 12:08:01 2013] [notice] Apache/2.2.22 (Win64) PHP/5.3.13 configured -- resuming normal operations
[Thu May 09 12:08:01 2013] [notice] Server built: May 13 2012 19:41:17
[Thu May 09 12:08:01 2013] [notice] Parent: Created child process 2504
Warning: DocumentRoot [C:/apache2/docs/dummy-host.example.com] does not exist
Warning: DocumentRoot [C:/apache2/docs/dummy-host2.example.com] does not exist
Warning: DocumentRoot [C:/apache2/docs/dummy-host.example.com] does not exist
Warning: DocumentRoot [C:/apache2/docs/dummy-host2.example.com] does not exist
[Thu May 09 12:08:01 2013] [notice] Child 2504: Child process is running
[Thu May 09 12:08:01 2013] [notice] Child 2504: Acquired the start mutex.
[Thu May 09 12:08:01 2013] [notice] Child 2504: Starting 64 worker threads.
[Thu May 09 12:08:01 2013] [notice] Child 2504: Starting thread to listen on port 80.
Most answer that I found in Google is asking us to edit C:\WINDOWS\System32\drivers\etc\hosts to only have one 127.0.0.1 localhost. Mine has been like that since the very beginning.
By the way, in the error log, it says C:/apache2/.... But in my C folder, that directory doesn't exist.
I use WAMP Server if that matter.
Any solution?
Thank you
I change my server from WAMP to XAMPP and now it works okay. Not sure what cause it.

APACHE Crashing: Parent: child process exited with status 3221225477 -- Restarting

My following setup is Xampp 1.7.7 and here is the info for everything in that package:
- Apache/2.2.21 (Win32) mod_ssl/2.2.21 OpenSSL/1.0.0e PHP/5.3.8 mod_perl/2.0.4 Perl/v5.10.1
I'm running the server on Windows XP SP3 32 bit OS, 4 gigs of ram, Quad Core.
The issue I'm having in my apache error log file is:
[Tue Apr 24 15:55:55 2012] [notice] Parent: child process exited with status 3221225477 -- Restarting.
[Tue Apr 24 15:55:57 2012] [notice] Digest: generating secret for digest authentication ...
[Tue Apr 24 15:55:57 2012] [notice] Digest: done
[Tue Apr 24 15:55:59 2012] [notice] Apache/2.2.21 (Win32) mod_ssl/2.2.21 OpenSSL/1.0.0e PHP/5.3.8 mod_perl/2.0.4 Perl/v5.10.1 configured -- resuming normal operations
[Tue Apr 24 15:55:59 2012] [notice] Server built: Sep 10 2011 11:34:11
[Tue Apr 24 15:55:59 2012] [notice] Parent: Created child process 776
[Tue Apr 24 15:56:00 2012] [notice] Disabled use of AcceptEx() WinSock2 API
[Tue Apr 24 15:56:01 2012] [notice] Digest: generating secret for digest authentication ...
[Tue Apr 24 15:56:01 2012] [notice] Digest: done
[Tue Apr 24 15:56:02 2012] [notice] Child 776: Child process is running
[Tue Apr 24 15:56:02 2012] [notice] Child 776: Acquired the start mutex.
[Tue Apr 24 15:56:02 2012] [notice] Child 776: Starting 350 worker threads.
[Tue Apr 24 15:56:02 2012] [notice] Child 776: Listening on port 443.
[Tue Apr 24 15:56:02 2012] [notice] Child 776: Listening on port 80.
This seems to occur sporadically throughout the day and I even tried using Win32DisableEx, EnableIMAP Off and EnableSendFile Off in the apache conf file. I also tried copying the libmysql.dll file to the system32 and apache/bin folders with no avail.
If anyone knows other reasons this error for the child process exiting and causing apache to crash, info would be greatly appreciated. If any additional log files are needed please let me know.
Tks,
Shane.
The error code 3221225477 is 0xC0000005 in hex, which on Windows is:
#define STATUS_ACCESS_VIOLATION ((NTSTATUS)0xC0000005L)
Access violation is Windows' version of "segmentation fault", which simply said means that the program tried to access a memory which is not allocated. This can happen for a lot of different reasons, but mostly (if not always) is a bug in the program.
Now, my guess for your situation, is that there is either a bug in PHP or in one of PHP's extensions or in Perl or some Perl application. Apache itself is usually very stable, but if you use some unusual extension, it might be the cause, too.
I would suggest updating all your configuration to latest versions. If you want to find the source of the problem for sure, run Apache inside a debugger, like Visual Studio or OllyDbg. When the exception (access violation) happens, it will stop execution (instead of restarting) and you'll see in which module it is.
Also take a look in the access log, if there is a suspicious request with the same timestamp as the error. But it may happen that the crash happens before the request is saved in the logfile.

Performance issue with php/apache/windows. Connection reset

I'm having a rather big problem with a site performance. It's a php site on Apache on Windows Server 2003.
Web site is basically crashing with 'connection was reset' or 'cannot load web page' quite often. httpd process in Windows takes about 100mb on normal traffic, having about 1gb of memory still free
This is first time I host a php site on Windows (WIndows was requirement in this case) and I'm not sure what are my options
Thanks
Apache log is displaying the following (sorry for pasting it like that, couldn't do it as 'code block' from some reason. This surely doesn't look right. Any ideas what could be going on?
[Tue Nov 08 16:44:43 2011] [notice] Parent: Received restart signal --
Restarting the server.
[Tue Nov 08 16:44:43 2011] [notice] Child 2072: Exit event signaled.
Child process is ending.
httpd.exe: Could not reliably determine the server's fully qualified
domain name, using 192.168.67.1 for ServerName
[Tue Nov 08 16:44:44 2011] [notice] Apache/2.2.17 (Win32)
mod_ssl/2.2.17 OpenSSL/0.9.8o PHP/5.2.17 configured -- resuming normal
operations
[Tue Nov 08 16:44:44 2011] [notice] Server built: Oct 18 2010 01:58:12
[Tue Nov 08 16:44:44 2011] [notice] Parent: Created child process 7692
httpd.exe: Could not reliably determine the server's fully qualified
domain name, using 192.168.67.1 for ServerName
httpd.exe: Could not reliably determine the server's fully qualified
domain name, using 192.168.67.1 for ServerName
[Tue Nov 08 16:44:44 2011] [notice] Child 2072: Released the start
mutex
[Tue Nov 08 16:44:44 2011] [notice] Child 7692: Child process is
running
[Tue Nov 08 16:44:44 2011] [notice] Child 7692: Acquired the start
mutex.
[Tue Nov 08 16:44:44 2011] [notice] Child 7692: Starting 1000 worker
threads.
[Tue Nov 08 16:44:44 2011] [notice] Child 7692: Starting thread to
listen on port 2090.
[Tue Nov 08 16:44:44 2011] [notice] Child 7692: Starting thread to
listen on port 8011.
[Tue Nov 08 16:44:44 2011] [notice] Child 7692: Starting thread to
listen on port 8080.
[Tue Nov 08 16:44:44 2011] [notice] Child 7692: Starting thread to
listen on port 443.
[Tue Nov 08 16:44:44 2011] [notice] Child 7692: Starting thread to
listen on port 80.
[Tue Nov 08 16:44:45 2011] [notice] Parent: child process exited with
status 0 -- Restarting.
httpd.exe: Could not reliably determine the server's fully qualified
domain name, using 192.168.67.1 for ServerName
Windows event viewer is throwing the following
Error - VsJITDebugger. An unhandled win32 exception occurred in httpd.exe [4416]. Just-In-Time debugging this exception failed with the following error: Debugger could not be started because no user is logged on.
Can anyone help with this?
That '[notice] Parent: child process exited with status 0 -- Restarting' is describing the issue here. Tho it describes it in vary vague way. Server is basically restarting on it's own every few minutes. I took the site down with a holding page and the error and restart ddidn't occure. I added an html page and bombed it with combinations of requests using AB. It would always crash at requests close to number of ThreadsPerChild specified in mpm config, which I have set to 1000. Each crash followed with an error
apr_socket_recv: An existing connection was forcibly closed by the remote host.
(730054)
That error only displays when benchmarking. Nothing like that appears in apache log. As soon I switch the site back live, it starts to crash every few minutes. The site generates about 100 requests per page and is also using 2-3 ajax calls per page (while loading)
I spent hours searching the web for possible solutions. Found nothing that fits. I'm completely out of options. I'm not even experienced running apache on windows as during 5 years I work in the business I never had to run php sites on Windows. I haven't seen such error on linux neither
There are two places where you should have a look:
Regular Apache logs, located in the logs folder inside Apache installation.
Windows event viewer, located in Windows control panel
In particular, the second one will log Apache crashes and will possibly reveal additional details.

PHP's configuration setting 'error_log' is not working

What am I doing wrong here?
I have error_log set in the .ini file along with error_reporting = E_ALL | E_STRICT.
What else am I missing? This usually gave it to me. I want this set in the .ini file and not in my scripts.
Another interesting thing that is happening is that when I purposefully try and throw an error in one of my scripts, Apache restarts over and over again.
This is my event log after one error. Look at the timestamp.
Wed Nov 04 19:34:23 2009] [notice] Apache/2.2.14 (Win32) PHP/5.3.0 configured -- resuming normal operations
[Wed Nov 04 19:34:23 2009] [notice] Server built: Sep 28 2009 22:41:08
[Wed Nov 04 19:34:23 2009] [notice] Parent: Created child process 1700
[Wed Nov 04 19:34:23 2009] [notice] Child 1700: Child process is running
[Wed Nov 04 19:34:23 2009] [notice] Child 3008: Released the start mutex
[Wed Nov 04 19:34:23 2009] [notice] Child 1700: Acquired the start mutex.
[Wed Nov 04 19:34:23 2009] [notice] Child 1700: Starting 64 worker threads.
[Wed Nov 04 19:34:23 2009] [notice] Child 1700: Starting thread to listen on port 80.
[Wed Nov 04 19:34:24 2009] [notice] Child 3008: All worker threads have exited.
[Wed Nov 04 19:34:24 2009] [notice] Child 3008: Child process is exiting
[Wed Nov 04 19:34:53 2009] [notice] Parent: child process exited with status 128 -- Restarting.
[Wed Nov 04 19:34:53 2009] [notice] Apache/2.2.14 (Win32) PHP/5.3.0 configured -- resuming normal operations
[Wed Nov 04 19:34:53 2009] [notice] Server built: Sep 28 2009 22:41:08
[Wed Nov 04 19:34:53 2009] [notice] Parent: Created child process 3656
[Wed Nov 04 19:34:53 2009] [notice] Child 3656: Child process is running
[Wed Nov 04 19:34:53 2009] [notice] Child 3656: Acquired the start mutex.
[Wed Nov 04 19:34:53 2009] [notice] Child 3656: Starting 64 worker threads.
[Wed Nov 04 19:34:53 2009] [notice] Child 3656: Starting thread to listen on port 80.
[Wed Nov 04 19:34:53 2009] [notice] Parent: child process exited with status 128 -- Restarting.
[Wed Nov 04 19:34:54 2009] [notice] Apache/2.2.14 (Win32) PHP/5.3.0 configured -- resuming normal operations
[Wed Nov 04 19:34:54 2009] [notice] Server built: Sep 28 2009 22:41:08
[Wed Nov 04 19:34:54 2009] [notice] Parent: Created child process 3980
[Wed Nov 04 19:34:54 2009] [notice] Child 3980: Child process is running
[Wed Nov 04 19:34:54 2009] [notice] Child 3980: Acquired the start mutex.
[Wed Nov 04 19:34:54 2009] [notice] Child 3980: Starting 64 worker threads.
[Wed Nov 04 19:34:54 2009] [notice] Child 3980: Starting thread to listen on port 80.
[Wed Nov 04 19:34:54 2009] [notice] Parent: child process exited with status 128 -- Restarting.
[Wed Nov 04 19:34:54 2009] [notice] Apache/2.2.14 (Win32) PHP/5.3.0 configured -- resuming normal operations
[Wed Nov 04 19:34:54 2009] [notice] Server built: Sep 28 2009 22:41:08
[Wed Nov 04 19:34:54 2009] [notice] Parent: Created child process 1600
[Wed Nov 04 19:34:54 2009] [notice] Child 1600: Child process is running
[Wed Nov 04 19:34:54 2009] [notice] Child 1600: Acquired the start mutex.
[Wed Nov 04 19:34:54 2009] [notice] Child 1600: Starting 64 worker threads.
[Wed Nov 04 19:34:54 2009] [notice] Child 1600: Starting thread to listen on port 80.
[Wed Nov 04 19:34:55 2009] [notice] Parent: child process exited with status 128 -- Restarting.
[Wed Nov 04 19:34:55 2009] [notice] Apache/2.2.14 (Win32) PHP/5.3.0 configured -- resuming normal operations
[Wed Nov 04 19:34:55 2009] [notice] Server built: Sep 28 2009 22:41:08
[Wed Nov 04 19:34:55 2009] [notice] Parent: Created child process 1068
[Wed Nov 04 19:34:55 2009] [notice] Child 1068: Child process is running
[Wed Nov 04 19:34:55 2009] [notice] Child 1068: Acquired the start mutex.
[Wed Nov 04 19:34:55 2009] [notice] Child 1068: Starting 64 worker threads.
[Wed Nov 04 19:34:55 2009] [notice] Child 1068: Starting thread to listen on port 80.
[Wed Nov 04 19:34:55 2009] [notice] Parent: child process exited with status 128 -- Restarting.
[Wed Nov 04 19:34:55 2009] [notice] Apache/2.2.14 (Win32) PHP/5.3.0 configured -- resuming normal operations
[Wed Nov 04 19:34:55 2009] [notice] Server built: Sep 28 2009 22:41:08
[Wed Nov 04 19:34:55 2009] [notice] Parent: Created child process 3220
[Wed Nov 04 19:34:56 2009] [notice] Child 3220: Child process is running
[Wed Nov 04 19:34:56 2009] [notice] Child 3220: Acquired the start mutex.
[Wed Nov 04 19:34:56 2009] [notice] Child 3220: Starting 64 worker threads.
[Wed Nov 04 19:34:56 2009] [notice] Child 3220: Starting thread to listen on port 80.
This has been asked 1000 times and I have browsed through the different posts before posting this, but I have not found an answer. As long as I have been programming with PHP, this have always been a nightmare to get working.
Check PHP-FPM is not explicitly setting error_log:
Make sure the file /etc/php-fpm.d/www.conf does not contain php_admin_value settings for error_log. Search for the following and comment them out using a semi-colon:
; NOTE: If these are set, ini_set('error_log', 'path') will have no effect
; inside your php code, and this will be forced to be the value always.
; php_admin_value[error_log] = /var/log/php-fpm/www-error.log
; php_admin_flag[log_errors] = on
Then restart php-fpm:
systemctl restart php-fpm
Check Apache .htaccess files are not setting the error_log value using
php_admin_value settings in the Apache configuration files cannot be overridden, so make sure you don’t have any php_admin_value for the error_log setting in the Apache configuration files. Also check for php_value settings just in case.
PHP Website - How to change configuration settings
Flimm's Troubleshooting Guide
Here is my troubleshooting guide to error_log() calls not working.
Look at your server's configuration to find out where the default error log file is.
This depends on which server you're using. To get you started, have
a look at Apache's ErrorLog option if you're using Apache or
Nginx's error_log option if you're using Nginx. Make sure it
is set to a file. If you're using a tool like Valet, note that it's
using server software like Nginx behind the scenes.
Check the permissions of your server's error log file. On Unix-like systems, it should be writeable by the correct user and group, and the permissions of the parent directory and all its ancestors need to be correct as well. Use chmod and chown.
Check the configuration of PHP in the .ini files. Specifically, check for log_errors = On and error_reporting = E_ALL | E_STRICT and error_log = /tmp/example/php_errors.log (see docs for log_errors, error_reporting and error_log configuration settings). To find the .ini file, look at the output of phpinfo();. If error_log is not set, by default it goes to the error log for the server, mentioned in the previous steps. If error_log is set to a file, it should already exist and be writeable, just like in previous steps. Remember to restart the server after configuration changes.
Check that PHP's settings aren't being changed by server configuration. Your server's configuration (even .htaccess) can change PHP configuration settings. In Apache, this is done using php_admin_value and php_admin_flag (docs). For instance, you may find in your .htaccess file this line: php_admin_flag[log_errors] = off. Remember to restart the server after configuration changes. At this point, you should be able to create a test file test.php with the contents <?php error_log("test");, restart your server, and open the URL in your browser, and you should be able to see test in your error log (either the server's, or the one specified by error_log = ). But keep reading.
Check that PHP's settings aren't being changed at run-time. The log_errors option can be changed at runtime by running ini_set('log_errors', 1);, and so can the other configuration options error_reporting and error_log. Also note there is a special error_reporting() PHP function which changes the configuration at run-time. Search your code-base for any invocations of ini_set or error_reporting. WordPress for example does run these depending on the value of WP_DEBUG.
Other things to look at: You may be having permission issues in SELinux (see this answer).
You also need to set log_errors = On in file php.ini.
In case anyone else is having trouble getting their local development environment to log errors, here's what fixed it for me:
On Windows, error_log must be set to the complete path to the log for error_log() to work (error_log = c:\apache\php_errors.log). However, if error_log = php_errors.log with no path, php will still be able to log startup errors such as
PHP Startup: Unable to load dynamic library 'ext\php_mysqli.dll' - The specified module could not be found
The problem I ran into was that the error log I had designated was write-protected. All my .htaccess settings were correct, but PHP just couldn't write to the error log, because it didn't have any permissions. This fixed it right up for me:
chmod 777 watermellon-app-errors.log
Obviously, you're going to want to change the .log part to whatever file you're using for a log.
If the error_log directive is set, the file will be used for recording PHP errors. When it is not set, errors will be logged to the Apache log. Take a look at error_log.
The error_log file and the directory it's in must be writable by the user that Apache is running under. If the file isn't being created, it's probably due to a permissions issue.
I don't know for sure why Apache would be crashing on you, but I'm guessing it's a permissions issue of some sort.
I don't understand why, but the error log is now working. Here is what I did.
I gave up and commented back out the error_log directive and closed the ini file. I ran the script with the parse error to see if Apache would still crash and I got the PHP error in the log file. This is freaky, because the ini file no longer has error_log enabled and my script is not using ini_set().
In my case, on a CentOS development server, after a full yum update, the permission on /var/log/http was changed to 700 and the user to 'root', so the user 'apache' wasn't able to enter or write into it.
It was still able to write into the existing file /var/log/httpd/error.log, but it wasn't able to create a new file, as I use date-suffixed log files.
Issuing the command
chown apache /var/log/httpd
solved the problem.
If you are using Fedora, SELinux (enabled by default) will prevent Apache / httpd from appending errors to your log file even when your file is specified in file php.ini and its containing directory has all permissions allowed.
You can see if this is happening by looking at your system log file in /var/log/messages
The ideal solution is to configure SELinux to allow access to the log file.
The quicker solution is to disable SELinux in /etc/selinux/config by setting SELINUX to disabled.
You'll need to reboot your system after doing this for the change to take effect.
For me, manually creating the file, /var/log/php_error.log, solved the issue:
In file php.ini, configure log to file
log_errors = On
error_log = /var/log/php_error.log
Restart Apache
sudo systemctl restart apache2
Create the log file, for example:
sudo touch /var/log/php_error.log
Give the correct rights (owner must be Apache)
sudo chown www-data:root /var/log/php_error.log
(And if not already set)
sudo chmod 0644 /var/log/php_error.log
Test this way, for example:
sudo vim /var/www/.../index.php
<html>
<body>
PHP file:
<?php
echo "Hello, World!";
trigger_error("User error in PHP", E_USER_ERROR);
?>
</body>
</html>
Check the error is written
sudo less /var/log/php_error.log
For further debugging:
phpinfo();
It shows the current error_log setting, next to the error_log value in phpinfo() and can be useful when a vhost isn't logging.
I ended up here after that setting got overridden from file php.ini and the vhost. I ended up logging to syslog.
As bradym said, check whether you have write permissions to the directory where you PHP error log is located for the Apache user. If you created a log file with written permissions it's not enough; the directory should have them too.
I had the same issue and fixed it by doing this:
chmod 0777 -R /var/log/apache2
apachectl restart
I think PHP runs as user www-data while access to /var/log/apache2 is limited to root. So, this fixes it.
The error_log = "C:\php\Log\error.log" line was not working for me either. The solution for me was that you shouldn't create the error.log yourself, because PHP will do it for you. See the PHP message board. I'm using PHP 5.2 on a Windows Server 2008 server.
This did the trick for me.
setsebool -P httpd_unified 1
Please note, this would be the preferred method below to try first:
semanage fcontext -a -t httpd_sys_rw_content_t 'errorLogNameHere.error.log
restorecon -v 'errorLogNameHere.error.log'
This answer was derived from the logs from executing this command line:
journalctl -xe
Further information on the system I was running on:
PHP 7.0 and CentOS 7
I am not sure if it's not obvious, but the issue was Apache's configuration to writing files. I did try chmod 777, chmod a+w on the logging directory, but this didn't work for me.

Categories