Skip to content
Advertisement

Apache 2.4, .htaccess and php directive error

I have upgraded to Centos 8, and find myself having to cope with the changes in Apache 2.4. I’ve started to get it working, but I have a perplexing error with a simple setting in .htaccess:

#   .htaccess
#   PHP Time Zone
    php_value date.timezone Australia/Melbourne

I get the dreaded error:

The server encountered an internal error or misconfiguration and was unable to complete your request.

There’s no point contacting the server administrator because that’s me.

The error_log file has this:

Invalid command ‘php_value’, perhaps misspelled or defined by a module not included in the server configuration

This has always worked in the past on Apache 2.4, and also works when I use Apache 2.4 on XAMPP. So obviously there is something in some other configuration, possibly in httpd.conf which causes it to crash.

What setting am I missing, or should I change?

Update

As answered by @Chi.C.J.RajeevaLochana below, the solution lies in using the correct MPM. In my case, in the file 00-mpm-conf:

  • Comment out

    LoadModule mpm_event_module modules/mod_mpm_event.so

  • Uncomment

    LoadModule mpm_prefork_module modules/mod_mpm_prefork.so

For further information, see:

Advertisement

Answer

When you are using either mod_mpm_event or mod_mpm_worker instead of mod_mpm_prefork, you will not be able to use the PHP Module. This is because mod_mpm_event and mod_mpm_worker are threaded modules. And the PHP module is not thread safe.

If you are unsure how to do this, check out Soufiane ELH’s tutorial which should be above/below this answer.

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement