-
Notifications
You must be signed in to change notification settings - Fork 13
DEPRECATED: Multiple PHP CLIs (Ubuntu)
Amitai Burstein edited this page Aug 5, 2020
·
1 revision
Instead of having multiple PHP installed locally, please use DDEV.
Taken from the next post: https://tecadmin.net/install-multiple-php-version-apache-ubuntu/
sudo apt update
sudo apt install apache2 libapache2-mod-fastcgi
# Ubuntu 18.04 Users:
sudo apt install apache2 libapache2-mod-fcgid
# On Ubuntu 16.04
sudo apt install python-software-properties
sudo add-apt-repository ppa:ondrej/php
# On Ubuntu 18.04
sudo apt install software-properties-common
sudo add-apt-repository ppa:ondrej/php
- Let's take version 7.2 for example:
apt update sudo apt install php7.2 php7.2-fpm
sudo systemctl status php7.2-fpm
Modify the virtual host that should use a specific version, add the next to it:
<VirtualHost *:80>
<FilesMatch \.php$>
SetHandler "proxy:unix:/var/run/php/php7.2-fpm.sock|fcgi://localhost"
</FilesMatch>
</VirtualHost>
sudo systemctl restart apache2
For each php package/extension, need to install per version.
For example, mysql
or gd
or tidy
or curl
:
sudo apt install php7.2-mysql
sudo apt-get install php7.2-gd
sudo apt-get install php7.2-tidy
sudo apt-get install php7.2-curl
sudo update-alternatives --config php
Personally, I add an alias to ~/.bashrc
to easily switch:
alias phpswitch='sudo update-alternatives --config php'