Investors

Knowledge base

1000 FAQs, 500 tutorials and instructional videos. Here, there are only solutions!

Change the PHP version for CLI

Update 10/22/2026

This guide explains how to change the PHP version used in the command line (PHP CLI) on an Infomaniak web hosting plan.

 

Introduction

  • This configuration allows you to choose the PHP version used by scripts executed via SSH in the command line.
  • To change the PHP version used by websites (FPM/Apache) from the Manager, please refer to this other guide.
  • On October 21, 2026, the PHP team released new versions that fix two critical vulnerabilities (❓: help):
    • The security patches provided by the PHP teams have been successfully deployed across the entire shared infrastructure and Cloud Servers, for PHP versions 8.5, 8.4, 8.3, 8.2, 8.1, 8.0, and 7.4.
    • The PHP version numbers remain unchanged, but the security patches have been applied to all affected services.

 

Check the PHP version used in the CLI

The php command uses the first PHP binary found in the PATH environment variable. To find out which version is being used and its location, run:

php -v
which php

The number displayed corresponds to the version of the binary used in the CLI. This does not necessarily correspond to the version configured for websites.

 

Check the compilation date and security patches

To display the compilation date of the PHP binary being used, run:

php -i | grep "Build Date"

If you are using an explicit path to a PHP version, you can also check its compilation date:

/opt/php8.3/bin/php -i | grep "Build Date"

Infomaniak may integrate certain security patches into a recompiled PHP binary without modifying the displayed version number. Therefore, a version that appears to be older than the latest officially published version (❓: help) does not necessarily mean that the patches are missing.

 

Modify the PHP version in CLI

You can choose the default PHP version loaded in your SSH sessions by modifying the PATH environment variable.

1. Modify the .bashrc file (recommended)

The ~/.bashrc file contains the configuration for interactive Bash sessions.

  1. Open the file or create it if it doesn't exist:

    nano ~/.bashrc
  2. Add the following line to use PHP 8.3, for example:

    export PATH="/opt/php8.3/bin:$PATH"
  3. Reload the configuration:

    source ~/.bashrc
  4. Check the version and path used:

    php -v
    which php

2. Load .bashrc when connecting via SSH (if necessary)

If your SSH session does not automatically load ~/.bashrc, add the following code to the login file used by your shell, for example ~/.bash_profile or ~/.profile:

if [ -f ~/.bashrc ]; then
    . ~/.bashrc
fi

 

Run a specific version on demand

To run a script with a specific version without modifying the default configuration, specify the path to the binary directly:

/opt/php8.2/bin/php my_script.php
/opt/php8.3/bin/php -v

The version selected in PATH will be used by default in sessions that load this configuration. You can always run a different version by specifying its full path.


Has this FAQ been helpful?