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:
- Go to the Apps page in the dashboard and click on the name of the app.
- Click on Settings.
- For the PHP Version, click the edit icon and select the desired PHP version.
- 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:
php -v
To change the PHP version of the php
command:
- SSH into your server as the user
root
. - Run the command:
Terminal window sudo dpkg-reconfigure sp-php-cli - Select the desired PHP version and press Enter.
PHP settings
PHP settings control the behavior of PHP.
- Default settings for PHP 8.4
- Default settings for PHP 8.3
- Default settings for PHP 8.2
- Default settings for PHP 8.1
- Default settings for PHP 8.0
- Default settings for PHP 7.4
- Default settings for PHP 7.3
- Default settings for PHP 7.2
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:
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:
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.
php8.4-sp
php8.3-sp
php8.2-sp
php8.1-sp
php8.0-sp
php7.4-sp
php7.3-sp
php7.2-sp
php7.1-sp
php7.0-sp
php5.6-sp
Versioned composer
commands
In addition to the composer
command, versioned commands are available.
composer8.4-sp
composer8.3-sp
composer8.2-sp
composer8.1-sp
composer8.0-sp
composer7.4-sp
composer7.3-sp
composer7.2-sp
composer7.1-sp
composer7.0-sp
composer5.6-sp
Versioned wp
commands
In addition to the wp
command, versioned commands are available.
wp8.4-sp
wp8.3-sp
wp8.2-sp
wp8.1-sp
wp8.0-sp
wp7.4-sp
wp7.3-sp
wp7.2-sp
wp7.1-sp
wp7.0-sp
wp5.6-sp