Using Linux system with multiple PHP versions installed by apt? Now you may looking for a easy way to switch in between multiple php versions without executing multiple commands manually, Well we can use S-PHP for that.
How to install on Linux :-
- Clone S-PHP repository to your local machine using command.
git clone https://github.com/vinugawade/s-php.git
- Move shell script file to `/usr/local/bin` location or use command.
sudo mv `/location/of/file` /usr/local/bin
- Allow everyone to execute the script using command.
sudo chmod +x `/location/of/file`
- OR
sudo chmod 0755 `/location/of/file`
- Add `usr/local/bin` to your `$PATH`. if you use the `Bash` shell, Then you can do this by using command.
export PATH=$PATH:/usr/local/bin
- OR
export PATH=$PATH:`/location/of/file`
This will set the variable name:- potentially in a file called `~/.bash_profile`, `~/.bashrc` and `~/.profile`. The difference between these files is (primarily) when they get read by the shell. If you're not sure where to put it, Then `~/.bashrc` is the good choice.
Note:- You may need to restart your shell for this to take effect.
How to use the script :-
s-php 7.4
OR
s-php 8.0
This will change your PHP execution file of the system as well as the apache server's PHP config to use a different version.
Mac User?
You can check this sphp repository as an alternative script for Mac OS.