Easy bash-script to switch PHP versions on linux

Every webdeveloper needs to swith PHP version on his/her development setup. While you can do that manually every single time by using sudo a2dismod and sudo a2enmod and then restarting your server, it’s much easier and faster to write a quick bash script to do that for you.

Swith PHP version on the terminal

When working with the terminal, I am used to having shortcurts set up to make my work a bit faster an a bit more fun.

That is why I have written this tiny bash script to let me change my PHP version right from the terminal without having to disable and enable the PHP versions and then restart the server manually.

Feel free to just copy and paste it and place it as an executable in your /usr/bin  or just /bin  directory on your server.

I call this file switchphp , and it resides in my /bin  directory.

So copy the script above, save it to your /bin/switchphp  file and make it executable by using sudo chmod +x /bin/switchphp .

You can now switch your PHP versions by using the following commands:

switchphp 7  or switchphp 5.6

Note that you must have both PHP versions installed, of course. :)

Easy bash-script to switch PHP versions on linux
Wie bewertests Du diesen Beitrag? Rate this postplease.

Kommentar verfassen