12

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

5
  • 1
    Did you install mod_php? Try sudo apt-get install libapache2-mod-php7.0, then sudo a2enmod php7.0, then restart apache with sudo apache2ctl restart.
    – Ian Drake
    Oct 30, 2017 at 21:32
  • running sudo e2enmod php7.0 returns the 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" Oct 30, 2017 at 21:37
  • I think you can just run sudo a2dismod mpm_event to disable that conflicting module, then try running sudo a2enmod php7.0 again.
    – Ian Drake
    Oct 30, 2017 at 21:44
  • 1
    disabling mpm_event seems to stop my apache from working, it wont let me start the apache service if it is disabled Oct 30, 2017 at 21:59
  • You might have to manually enable mpm_prefork with sudo a2enmod mpm_prefork. That should allow the apache service to start up.
    – Ian Drake
    Oct 30, 2017 at 22:18

3 Answers 3

53

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.

3
  • 1
    Thank you! Worked for me too. My phpPgAdmin did not work until this setup (Ubuntu 21.04).
    – Arsenii
    Aug 18, 2021 at 20:48
  • 1
    Minor note, only restarting apache2 at the end (and not at step 2 and 4) sufficed for me Oct 11, 2021 at 22:47
  • 2
    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. Jun 19, 2022 at 17:22
10

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.

5
  • 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? Apr 7, 2018 at 22:03
  • 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 Jan 6, 2020 at 10:02
  • 1
    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. Jan 6, 2020 at 10:32
  • 1
    * do re-enable mpm_event before restarting apache2 Jan 6, 2020 at 10:39
  • 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
    – udo
    Mar 19, 2020 at 14:26
0

There has to be a php.conf file in etc/apache2 otherwise it wont work you haven't installed it correctly.You might have not configured your installation together with mysql and apache.Read the install file in php source code folder and then recompile with apache and mysql so you can have Lamp in your Ubuntu installation for example :

./configure --with-mysql --with-apache2 and so on 

make

make install

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.