Apache is running a threaded MPM, but your PHP Module is not compiled to be threadsafe. You need to

After the latest tumbleweed patches install Apache2 refuse to start with the following error:

– Unit apache2.service has begun starting up.
Oct 21 16:50:34 phoenix start_apache2[2782]: [Sun Oct 21 16:50:34.062855 2018] [php7:crit] [pid 2782:tid 140715914639360] Apache is running a threaded MPM, but your PHP Module is not compiled to be threadsafe. You need to recompile PHP.
Oct 21 16:50:34 phoenix start_apache2[2782]: AH00013: Pre-configuration failed
Oct 21 16:50:34 phoenix systemd[1]: apache2.service: Main process exited, code=exited, status=1/FAILURE
Oct 21 16:50:34 phoenix systemd[1]: apache2.service: Failed with result ‘exit-code’.
Oct 21 16:50:34 phoenix systemd[1]: Failed to start The Apache Webserver.
– Subject: Unit apache2.service has failed
– Defined-By: systemd
– Support: https://lists.freedesktop.org/mailman/listinfo/systemd-devel

– Unit apache2.service has failed.

– The result is RESULT.

After searching a bit, I see this issue is old so I do not know why is resurfacing and past fixes don’t seem to work.

Any idea?

Is this on a clean install?
Output of


a2enmod -l

Could you be more elaborate?

EDIT: You may need php7-fpm

This might even be better. IIRC I solved the issue like this on a customer’s server.

This is what I get:


a2enmod -l
authz_host actions alias auth_basic authz_user authz_groupfile authn_file autoindex cgi dir include log_config mime negotiation setenvif status userdir asis imagemap ssl reqtimeout authn_core version socache_shmcb authz_core php7

This is a clean install, but a couple of years old, so zypper dup has been ran several hundred times…

How? BTW php7-fpm is there.



a2enmod -d php7


This removes the mod_php7 module and the web server is able to start. However as you can guess now no php pages will work, so my question is:

Where do I get a version of php7 compiled with threadsafe? Do they even test these things before releasing them? I understand Tumbleweed is not meant to be used in production, but the coupling of Apache and PHP nowadays seems to be a common thing and it surprises me this was not properly tested…>:(

The following is one place where MTM is described, AFAIK openSUSE deploys as “prefork.”

So,
I guess the question might be what kind of website (particularly load" is being run, and if you’re enabled or modified apache2 to be running anything out of the ordinary.
Then, the question is if as you seem to describe the error is thrown when attempting to start apache2 or whether the error is thrown when the website is under load.

I’ve only ever run into being threadsafe as a coding technique so as the error suggests can only be addressed before or at compilation.
Once compiled, I don’t know that the End User typically can do anything to modify the characteristic.
This suggests to me…

  • You probably need to submit your error with a very detailed description (including answers to my questions) to https://bugzilla.opensuse.org on the chance that the PHP7 module may be compiled in a way that supports MTM better than it does now. Remember, your bug report has to be sufficiently detailed so that someone else can follow your steps and replicate the error you see.
  • It may be that you require an Apache or at least modules which are compiled differently, either a suggestion may be made by whoever the bugzilla assignes the issue to, or you may find an answer with a bit of research.

Good Luck,
TSU

There is nothing out of the ordinary about my websites. Nothing has been compiled or altered and there are no modules or packages that are not coming from the standard Tumbleweed distribution. The Apache2 is what comes with tumbleweed, and so is the php7, the mod_php7, and any other packages that are used by apache or any other application on that server that may and may not have an impact on how apache runs.

This was working just fine until a zypper dup upgraded the apache2. After that, at startup it pops the error on the log I did show earlier in this thread. So my assumption is the following:

Apache was modified (by whoever maintains it) to check for the PHP7 module to be compiled with threadsafe. Since apparently, the left hand does not know what the right hand is doing, the php7 module was not re-compiled (by whoever maintain it) with threadsafe to reflect that change, hence the error.

I am going to report the bug as you suggested and for the sake of my sanity, I will rebuild this machine with LEAP 15, because I am totally fed up with the very poor level of QA of this distribution, since this is just another of a long list of things that have been broken and then much later on fixed over the past 2 years.

I think that everyone would generally agree that unless you have a special reason to do so, all Production deployments should be on LEAP and not TW.

TSU

Your conclusions may be too fast:

erlangen:~ # systemctl status apache2.service 
● apache2.service - The Apache Webserver
   Loaded: loaded (/usr/lib/systemd/system/apache2.service; enabled; vendor preset: disabled)
   Active: active (running) since Sat 2018-11-03 13:20:49 CET; 1 day 6h ago
 Main PID: 986 (httpd-prefork)
   Status: "Total requests: 0; Current requests/sec: 0; Current traffic:   0 B/sec"
    Tasks: 11
   CGroup: /system.slice/apache2.service
           ├─  986 /usr/sbin/httpd-prefork -DSYSCONFIG -C PidFile /var/run/httpd.pid -C Include /etc/apache2/sysconfig.d//loadmodule.conf -C Include /etc/apache2/sysconfig.d//global.conf -f /etc/apache2/httpd.conf -c Include /etc/apache>
           ├─ 1081 /usr/sbin/httpd-prefork -DSYSCONFIG -C PidFile /var/run/httpd.pid -C Include /etc/apache2/sysconfig.d//loadmodule.conf -C Include /etc/apache2/sysconfig.d//global.conf -f /etc/apache2/httpd.conf -c Include /etc/apache>
           ├─ 1083 /usr/sbin/httpd-prefork -DSYSCONFIG -C PidFile /var/run/httpd.pid -C Include /etc/apache2/sysconfig.d//loadmodule.conf -C Include /etc/apache2/sysconfig.d//global.conf -f /etc/apache2/httpd.conf -c Include /etc/apache>
           ├─ 1084 /usr/sbin/httpd-prefork -DSYSCONFIG -C PidFile /var/run/httpd.pid -C Include /etc/apache2/sysconfig.d//loadmodule.conf -C Include /etc/apache2/sysconfig.d//global.conf -f /etc/apache2/httpd.conf -c Include /etc/apache>
           ├─ 1085 /usr/sbin/httpd-prefork -DSYSCONFIG -C PidFile /var/run/httpd.pid -C Include /etc/apache2/sysconfig.d//loadmodule.conf -C Include /etc/apache2/sysconfig.d//global.conf -f /etc/apache2/httpd.conf -c Include /etc/apache>
           ├─15779 /usr/sbin/httpd-prefork -DSYSCONFIG -C PidFile /var/run/httpd.pid -C Include /etc/apache2/sysconfig.d//loadmodule.conf -C Include /etc/apache2/sysconfig.d//global.conf -f /etc/apache2/httpd.conf -c Include /etc/apache>
           ├─15810 /usr/sbin/httpd-prefork -DSYSCONFIG -C PidFile /var/run/httpd.pid -C Include /etc/apache2/sysconfig.d//loadmodule.conf -C Include /etc/apache2/sysconfig.d//global.conf -f /etc/apache2/httpd.conf -c Include /etc/apache>
           ├─15811 /usr/sbin/httpd-prefork -DSYSCONFIG -C PidFile /var/run/httpd.pid -C Include /etc/apache2/sysconfig.d//loadmodule.conf -C Include /etc/apache2/sysconfig.d//global.conf -f /etc/apache2/httpd.conf -c Include /etc/apache>
           ├─15812 /usr/sbin/httpd-prefork -DSYSCONFIG -C PidFile /var/run/httpd.pid -C Include /etc/apache2/sysconfig.d//loadmodule.conf -C Include /etc/apache2/sysconfig.d//global.conf -f /etc/apache2/httpd.conf -c Include /etc/apache>
           ├─15813 /usr/sbin/httpd-prefork -DSYSCONFIG -C PidFile /var/run/httpd.pid -C Include /etc/apache2/sysconfig.d//loadmodule.conf -C Include /etc/apache2/sysconfig.d//global.conf -f /etc/apache2/httpd.conf -c Include /etc/apache>
           └─18270 /usr/sbin/httpd-prefork -DSYSCONFIG -C PidFile /var/run/httpd.pid -C Include /etc/apache2/sysconfig.d//loadmodule.conf -C Include /etc/apache2/sysconfig.d//global.conf -f /etc/apache2/httpd.conf -c Include /etc/apache>

Nov 03 13:20:49 erlangen systemd[1]: Starting The Apache Webserver...
Nov 03 13:20:49 erlangen systemd[1]: Started The Apache Webserver.
erlangen:~ # 

From info page:

System Linux erlangen.fritz.box 4.18.15-1-default #1 SMP PREEMPT Thu Oct 18 08:56:17 UTC 2018 (5a53676) x86_64
Server API Apache 2.0 Handler
Virtual Directory Support disabled
Configuration File (php.ini) Path /etc/php7/apache2
Loaded Configuration File /etc/php7/apache2/php.ini
Scan this dir for additional .ini files /etc/php7/conf.d
Additional .ini files parsed /etc/php7/conf.d/ctype.ini, /etc/php7/conf.d/dom.ini, /etc/php7/conf.d/iconv.ini, /etc/php7/conf.d/json.ini, /etc/php7/conf.d/openssl.ini, /etc/php7/conf.d/pdo.ini, /etc/php7/conf.d/pdo_sqlite.ini, /etc/php7/conf.d/sqlite3.ini, /etc/php7/conf.d/tokenizer.ini, /etc/php7/conf.d/xmlreader.ini, /etc/php7/conf.d/xmlwriter.ini, /etc/php7/conf.d/zip.ini
PHP API 20170718
PHP Extension 20170718
Zend Extension 320170718
Zend Extension Build API320170718,NTS
PHP Extension Build API20170718,NTS
Debug Build no
Thread Safety disabled
Zend Signal Handling enabled
Zend Memory Manager enabled
Zend Multibyte Support disabled
IPv6 Support enabled
DTrace Support disabled
Registered PHP Streams php, file, glob, data, http, ftp, https, ftps, zip
Registered Stream Socket Transports tcp, udp, unix, udg, ssl, tls, tlsv1.0, tlsv1.1, tlsv1.2
Registered Stream Filters string.rot13, string.toupper, string.tolower, string.strip_tags, convert., consumed, dechunk, convert.iconv.

[HR][/HR] Configuration

apache2handler

Apache Version Apache
Apache API Version 20120211
Server Administrator [no address given]
Hostname:Port erlangen.fritz.box:0
User/Group wwwrun(30)/8
Max Requests Per Child: 10000 - Keep Alive: on - Max Per Connection: 100
Timeouts Connection: 60 - Keep-Alive: 15
Virtual Server
No
Server Root /srv/www
Loaded Modules core mod_so http_core prefork mod_unixd mod_systemd mod_actions mod_alias mod_auth_basic mod_authn_file mod_authz_host mod_authz_groupfile mod_authz_core mod_authz_user mod_autoindex mod_cgi mod_dir mod_env mod_expires mod_include mod_log_config mod_mime mod_negotiation mod_setenvif mod_ssl mod_socache_shmcb mod_userdir mod_reqtimeout mod_authn_core mod_php7

Apache Environment

That is all very interesting but it does not really help. It may work on your server, but it does not on mine. And posting the bug on Bugzilla did not help either as it was promptly removed as “apparently” they already knew that was an issue and claim they are working on it. That was over a week ago, but still, after more patches being releases, it still does give the same error at startup, and using the search option on Bugzilla I am unable to find any reference to this bug, which makes things even more interesting…

Question: is your server up to the latest patches?

That is all very interesting but it does not really help. It may work on your server, but it does not on mine. And posting the bug on Bugzilla did not help either as it was promptly removed as “apparently” they already knew that was an issue and claim they are working on it. That was over a week ago, but still, after more patches being releases, it still does give the same error at startup, and using the search option on Bugzilla I am unable to find any reference to this bug, which makes things even more interesting…

Question: is your server up to the latest patches?

Yes:

erlangen:~ # zypper info --type product openSUSE
Loading repository data...
Reading installed packages...


Information for product openSUSE:
---------------------------------
Repository          : Haupt-Repository (OSS)                            
Name                : openSUSE                                          
Version             : 20181103-0                                        
Arch                : x86_64                                            
Vendor              : openSUSE                                          
Flavor              : ftp                                               
Is Base             : Yes                                               
Installed           : Yes                                               
Status              : up-to-date                                        
Update Repositories : ---                                               
CPE Name            : cpe:2.3:o:opensuse:opensuse:20181103:*:*:*:*:*:*:*
Short Name          : openSUSE                                          
Summary             : openSUSE Tumbleweed                               
Description         :                                                   
    openSUSE Tumbleweed is the rolling distribution by the openSUSE.org project.

erlangen:~ # 

Apache has:


erlangen:~ # zypper if apache2 apache2-doc apache2-mod_dnssd apache2-mod_php7 apache2-prefork apache2-utils
Loading repository data...
Reading installed packages...


Information for package apache2:
--------------------------------
Repository     : Haupt-Repository (OSS)           
Name           : apache2                          
Version        : 2.4.37-1.1                       
Arch           : x86_64                           
Vendor         : openSUSE                         
Installed Size : 4.6 MiB                          
Installed      : Yes                              
Status         : up-to-date                       
Source package : apache2-2.4.37-1.1.src           
Summary        : The Apache Web Server Version 2.4
Description    :                                  
    This version of httpd is a major release of the 2.4 stable branch,
    and represents the best available version of Apache HTTP Server.
    New features include Loadable MPMs, major improvements to OCSP support,
    mod_lua, Dynamic Reverse Proxy configuration, Improved Authentication/
    Authorization, FastCGI Proxy, New Expression Parser, and a Small Object
    Caching API.

     See /usr/share/doc/packages/apache2/, http://httpd.apache.org/, and
    http://httpd.apache.org/docs-2.4/upgrading.html.


Information for package apache2-doc:
------------------------------------
Repository     : Haupt-Repository (OSS)          
Name           : apache2-doc                     
Version        : 2.4.37-1.1                      
Arch           : noarch                          
Vendor         : openSUSE                        
Installed Size : 21.1 MiB                        
Installed      : Yes                             
Status         : up-to-date                      
Source package : apache2-2.4.37-1.1.src          
Summary        : Additional Package Documentation
Description    :                                 
    This package contains optional documentation provided in addition to
    this package's base documentation.


Information for package apache2-mod_dnssd:
------------------------------------------
Repository     : Haupt-Repository (OSS)                        
Name           : apache2-mod_dnssd                             
Version        : 0.6-28.4                                      
Arch           : x86_64                                        
Vendor         : openSUSE                                      
Installed Size : 42.3 KiB                                      
Installed      : Yes (automatically)                           
Status         : up-to-date                                    
Source package : apache2-mod_dnssd-0.6-28.4.src                
Summary        : Apache2 module for Zeroconf support via DNS-SD
Description    :                                               
    mod_dnssd is an Apache HTTPD module which adds Zeroconf support via
    DNS-SD using Avahi.


Information for package apache2-mod_php7:
-----------------------------------------
Repository     : Haupt-Repository (OSS)                  
Name           : apache2-mod_php7                        
Version        : 7.2.11-1.3                              
Arch           : x86_64                                  
Vendor         : openSUSE                                
Installed Size : 9.1 MiB                                 
Installed      : Yes                                     
Status         : up-to-date                              
Source package : php7-7.2.11-1.3.src                     
Summary        : PHP7 module for the Apache 2.x webserver
Description    :                                         
    PHP is a server-side, cross-platform HTML embedded scripting language.
    If you are completely new to PHP and want to get some idea of how it
    works, have a look at the Introductory tutorial. Once you get beyond
    that, have a look at the example archive sites and some of the other
    resources available in the links section.

    Please refer to /usr/share/doc/packages/php7/README.SUSE for
    information on how to load the module into the Apache webserver.


Information for package apache2-prefork:
----------------------------------------
Repository     : Haupt-Repository (OSS)                          
Name           : apache2-prefork                                 
Version        : 2.4.37-1.1                                      
Arch           : x86_64                                          
Vendor         : openSUSE                                        
Installed Size : 641.1 KiB                                       
Installed      : Yes                                             
Status         : up-to-date                                      
Source package : apache2-2.4.37-1.1.src                          
Summary        : Apache 2 "prefork" MPM (Multi-Processing Module)
Description    :                                                 
    "prefork" MPM (Multi-Processing Module)

    This MPM is basically the one that Apache 1.3.x used. It warrants the
    maximum stability because each server runs in its own process. If a
    process dies it will not affect other servers.


Information for package apache2-utils:
--------------------------------------
Repository     : Haupt-Repository (OSS)
Name           : apache2-utils         
Version        : 2.4.37-1.1            
Arch           : x86_64                
Vendor         : openSUSE              
Installed Size : 238.8 KiB             
Installed      : Yes                   
Status         : up-to-date            
Source package : apache2-2.4.37-1.1.src
Summary        : Apache 2 utilities    
Description    :                       
    Utilities provided by the Apache 2 Web Server project which are useful
    to administrators of web servers in general.

erlangen:~ # 

Started a few minutes ago:

erlangen:~ # systemctl status apache2.service 
● apache2.service - The Apache Webserver
   Loaded: loaded (/usr/lib/systemd/system/apache2.service; enabled; vendor preset: disabled)
   Active: active (running) since Tue 2018-11-06 17:35:44 CET; 9min ago
 Main PID: 1933 (httpd-prefork)
   Status: "Total requests: 0; Current requests/sec: 0; Current traffic:   0 B/sec"
    Tasks: 6
   CGroup: /system.slice/apache2.service
           ├─1933 /usr/sbin/httpd-prefork -DSYSCONFIG -C PidFile /var/run/httpd.pid -C Include /etc/apache2/sysconfig.d//loadmodule.conf -C Include /etc/apache2/sysconfig.d//global.conf -f /etc/apache2/httpd.conf -c Include /etc/apache2>
           ├─1963 /usr/sbin/httpd-prefork -DSYSCONFIG -C PidFile /var/run/httpd.pid -C Include /etc/apache2/sysconfig.d//loadmodule.conf -C Include /etc/apache2/sysconfig.d//global.conf -f /etc/apache2/httpd.conf -c Include /etc/apache2>
           ├─1964 /usr/sbin/httpd-prefork -DSYSCONFIG -C PidFile /var/run/httpd.pid -C Include /etc/apache2/sysconfig.d//loadmodule.conf -C Include /etc/apache2/sysconfig.d//global.conf -f /etc/apache2/httpd.conf -c Include /etc/apache2>
           ├─1965 /usr/sbin/httpd-prefork -DSYSCONFIG -C PidFile /var/run/httpd.pid -C Include /etc/apache2/sysconfig.d//loadmodule.conf -C Include /etc/apache2/sysconfig.d//global.conf -f /etc/apache2/httpd.conf -c Include /etc/apache2>
           ├─1967 /usr/sbin/httpd-prefork -DSYSCONFIG -C PidFile /var/run/httpd.pid -C Include /etc/apache2/sysconfig.d//loadmodule.conf -C Include /etc/apache2/sysconfig.d//global.conf -f /etc/apache2/httpd.conf -c Include /etc/apache2>
           └─1968 /usr/sbin/httpd-prefork -DSYSCONFIG -C PidFile /var/run/httpd.pid -C Include /etc/apache2/sysconfig.d//loadmodule.conf -C Include /etc/apache2/sysconfig.d//global.conf -f /etc/apache2/httpd.conf -c Include /etc/apache2>

Nov 06 17:35:44 erlangen systemd[1]: Starting The Apache Webserver...
Nov 06 17:35:44 erlangen systemd[1]: Started The Apache Webserver.
erlangen:~ # 

A FYI -
I came across the following which you <may> want to investigate…

https://doc.opensuse.org/documentation/leap/reference/html/book.opensuse.reference/cha.apache2.html#sec.apache2.modules.building_modules

Instructions for compiling modules on the fly.
Of course requires source for the module so you’ll need the source for your PHP module.

On the other hand,
If it’s currently being looked at, I’d assume the people looking at the problem now would be more knowledgeable about compiling threadsafe than your or me.

TSU

Ok so looking at your apache2 status you are running it in prefork mode, so I dug a bit and found out that Tumbleweed default mode is worker and not prefork (as the documentation instead suggests the opposite)

Looking at /etc/sysconfig/apache2

When the entry:

APACHE_MPM=“”

The description says that it will pick up one of the installed mpm modules. I guess since I had installed both worker and prefork it opted for worker.

Now that I have changed APACHE_MPM=“prefork” and added mpm_prefork to the loadmodules.conf it is working again.

What beats me is that this was working before and why the hell they change the default behaviour of the web server for no apparent gain, since one can force one or the other anyway? I am assuming originally was running in prefork and when the update was installed it switched to worker…

I am still not impressed with the Tumbleweed developers, even less about their attitude when I reported this as a bug. But that is another story…

Thanks for posting your configuration, it really helped…

You found something I looked at but was unable to find… that TW defaulted to “worker” instead of prefork.
So, am curious where you “dug deeper” and found this?

TIA,
TSU

1 Like

This issue seems to be common to other Linux “flavours” (like Ubuntu or Plesk for example). I googled several articles saying the same thing: disable worker, enable prefork. So I used my power of deduction to do the same on Tumblewood and it worked.

Prefork and worker are two type of MPM apache provides. Both have their merits and demerits.
By default mpm is prefork which is thread safe.
Prefork MPM uses multiple child processes with one thread each and each process handles one connection at a time.
Worker MPM uses multiple child processes with many threads each. Each thread handles one connection at a time.

https://stackoverflow.com/questions/13883646/apache-prefork-vs-worker-mpm