2

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:

Manngo
  • 14,066
  • 10
  • 88
  • 110

2 Answers2

3

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.

Example person
  • 3,198
  • 3
  • 18
  • 45
  • When I build httpd-2.4.46 I do not have the either `mod_mpm_event.so` or `mod_mpm_prefork.so` in the modules folder. Does this mean the build went wrong? Supposed to build from `prefork.c` in the server folder correct? – Brian Wiley Dec 15 '20 at 00:28
  • @Brian Wiley, What was your configure command? – Example person Dec 15 '20 at 03:14
  • https://stackoverflow.com/questions/65219046/how-to-install-apache-2-4-46-from-source-on-ubuntu/65219058#65219058, see this answer, it might help you in someway – Example person Dec 15 '20 at 05:03
  • So I tried this first `./configure --prefix=/usr/local --with-module=mpm-prefork --with-mpm=prefork` which should have worked based on the documentation [here](http://httpd.apache.org/docs/current/install.html) and configure -h but then it had issue making 'mpm-prefork' (supposed to remove mod_ and replace underscores with -). But it does work if you just remove `--with-module=mpm-prefork`. So this should work for anybody else `./configure --with-mpm=prefork` – Brian Wiley Dec 15 '20 at 07:34
  • 1
    I am sure `--with-module=mpm-prefork` is invalid... Good job you fixed your issue. – Example person Dec 15 '20 at 07:37
  • Enable all mods to "reallyall" could work also probably. I saw that option in the help also – Brian Wiley Dec 15 '20 at 07:38
  • I usually always use `sudo ./configure --prefix=/usr/local/apache2 --enable-mods-shared="reallyall" --enable-mpms-shared="all"` which I have mentioned on the link I sent two hours ago. This gives me the flexibility to edit and disable any modules any time. – Example person Dec 15 '20 at 07:39
1

the event module is enabled by default on centos 8 .. to check wich module you have :

#sudo httpd -V | grep -i mpm

if you have enent module enabled, disable it, and enable the prefork module:

  • Edit the /etc/httpd/conf.modules.d/00-mpm.conf file
  • Comment out the line for the event module
  • uncomment the line for the prefork module
  • restart apache

check again the module enabled by apache and you will find prefork :

# sudo httpd -V | grep -i mpm
Server MPM:     prefork
Soufiane ELH
  • 562
  • 5
  • 8