How to Switch PHP Versions on the Command Line for Ubuntu 16.04 with Apache?

Susan Sarandon
Release: 2024-11-14 18:49:02
Original
726 people have browsed it

How to Switch PHP Versions on the Command Line for Ubuntu 16.04 with Apache?

Switching PHP Versions on the Command Line for Ubuntu 16.04 with Apache

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:

Interactive Switching

For an immediate switch, utilize the following commands:

sudo update-alternatives --config php
sudo update-alternatives --config phar
sudo update-alternatives --config phar.phar
Copy after login

Manual Switching

To manually switch between PHP versions:

from PHP 5.6 to PHP 7.1 (Command Line)

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
Copy after login

from PHP 7.1 to PHP 5.6 (Command Line)

sudo update-alternatives --set php /usr/bin/php5.6
Copy after login

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!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template