Skip to content

PHP versions and settings

PHP versions

The available PHP versions are determined by the server’s Ubuntu release.

Change an app’s PHP version

To change an app’s PHP version:

  1. Go to the Apps page in the dashboard and click on the name of the app.
  2. Click on Settings.
  3. For the PHP Version, click the edit icon and select the desired PHP version.
  4. Click on Update.

Change the version of the php command

The PHP version of the php command is configured server-wide. The version is not associated with the PHP version of a specific app on the server.

To determine the current PHP version for the PHP CLI, run the command:

Terminal window
php -v

To change the PHP version of the php command:

  1. SSH into your server as the user root.
  2. Run the command:
    Terminal window
    sudo dpkg-reconfigure sp-php-cli
  3. Select the desired PHP version and press Enter.

PHP settings

PHP settings control the behavior of PHP.

Change settings

PHP settings can be changed either per-app or server-wide.

View settings with phpinfo()

To view the current PHP settings for an app, create a PHP script in the app’s public/ directory that contains the following:

<?php phpinfo(); ?>

Request the file through your browser to view the app’s current PHP settings. The output of phpinfo() shows two values for each setting:

  • The “Local value” column shows the current PHP settings for your app including any settings configured using a .user.ini file.
  • The “Master Value” column shows the default PHP settings including any customizations to default PHP settings.

View settings with the CLI

To view PHP settings using the PHP CLI, use the -i flag:

Terminal window
php -i

The output of php -i shows the server-wide settings for the PHP version of the php command.

By default, the PHP CLI will not read .user.ini files. To force the PHP CLI to read .user.ini files, set the PHP_INI_SCAN_DIR environment variable. For example:

Terminal window
PHP_INI_SCAN_DIR=apps/APPNAME/public php -i

When using the PHP_INI_SCAN_DIR environment variable to include settings from .user.ini files, the values from the .user.ini files will be shown as both the “Local value” and the “Master Value”.

PHP extensions

In addition to official extensions that are part of PHP, you can install third-party PHP extensions.

Default extensions

See the default extensions for each PHP version.

Install third-party extensions

Install third-party extensions to add functionality to PHP.

PHP CLI

The PHP version for the php, composer, and wp commands is determined by the version of the PHP CLI that is configured server-wide.

To use multiple versions of the php, composer, and wp commands without changing the default version of the PHP CLI, versioned commands are available.

Versioned php commands

In addition to the php command, versioned commands are available.

Terminal window
php8.4-sp

Versioned composer commands

In addition to the composer command, versioned commands are available.

Terminal window
composer8.4-sp

Versioned wp commands

In addition to the wp command, versioned commands are available.

Terminal window
wp8.4-sp