I have installed php 5.6 and php 7.1 on Ubuntu 16.04
I know I can do it using Apache as my web server
a2enmod php5.6 #to enable php5 a2enmod php7.1 #to enable php7
When I disable php7.1 and enable php 5.6 in the Apache module, Apache recognizes the change and uses the php 5.6 interpreter as expected.
But when I run the internal php web server from the command line:
php -S localhost:8888
php uses php 7 to handle requests. So how do I switch between php 5.6 and php 7.1 from the command line?
P粉5040809922023-10-11 14:07:31
sudo update-alternatives --config php sudo update-alternatives --config phar sudo update-alternatives --config phar.phar
Your system settings default to PHP 5.6, you need to switch to PHP 7.1.
Apache:
$ sudo a2dismod php5.6 $ sudo a2enmod php7.1 $ sudo service apache2 restart
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
Your system is set to default PHP 7.1, you need to switch to PHP 5.6.
Apache:
$ sudo a2dismod php7.1 $ sudo a2enmod php5.6 $ sudo service apache2 restart
Command Line:
$ sudo update-alternatives --set php /usr/bin/php5.6