Linux – Apache Start Fails due to missing mpm module

Apache2linuxmpm-preforkphpmyadmin

I originally posted this question on StackOverflow. Before it was taken down as off topic, the answer and comments were leading to MPM not being loaded

  • I tried sudo apt-get install apache-mpm-prefork but was given the error:

    E: Unable to locate package apache-mpm-prefork

Below are all the steps I took today which led to the errors I am experiencing:
– Installing phpmyadmin following this tutorial: https://www.digitalocean.com/community/tutorials/how-to-install-and-secure-phpmyadmin-on-ubuntu-16-04
– I got stuck at sudo phpenmod mcrypt and sudo phpenmod mbstring as it was giving me some error
– I then tried to diagnose this problem by creating a php file in var/www/html that simply contained <?php phpinfo(); ?>
– It was here that I saw that apache was not serving the php files as the webpage simply outputed <?php phpinfo(); ?>
– So I tried to follow this: https://www.techrepublic.com/article/how-to-fix-apache-2-not-executing-php-files/
– However this restarting was not working so I performed sudo service apache2 stop in hope that I could start again
sudo service apache2 start gives the error:

Job for apache2.service failed. See 'systemctl status apache2.service' and 'journalctl -xn' for details.

  • Okay so sudo systemctl status apache2.service i guess:

    • apache2.service – LSB: Apache2 web server
      Loaded: loaded (/etc/init.d/apache2)
      Drop-In: /lib/systemd/system/apache2.service.d
      `-forking.conf
      Active: failed (Result: exit-code) since Sun 2018-11-25 09:21:39 PST; 2min 14s ago
      Process: 16632 ExecStart=/etc/init.d/apache2 start (code=exited, status=1/FAILURE)
      Nov 25 09:21:39 XXXXXXXXXX apache2[16632]: Starting web server: apache2 failed!
      Nov 25 09:21:39 XXXXXXXXXX apache2[16632]: The apache2 configtest failed. … (warning).
      Nov 25 09:21:39 XXXXXXXXXX apache2[16632]: Output of config test was:
      Nov 25 09:21:39 XXXXXXXXXX apache2[16632]: AH00534: apache2: Configuration error: No MPM loaded.
      Nov 25 09:21:39 XXXXXXXXXX apache2[16632]: Action 'configtest' failed.
      Nov 25 09:21:39 XXXXXXXXXX apache2[16632]: The Apache error log may have more information.
      Nov 25 09:21:39 XXXXXXXXXX systemd[1]: apache2.service: control process exited, code=exited status=1
      Nov 25 09:21:39 XXXXXXXXXX systemd[1]: Failed to start LSB: Apache2 web server.
      Nov 25 09:21:39 XXXXXXXXXX systemd[1]: Unit apache2.service entered failed state.
  • I tried deleting what I changed in the config file but it still outputs the same

ANY help would be greatly appreciated; I really do not want to have to reinstall apache. Thanks.

Current Config File (without comments)

Mutex file:${APACHE_LOCK_DIR} default

PidFile ${APACHE_PID_FILE}

Timeout 300

KeepAlive On

MaxKeepAliveRequests 100

KeepAliveTimeout 5

User ${APACHE_RUN_USER}
Group ${APACHE_RUN_GROUP}

HostnameLookups Off

ErrorLog ${APACHE_LOG_DIR}/error.log

LogLevel warn

IncludeOptional mods-enabled/.load
IncludeOptional mods-enabled/
.conf

Include ports.conf

Options FollowSymLinks
AllowOverride None
Require all denied

AllowOverride None
Require all granted

Options Indexes FollowSymLinks
AllowOverride None
Require all granted

AccessFileName .htaccess

Require all denied

LogFormat "%v:%p %h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" vhost_combined

LogFormat "%h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" combined

LogFormat "%h %l %u %t \"%r\" %>s %O" common

LogFormat "%{Referer}i -> %U" referer

LogFormat "%{User-agent}i" agent

IncludeOptional conf-enabled/*.conf

IncludeOptional sites-enabled/*.conf

Best Answer

welcome to serverfault!

As of Ubuntu 16.04 server the mpm-prefork module is included in the package apache2-bin. In order to install it you have to enter

sudo apt-get install apache2-bin

After that you will have to enable the mpm_prefork module like this:

sudo a2enmod mpm_prefork

and then try again to start apache2:

sudo systemctl start apache2.service

The detailed error log is located here:

tail -n 50 /var/log/apache2/error.log

journalctl and systemctl only give very basic information.

If you should furthermore have problems with installing the php modules mcrypt and mbstring then please post the complete error messages you get.

Hope this helps!