Debian set default php version
On your system, if you have installed multiple versions of PHP (eg PHP 8.1, 8.0, 7.4, 7.3, 7.2, 7.1 and 5.6). PHP 7.2 is running as default PHP for Apache and CLI. For any requirement, you need to use PHP 5.6. Then you don’t need to remove PHP 7.2. You can simply switch your PHP version to default used for Apache and command line. Show We assume you have installed multiple PHP version on your Debian system. Now you need to switch the active PHP version for CLI and Apache2. This tutorial will help you to switch between multiple PHP versions for Apache server and CLI on Debian.
We have installed PHP 8.1, PHP 7.4 and PHP 5.6 on our Debian system. You can use the same for other PHP versions by changes commands accordingly. Enable PHP 8.1 as Default VersionYou need to set PHP 8.1 as your active PHP version for CLI and Apache2 both. You can do this by disabling Apache2 modules for all other installed PHP versions and configure CLI using the update-alternatives command.
Note – The phpize8.1 and php-config8.1 command is available in php8.1-dev package. This is more useful for compiling PHP modules using pecl. Enable PHP 7.4 as Default VersionYou need to set PHP 7.4 as your active PHP version for CLI and Apache2 both. You can do this by disabling Apache2 modules for all other installed PHP versions and configure CLI using the update-alternatives command.
Note – The phpize7.4 and php-config7.4 command is available in php7.4-dev package. This is more useful for compiling PHP modules using pecl. Enable PHP 5.6 as Default VersionThe developers of PHP are no longer supporting PHP 5.6. It is strongly recommended to upgrade to higher PHP version like 7.4 or 8.1. But still you can install and Use php 5.6 on your Debian system if your application required PHP 5.6. Let’s set PHP 5.6 as your default version for CLI and Apache2 both.
Note – The phpize5.6 and php-config5.6 command is available in php5.6-dev package. This is more useful for compiling PHP modules using pecl. ConclusionIn this tutorial, you have learned about switching PHP versions on Debian system. You can change the default PHP version without uninstalling the other versions. I have installed php 5.6 and and php 7.1 on my Ubuntu 16.04 I know with Apache as my web server, I can do
When I disable php7.1 in Apache modules and enable php 5.6, Apache recognizes the change and uses php 5.6 interpreter as expected. But when I run internal php web server from the commandline:
php handles requests using php 7. So how do I switch between php 5.6 and php 7.1 in the command line ?
Akshay 5966 silver badges20 bronze badges asked Mar 6, 2017 at 6:55
1 Interactive switching mode
Manual SwitchingFrom PHP 5.6 => PHP 7.1Default PHP 5.6 is set on your system and you need to switch to PHP 7.1. Apache:
Command Line:
From PHP 7.1 => PHP 5.6Default PHP 7.1 is set on your system and you need to switch to PHP 5.6. Apache:
Command Line:
Source
PiTheNumber 21.9k17 gold badges103 silver badges173 bronze badges answered Mar 6, 2017 at 7:03
Stevie GStevie G 5,0581 gold badge9 silver badges15 bronze badges 7
should work for all ubuntu versions after 16.04 (18.04 and 20.04) This is what you should see as a response
Choose the appropriate version answered Jan 19, 2018 at 8:28
GiorgosKGiorgosK 6,6872 gold badges29 silver badges24 bronze badges 6 To list all available versions and choose from them :
Or do manually
answered May 30, 2018 at 11:25
Kamal KumarKamal Kumar 3,0421 gold badge18 silver badges15 bronze badges 1 in
DOWNGRADE
UPGRADE
check the changes:
OR
answered Mar 22, 2021 at 10:03
Pejman KheyriPejman Kheyri 2,9767 gold badges30 silver badges31 bronze badges 1 I think you should try this From php5.6 to php7.1
From php7.1 to php5.6
answered Sep 19, 2017 at 9:38
1 I actually wouldn't recommend using answered Mar 6, 2017 at 7:02
FatBoyXPCFatBoyXPC 8036 silver badges14 bronze badges 1 You can create a script to switch from versions:
exit and save make it executable: To execute the script just type That's it you can now easily switch form PHP7 to PHP 5.6!
chepe263 2,73420 silver badges38 bronze badges answered Jul 22, 2017 at 18:38
ihakozihakoz 1211 silver badge3 bronze badges 2 May be you might have an old PHP version like PHP 5.6 in your system and you installed PHP 7.2 too so thats multiple PHP in your machine. There are some applications which were developed when older PHP 5.6 was latest version, they are still live and you working on those applications, You might be working on Laravel simultaneously but Laravel requires PHP 7+ to get started. Getting the picture ? In that case you can switch between the PHP versions to suit your requirements. Switch From PHP 5.6 => PHP 7.2 Apache:-
Command Line:-
And vice-versa, Switch From PHP 7.2 => PHP 5.6 Apache:-
Command Line:-
answered Aug 18, 2019 at 6:30
1
E.g. I want to switch
answered Feb 14, 2019 at 5:12
this worked for me:-
just change the PHP version to whichever version you need I have changed it to php7.4 answered Apr 29, 2021 at 1:13
AahadAahad 4304 silver badges9 bronze badges 1 Type given command in your terminal.. For disable the selected PHP version...
It will upgrade Php version, same thing reverse if you want version downgrade, you can see it by PHP_INFO(); answered Jan 24, 2018 at 13:02
0 Switch from PHP 5.6 to PHP 7.2 using:
Switch from PHP 7.2 to PHP 5.6 using:
Omar Einea 2,4306 gold badges22 silver badges35 bronze badges answered Mar 7, 2018 at 17:48
0 You could use these open source PHP Switch Scripts, which were designed specifically for use in Ubuntu 16.04 LTS. https://github.com/rapidwebltd/php-switch-scripts There is a
answered Mar 15, 2018 at 17:03
DivineOmegaDivineOmega 3891 gold badge5 silver badges11 bronze badges 0 I made a bash script to switch between different PHP versions on Ubuntu. Hope it helps someone. Here's the script: (save it in /usr/local/bin/sphp.sh, don't forget to add +x flag with command: sudo chmod +x /usr/local/bin/sphp.sh)
answered Feb 10, 2020 at 22:42
From PHP 5.6 => PHP 7.1
for old linux versions
for more recent version
answered Sep 24, 2018 at 14:42
0 When installing laravel on Ubuntu 18.04, be default PHP 7.3.0RC3 install selected, but laravel and symfony will not install properly complaining about missin php-xml and php-zip, even though they are installed. You need to switch to php 7.1, using the instructions above or,
now, running laravel new blog, will proceed correctly answered Oct 22, 2018 at 20:36
pingle60pingle60 6567 silver badges9 bronze badges please follow the steps :
answered Jan 9, 2020 at 12:51
YashYash 1311 silver badge5 bronze badges |