Apache installing and running php files

18,787

Solution 1

Running:

  1. sudo a2dismod mpm_event
  2. sudo systemctl restart apache2
  3. sudo a2enmod mpm_prefork
  4. sudo systemctl restart apache2
  5. sudo a2enmod php7.0
  6. sudo systemctl restart apache2

worked for me.

Solution 2

I had this problem too. I upgraded from Ubuntu 17.04 to Ubuntu 17.10 and then php did not work and there was no php.conf file in /etc/apache2/mods-enabled. When I tried sudo a2enmod php7.1 I was given the same error:

Considering dependency mpm_prefork for php7.0:
Considering conflict mpm_event for mpm_prefork:
ERROR: Module mpm_event is enabled - cannot proceed due to conflicts. It needs to be disabled first!
Considering conflict mpm_worker for mpm_prefork:
ERROR: Could not enable dependency mpm_prefork for php7.0, aborting

I used sudo a2dismod mpm_event and received no errors. I restarted apache2 and then used sudo a2enmod php7.1 and it worked just fine. Restarted apache2 again and now php is working again and I can see phpinfo() in my browser when I couldn't before.

Share:
18,787
james clarke
Author by

james clarke

Updated on July 21, 2022

Comments

  • james clarke
    james clarke almost 2 years

    Im having some problems with running php files on my apache server. i have installed php 7, the folder /etc/php/7.0 exists which shows it's installed. I have configured apache to run .php files, however in my /etc/apache2/mods-enabled folder there isn't a php.conf file. Any ideas about how to install it?

    (im on raspbian), apache version 2.4.25

  • Nathan Wiles
    Nathan Wiles about 6 years
    I'm getting the exact same error and I was tempted to try this same solution. I was afraid that mpm_event was a necessary module that would be a bad idea to disable. Any input there?
  • user1043568
    user1043568 over 4 years
    I had very similar problems after upgrading from Ubuntu LTS 16.04.6 to 18.04.3 and stupidly thinking the upgrade would 'just work'. I tried sudo a2dismod mpm_event which seemed to work, but apache2 then failed to restart - systemctl reported Configuration error: No MPM loaded. So maybe you are right @NathanWiles
  • user1043568
    user1043568 over 4 years
    I found that this solution worked for me if apache2 is NOT restarted after disabling the mpm_event and the php7.2 module enabled while mpm_event is disabled and then restart apache2.
  • user1043568
    user1043568 over 4 years
    * do re-enable mpm_event before restarting apache2
  • udo
    udo about 4 years
    I just ran into the same problem (upgrading from LTS 16.04.6 to 18.04.4. What worked for me: stop apache - a2dismod mpm_event - a2enmod php7.2 - start apache
  • Arsenii
    Arsenii over 2 years
    Thank you! Worked for me too. My phpPgAdmin did not work until this setup (Ubuntu 21.04).
  • Felix Jassler
    Felix Jassler over 2 years
    Minor note, only restarting apache2 at the end (and not at step 2 and 4) sufficed for me
  • NorthStarCode
    NorthStarCode almost 2 years
    Thank you! This was super annoying. I have no idea what really happened. I have a server I don't often do much on as it is just a few static sites. I'm guessing some automated updates occurred. Only thing I'd add here is to sudo reboot at the end of all of this. Once I did that it worked again.