How to switch php version in linux, pay attention to linux

To switch PHP version in Linux, you can use the following steps:

  1. Install multiple PHP versions

In Linux, multiple PHP versions can be installed using different ways such as using apt-get or yum to install different PHP versions. After the installation is complete, you can check the installed PHP version with the following command:

$ sudo update-alternatives --config php
  1. Switch PHP version

Switch the PHP version with the following command:

$ sudo update-alternatives --set php /usr/bin/php7.2

Among them, php7.2 is the PHP version number to be switched, which can be modified according to the actual situation.

  1. Restart the web server

After switching the PHP version, the web server needs to be restarted for the changes to take effect. For example, if you use Apache as your web server, you can restart Apache with the following command:

$ sudo systemctl restart apache2

If you use Nginx as your web server, you can restart Nginx with the following command:

$ sudo systemctl restart nginx

In general, switching PHP versions in Linux requires installing multiple PHP versions, then using the update-alternatives command to switch PHP versions, and restarting the web server for the changes to take effect.

Guess you like

Origin blog.csdn.net/zhenghaochang/article/details/130214284