Tuesday, January 28, 2025Running PHP 8.3 alongside other versions
Keven Client A. Cataluña @LinkedIn
Introduction

This guide explains how to check the current PHP version, list all installed PHP versions, and switch between them using the update-alternatives command. It ensures smooth management of multiple PHP versions on a single system.

Steps1. Check the current PHP version
    php -v
  
      PHP 8.3.9 (cli) (built: Jul 5 2024 12:03:23) (NTS)
  Copyright (c) The PHP Group
  Zend Engine v4.3.9, Copyright (c) Zend Technologies
      with Zend OPcache v8.3.9, Copyright (c), by Zend Technologies
  
2. List the installed PHP versions and switch to the desired version
    sudo update-alternatives --config php
  
      There are 2 choices for the alternative php (providing /usr/bin/php).

    Selection   Path              Priority   Status
  ------------------------------------------------------------
  * 0           /usr/bin/php8.3   83         auto mode
    1           /usr/bin/php8.2   82         manual mode
    2           /usr/bin/php8.3   83         manual mode

  Press <enter> to keep the current choice[*], or type selection number: 1
  update-alternatives: using /usr/bin/php8.2 to provide /usr/bin/php (php) in manual mode
  
3. Verify the current PHP version
    php -v
  
      PHP 8.2.21 (cli) (built: Jul 4 2024 16:26:06) (NTS)
  Copyright (c) The PHP Group
  Zend Engine v4.2.21, Copyright (c) Zend Technologies
      with Zend OPcache v8.2.21, Copyright (c), by Zend Technologies
  
Tags
← Back to the posts