Ubuntu: apache2 php not executed


When I go to pages in localhost, only php code is shown. This version:

$ php -v  PHP 7.0.10-2+deb.sury.org~xenial+1 (cli) ( NTS )  Copyright (c) 1997-2016 The PHP Group  Zend Engine v3.0.0, Copyright (c) 1998-2016 Zend Technologies      with Zend OPcache v7.0.10-2+deb.sury.org~xenial+1, Copyright (c) 1999-2016, by Zend Technologies  

I tried to do Upgrade to 16.04. php7 not working in browser but

sudo a2enmod php7.0  ERROR: Module php7.0 does not exist!  

When I click tab while

sudo a2enmod php7  

it completes to

sudo a2enmod php7.0.load.dpkg-dist  

but result is same

$ sudo a2enmod php7.0.load.dpkg-dist   ERROR: Module php7.0.load.dpkg-dist does not exist!  

I installed php like this:

sudo apt-get update  sudo apt-get remove php5-common -y  sudo apt-get purge php5-common -y  sudo apt-get install php7.0 php7.0-fpm php7.0-mysql -y  sudo apt-get --purge autoremove -y  

I did not enable fpm.

I have all these packages.

$ a2enmod php  php5.6                 php7.0.load.dpkg-dist  $ a2enmod php5.6  Considering dependency mpm_prefork for php5.6:  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 php5.6, aborting  

I delete 5.6 but it's still shown; why?


You need to choose between mpm_worker vs mpm_prefork (or mpm_event). Only one Apache MPM module. Try:

sudo a2dismod mpm_worker  sudo a2enmod mpm_prefork  sudo systemctl restart apache2.service  

Take a look at this excellent answer at Serverfault.

Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Next Post »