sudo a2enmod php5.6, php -v still shows php 7.01 conflict sudo a2enmod php5.6, php -v still shows php 7.01 conflict php php

sudo a2enmod php5.6, php -v still shows php 7.01 conflict


Your commands looks correct. Did you restart apache before testing?

sudo service apache2 restart

The PHP module php5.6 made by Ondřej Surý can only be enabled by:

sudo a2dismod php7.0sudo a2dismod php7.1sudo a2dismod php7.2sudo a2dismod php7.3sudo a2dismod php7.4sudo a2enmod php5.6sudo update-alternatives --set php /usr/bin/php5.6sudo service apache2 restart

I have found that this setup isn't compatible with any other MPM modules other that PREFORK. You have to make sure you disable ALL other MPM modules first, before enabling the php5.6 mod.

If the mod won't enable you might have to try to disable the other MPM's.

sudo a2dismod mpm_preforksudo a2dismod mpm_workersudo a2dismod mpm_event

Then try to enable the mod again as it should auto enable the correct MPM.

$ sudo a2enmod php5.6Considering dependency mpm_prefork for php5.6:Considering conflict mpm_event for mpm_prefork:Considering conflict mpm_worker for mpm_prefork:Module mpm_prefork already enabledConsidering conflict php5 for php5.6:Enabling module php5.6.To activate the new configuration, you need to run:  service apache2 restart

FYI, I like to put these commands into my '.bash_aliases' so I always have them handy for DEV work.

# Aliases - PHPalias php.info='php -i'alias php5.6='sudo a2dismod php7.0 && sudo a2dismod php7.1 && sudo a2dismod php7.2 && sudo a2dismod php7.3 && sudo a2dismod php7.4 && sudo a2enmod php5.6 && sudo update-alternatives --set php /usr/bin/php5.6 && sudo service apache2 restart'alias php7.0='sudo a2dismod php5.6 && sudo a2dismod php7.1 && sudo a2dismod php7.2 && sudo a2dismod php7.3 && sudo a2dismod php7.4 && sudo a2enmod php7.0 && sudo update-alternatives --set php /usr/bin/php7.0 && sudo service apache2 restart'alias php7.1='sudo a2dismod php5.6 && sudo a2dismod php7.0 && sudo a2dismod php7.2 && sudo a2dismod php7.3 && sudo a2dismod php7.4 && sudo a2enmod php7.1 && sudo update-alternatives --set php /usr/bin/php7.1 && sudo service apache2 restart'alias php7.2='sudo a2dismod php5.6 && sudo a2dismod php7.0 && sudo a2dismod php7.1 && sudo a2dismod php7.3 && sudo a2dismod php7.4 && sudo a2enmod php7.2 && sudo update-alternatives --set php /usr/bin/php7.2 && sudo service apache2 restart'alias php7.3='sudo a2dismod php5.6 && sudo a2dismod php7.0 && sudo a2dismod php7.1 && sudo a2dismod php7.2 && sudo a2dismod php7.4 && sudo a2enmod php7.3 && sudo update-alternatives --set php /usr/bin/php7.3 && sudo service apache2 restart'alias php7.4='sudo a2dismod php5.6 && sudo a2dismod php7.0 && sudo a2dismod php7.1 && sudo a2dismod php7.2 && sudo a2dismod php7.3 && sudo a2enmod php7.4 && sudo update-alternatives --set php /usr/bin/php7.4 && sudo service apache2 restart'

GIST: https://gist.github.com/djravine/376e81a018ba2b980750a5578deb3935


php -v (default PHP version)

From PHP 7.0 to PHP 5.6:

sudo a2dismod php7.0sudo a2enmod php5.6sudo update-alternatives --set php /usr/bin/php5.6sudo service apache2 restart

From PHP 5.6 to PHP 7.0:

sudo a2dismod php5.6sudo a2enmod php7.0sudo update-alternatives --set php /usr/bin/php7.0sudo service apache2 restart


To configure php7 to run with your server you need to do some configuration:1. Make sure you remove any traces of php/php5Open a terminal and:

cd /etc/apache2/mods-enabledls -la

The output should not contain any php5.conf or php5.load, but if it does, do the following:

# this is the proper way of disabling modulessudo a2dismod php5# run this only if the above command didn't remove the php5 sym-linkssudo rm php5.loadsudo rm php5.con

Now add the php7.0.conf and php7.0.load instead:

# this is the proper way of enabling modulessudo a2enmod php7.0# run this only if the above command didn't create the php7.0 sym-linkssudo ln -s php7.0.conf ../mods-available/php7.0.confsudo ln -s php7.0.load ../mods-available/php7.0.load

The output of ls -la php* should look like this:

lrwxrwxrwx 1 root root 29 Apr 15 03:55 php7.0.conf -> ../mods-available/php7.0.conflrwxrwxrwx 1 root root 29 Apr 15 03:55 php7.0.load -> ../mods-available/php7.0.load

After dealing with the modules we now come to the /etc/apache2/conf-enabled directory. Remove any traces of php/php5 here as well by sudo rm

Then, if needed do:

# the proper way of enabling configssudo a2enconf php7.0-cgisudo a2enconf php7.0-fpm# do those commands only if the above didn't work outsudo ln -s php7.0-cgi.conf ../conf-available/php7.0-cgi.confsudo ln -s php7.0-fpm.conf ../conf-available/php7.0-fpm.conf

The output of ls -la php* should look like this:

lrwxrwxrwx 1 root root 33 Apr 21 17:00 php7.0-cgi.conf -> ../conf-available/php7.0-cgi.conflrwxrwxrwx 1 root root 33 Apr 21 17:01 php7.0-fpm.conf -> ../conf-available/php7.0

And restart apache.

I have just resolved by following these steps.