📜  linux set alternatives etc Alternatives - PHP (1)

📅  最后修改于: 2023-12-03 15:32:40.582000             🧑  作者: Mango

Linux Set Alternatives

Alternatives is a system tool in Linux that allows you to manage multiple versions of software installed on your system. This is useful when you have multiple versions of a software installed and you need to switch between them.

One of the software that can be managed by Alternatives is PHP. In this guide, we will show you how to set alternatives for PHP in Linux.

Check current PHP version

Before we set alternatives for PHP, we need to check the current version of PHP installed on the system. We can do this by running the following command in the terminal:

php -v

This command will display the version of PHP installed on your system.

Install multiple versions of PHP

If you want to install multiple versions of PHP on your system, you can do so by using a package management system like apt or yum. For example, if you want to install PHP version 7.2 and 7.3, you can use the following commands:

sudo apt-get install php7.2
sudo apt-get install php7.3
Set alternatives for PHP

Once you have installed multiple versions of PHP on your system, you can set alternatives for PHP to switch between versions. To set alternatives for PHP, you can use the following command:

sudo update-alternatives --config php

This command will display a list of available PHP versions installed on your system. You can select the version you want to use by entering the number associated with that version.

Conclusion

In this guide, we showed you how to set alternatives for PHP in Linux. With Alternatives, you can easily manage and switch between multiple versions of PHP installed on your system.