Sudo a2enmod php5.6, php -v still showing php 7.01 conflict

I am trying to switch php versions, get the following answer. I tried unmounting mpm_prefork and mpm_worker so far without joy, any ideas please.

on Ubuntu 16.04

sudo a2enmod php5.6 Considering dependency mpm_prefork for php5.6: Considering conflict mpm_event for mpm_prefork: Considering conflict mpm_worker for mpm_prefork: Enabling module mpm_prefork. Considering conflict php5 for php5.6: Enabling module php5.6. To activate the new configuration, you need to run: service apache2 restart 
+14
source share
4 answers

Your teams look right. Did you restart apache before testing?

 sudo service apache2 restart 

The php5.6 PHP module created by Ondrej Suri can only be enabled:

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

I found that this setting is not compatible with MPM modules other than PREFORK. You must make sure to disable ALL other MPM modules first before enabling the php5.6 mod.

If the mod is not enabled, you may need to try disabling other MPMs.

 sudo a2dismod mpm_prefork sudo a2dismod mpm_worker sudo a2dismod mpm_event 

Then try turning on the mod again, as it should automatically turn on the correct MPM.

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

For your information, I like to put these commands in my ".bash_aliases", so they are always at hand for working with DEV.

 # Aliases - PHP alias php.info='php -i' alias php5.6='sudo a2dismod php7.0 && sudo a2dismod php7.1 && sudo a2dismod php7.2 && sudo a2dismod php7.3 && 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 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 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 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 a2enmod php7.3 && sudo update-alternatives --set php /usr/bin/php7.3 && sudo service apache2 restart' 

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

+33
source

php -v (default PHP version)

From PHP 7.0 to PHP 5.6:

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

From PHP 5.6 to PHP 7.0:

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

To configure php7 to work with your server, you need to do some configuration: 1. Make sure that you delete any traces of php / php5. Open a terminal and:

 cd /etc/apache2/mods-enabled ls -la 

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

 # this is the proper way of disabling modules sudo a2dismod php5 # run this only if the above command didn't remove the php5 sym-links sudo rm php5.load sudo rm php5.con 

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

 # this is the proper way of enabling modules sudo a2enmod php7.0 # run this only if the above command didn't create the php7.0 sym-links sudo ln -s php7.0.conf ../mods-available/php7.0.conf sudo 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.conf lrwxrwxrwx 1 root root 29 Apr 15 03:55 php7.0.load -> ../mods-available/php7.0.load 

After working with the modules, we will go to the / etc / apache 2 / conf directory. Remove all traces of php / php5 here also sudo rm

Then, if necessary, do:

 # the proper way of enabling configs sudo a2enconf php7.0-cgi sudo a2enconf php7.0-fpm # do those commands only if the above didn't work out sudo ln -s php7.0-cgi.conf ../conf-available/php7.0-cgi.conf sudo 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.conf lrwxrwxrwx 1 root root 33 Apr 21 17:01 php7.0-fpm.conf -> ../conf-available/php7.0 

And restart apache.

I just decided by following these steps.

+5
source

a2enmod is a command related to apache2 , and php -v is a command related to php itself.

when you execute the following command

 sudo a2enmod php5.6 

you are talking with apache2, not php [hey apache, enable the php5 module for me instead of php7.0], so to speak.

to enable php5 on your server you need to: -

1) delete the current php version which is 7, and then download the necessary php version.

or

2) download php 5 on the side of php 7

I think php-version would be a great starting point to do something like this.

-1
source

Source: https://habr.com/ru/post/1264829/


All Articles