PHP
Chester Wyke November 06, 2023 Updated: April 26, 2025 #MiscCheck current
Install current version
See apache install instructions to see how to install the current version that is in the default repos.
Install multiple versions
Source: https://www.youtube.com/watch?v=bHTv0FmvrTo
- Before doing this process it is assumed that apache and the current version of php is already installed.
- This approach only allows you to use one version at a time on the system.
- Tested on Ubuntu 22.04
Install dependency
NB: Normally already installed
Add ppa for other versions
Previous step needed to ensure this command is available.
Install desired version
Replace 7.3 in the example with the version you are looking for
Select versions of PHP that are installed and available
For Apache
Source: https://serverfault.com/questions/149039/how-to-change-what-version-of-php-apache2-uses
Example commands switch from 8.1 to 7.3
NB: Use of tab
to autocomplete commands works and helped in ensuring I got the version numbers right.
Disable current module
Enable replacement version
Install MySQL Module for PHP
Source: https://zoomadmin.com/HowToInstall/UbuntuPackage/php-mysqli (Link seems to be broken now)
Restart Apache
See instructions on restarting apache here.
For CLI
Will open a menu showing which are installed, and which one is active.
NB: sudo
not needed to only view the list and see which is active.
sudo
is only needed if you want to change the selection.