When working with multiple PHP versions and Apache on Ubuntu 16.04, managing version switching can be a challenge, especially for the command line. Here's how to navigate this seamlessly:
For an immediate switch, utilize the following commands:
sudo update-alternatives --config php sudo update-alternatives --config phar sudo update-alternatives --config phar.phar
To manually switch between PHP versions:
sudo update-alternatives --set php /usr/bin/php7.1 sudo update-alternatives --set phar /usr/bin/phar7.1 sudo update-alternatives --set phar.phar /usr/bin/phar.phar7.1
sudo update-alternatives --set php /usr/bin/php5.6
Remember to run sudo service apache2 restart to apply changes made to the Apache configuration.
The above is the detailed content of How to Switch PHP Versions on the Command Line for Ubuntu 16.04 with Apache?. For more information, please follow other related articles on the PHP Chinese website!