Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

I'm trying to switch php versions, get following response. I tried dismounting mpm_prefork and mpm_worker still no 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 
like image 873
GAV Avatar asked Feb 28 '17 11:02

GAV


People also ask

How do I know if PHP is running CGI?

Open the terminal prompt and then type the following commands. Login to the remote server using the ssh command. To check PHP version, run: php –version OR php-cgi –version.

Why PHP code is printing instead of executing?

If you are running your PHP script on a Windows computer, you need to manually install PHP. If you haven't already done so, your PHP code won't execute.


1 Answers

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.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 

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_prefork sudo a2dismod mpm_worker sudo a2dismod mpm_event 

Then try to enable the mod again as it should auto enable 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 

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

# 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 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

like image 118
Adan Rehtla Avatar answered Sep 28 '22 13:09

Adan Rehtla