How to Fix “Can’t Enable MPM Prefork with Apache 2.4 on Ubuntu 14.04”


4 views

When working with Apache 2.4 on Ubuntu 14.04, you might encounter issues when trying to switch between Multi-Processing Modules (MPM). The error occurs because Apache only allows one MPM module to be active at a time.

First, verify which MPM module is currently active:

apache2ctl -M | grep mpm

To switch from mpm_event to mpm_prefork:

sudo a2dismod mpm_event
sudo a2enmod mpm_prefork
sudo service apache2 restart

Ensure you have the necessary packages installed:

sudo apt-get install apache2-prefork-dev apache2-mpm-prefork

When compiling PHP from source, use the correct apxs path:

./configure --with-apxs2=/usr/bin/apxs2 --with-mysql --with-curl
make
sudo make install

If you see "Module mpm_prefork_module does not exist", it means:

  1. The package isn't properly installed
  2. The module file is missing
  3. There's a path configuration issue

Verify the module exists:

ls /usr/lib/apache2/modules/mod_mpm_prefork.so

After making changes, always verify your configuration:

sudo apache2ctl configtest
sudo service apache2 restart

When setting up PHP 5.4 with Apache 2.4 on Ubuntu 14.04, many developers encounter MPM module conflicts that prevent proper prefork configuration. The key error messages typically include:

module mpm_event_module is already loaded, skipping
ERROR: Module mpm_prefork_module does not exist!

Apache 2.4 on Ubuntu defaults to mpm_event_module, which conflicts with PHP's requirement for prefork. You'll need to:

  1. Disable event module
  2. Enable prefork module
  3. Properly configure PHP

First, check currently enabled modules:

apache2ctl -M | grep mpm

Then disable the conflicting module:

sudo a2dismod mpm_event

Now enable prefork (note the correct module name):

sudo a2enmod mpm_prefork

The proper way to install PHP 5.4 from source:

./configure --with-apxs2=/usr/bin/apxs2 \
--with-mysql \
--with-curl \
--enable-mbstring \
--with-zlib

make
sudo make install

Instead of editing apache2.conf directly, create a proper PHP config file:

sudo nano /etc/apache2/mods-available/php5.conf

Add these contents:

<FilesMatch "\.ph(p[345]?|t|tml)$">
    SetHandler application/x-httpd-php
</FilesMatch>
<FilesMatch "\.phps$">
    SetHandler application/x-httpd-php-source
</FilesMatch>

After making all changes, verify your setup:

sudo apache2ctl configtest
sudo systemctl restart apache2

Create a test PHP file:

sudo nano /var/www/html/info.php

With content:

<?php phpinfo(); ?>

If you still encounter issues:

  • Check Apache error logs: tail -f /var/log/apache2/error.log
  • Verify module paths: ls /usr/lib/apache2/modules/
  • Ensure proper permissions on PHP files