Earlier this evening I decided to turn up the PHP error logging on some of my vhosts. I tried simple things like adjusting the timezone. As well as turning on E_STRICT logging and saving these errors to a specific log file unique to that vhost.
Unfortunately; I kept receiving a 500 Internal Server Error. After examining the actually Apache error logs I noticed the following message:
.htaccess: php_value not allowed here
The following is an example of the sorts of directives I was attempting to set in the .htaccess file of the specific vhost.
php_value date.timezone "America/New_York" php_flag log_errors On php_value error_reporting "E_STRICT" php_flag display_errors off php_value error_log '../logs/php_error.log'
At this point I realized that the source of my troubles was the AllowOverride directive in my httpd.conf which is set to None. Obviously I changed this to All and restarted Apache. The 500 error persisted. So I changed the AllowOverride back to None and looked at the vhost config file. I set this to All and restart Apache again.
This time we achieved success. My original settings were ‘AllowOverride AuthConfig FileInfo’ which is fairly restrictive and I am of the mindset that you should only turn on what you need when you need it. I felt that leaving everything open like that is probably not optimal so I did some more digging.
Finally after several more adjustments and restarts I have settled on a new setting as follows;
AllowOverride Options FileInfo AuthConfig
This change allows me to adjust the php flags and values as need in the .htaccess while avoiding the 500 Internal Server Error. Most importantly it lets me set up php_error logging on each vhost so that I can track errors with having them display in the production environment.
I hope that by posting this it will help some one else expedite the changes required to correct the problem rather than spending wasted time reading useless StackOverFlow posts.
Related articles
Alexa says
Thanks a lot! I was looking for a solution where I did not “leave everything open”, and this was perfect.