40

When I try to run a2enmod php7.0 - I got message "Considering conflict php5 for php7.0".

After restarting apache - apache can't start.

How to solve this?

Maybe some already enabled modules links to php5?

Params: Ubuntu Wily, Apache 2.4.18, PHP 7.0.4 (works only cli)

Zanshin13
  • 980
  • 4
  • 19
  • 39
YanDatsiuk
  • 1,885
  • 2
  • 18
  • 30

3 Answers3

79

First, disable the php5 module:

a2dismod php5

then, enable the php7 module:

a2enmod php7.0

Next, reload/restart the Apache service:

service apache2 restart

Update 2018-09-04

wrt the comment, you need to specify exact installed version.

hjpotter92
  • 78,589
  • 36
  • 144
  • 183
  • Yes - it is good solution. And I tried it... But I haven't php5 module, because I deleted all packages with php5. And after "a2enmod php7.0" I can't start my apache. – YanDatsiuk Mar 14 '16 at 14:38
  • 2
    @YanDatsyuk run this command `sudo apachectl -t`. See if there's any syntax error. – hjpotter92 Mar 14 '16 at 16:37
  • Make sure, you are giving the correct version number while enabling php. ie `a2enmod php7.1` for php version 7.1 and `a2enmod php7.2` for php version 7.2. Otherwise, you may end up in error like `Cannot load /usr/lib/apache2/modules/libphp7.0.so` and won't be able to restart apache server. – Jacob Nelson Sep 03 '18 at 18:48
  • There used to be just 7.0 2 years ago @JacobNelson I'll update the reply wrt your comment. :) thanks – hjpotter92 Sep 03 '18 at 20:19
  • After all, you can also do: `systemctl restart apache2` – robe007 May 18 '20 at 22:19
35

I found the solution on the following thread : https://askubuntu.com/questions/760907/upgrade-to-16-04-php7-not-working-in-browser

Im my case not only the php wasn't working but phpmyadmin aswell i did step by step like that

sudo apt install php libapache2-mod-php
sudo apt install php7.0-mbstring
sudo a2dismod mpm_event
sudo a2enmod mpm_prefork
service apache2 restart

And then to:

gksu gedit /etc/apache2/apache2.conf

In the last line I do add Include /etc/phpmyadmin/apache.conf

That make a deal with all problems

Maciej

If it solves your problem, up vote this solution in the original post.

Community
  • 1
  • 1
Adrien Horgnies
  • 691
  • 4
  • 11
  • 2
    I've launched also a `sudo a2enmod php7.0` and then restarted apache – IlGala Jan 30 '17 at 11:59
  • Banging my head against the wall for days now. This FIXED my "Apache is running a threaded MPM, but your PHP Module is not compiled to be threadsafe" error. – Heres2u Nov 21 '19 at 21:56
1

For Windows users looking for solution of same problem. I just repleced

LoadModule php7_module "C:/xampp/php/php7apache2_4.dll"

in my /conf/extra/httpв-xampp.conf

vladkras
  • 16,483
  • 4
  • 45
  • 55
  • Yes, I know it can break some other modules dependencies (though I didn't experience them), but if you decided to vote down, please, describe your problem in comments for further consideration – vladkras Oct 15 '18 at 15:21