defaultphp
Show or change the server's default PHP version
- Command:
/go/defaultphp - Category: PHP
- Required option: None to show the version; a PHP version to change it
- Output: The current PHP version, or progress and status messages
- Last updated: 2026-11-20
On this page: Overview · Quick start · Syntax · Arguments · Output · Examples · Troubleshooting · Details · See also
Overview
/go/defaultphp controls which PHP version the server uses by default, including the php command on the command line.
- With no argument, it prints the PHP version currently in use.
- With a version number, it makes that version the default and then refreshes the related PHP settings and services.
To set the PHP version for one domain, use multiphp instead.
[!WARNING] On AlmaLinux, Rocky Linux, CentOS, Red Hat, and Fedora, this command removes every
php-*package and reinstalls PHP from the Remi repository. Sites served by the default PHP can be unavailable while it runs. Run it at a quiet time.
Quick start
# Show the current default PHP version
/go/defaultphp
# Make PHP 8.3 the default
/go/defaultphp 8.3
Syntax
# Show the current version
/go/defaultphp
# Change the default version
/go/defaultphp <version> [--progress]
Run the command as root. It has no -- options except --progress, which must come after the version.
Arguments
| Argument | Required | Notes |
|---|---|---|
<version> |
To change the version | One of 5.6, 7.0, 7.1, 7.2, 7.3, 7.4, 8.0, 8.1, 8.2, 8.3, 8.4, 8.5, 8.6. Always two parts, such as 8.3. |
--progress |
No | Prints progress messages, and a final 100, for use by the control panel. |
A version in this list is not necessarily available for your operating system. If the package source doesn't offer it, the install fails.
Output
Showing the version
PHP8.3.6
The name and number are printed together without a space. The exit status is 1 even though this is not an error.
Messages
| Message | Meaning |
|---|---|
Invalid PHP Version |
The version is not in the list above. Exit status 1. |
Instance (<name>) already running. |
The PHP install lock is in use. Exit status 1. |
PHP <version> not installed. To install PHP <version>, run the following command as root: followed by /go/installphp <version> |
Debian or Ubuntu only. The version isn't installed yet. Exit status 1. |
Change Default PHP Version Completed Successfully and 100 |
Shown only with --progress, when everything finished. |
Examples
# Check, change, then check again
/go/defaultphp
/go/defaultphp 8.2
/go/defaultphp
# Debian or Ubuntu: install the version first, then make it the default
/go/installphp 8.4
/go/defaultphp 8.4
# See which versions are installed
/go/listphp
Troubleshooting
| Symptom | Likely cause | Fix |
|---|---|---|
Invalid PHP Version |
The version is misspelled or not supported, for example 8 or 8.3.1. |
Use a two-part version from the list in Arguments. |
Instance (<name>) already running. |
installphp or another PHP change is running. |
Wait and try again. A lock older than 10 minutes is ignored. |
PHP <version> not installed |
Debian or Ubuntu: /etc/php/<version>/fpm/php.ini doesn't exist. |
Run /go/installphp <version>, then run this command again. |
The command prints the version but exits with status 1 |
That is how the no-argument form works. | Expected. Don't use its exit status in scripts. |
php -v still shows the old version |
A shell may have cached the old path. | Open a new session, or run hash -r. |
| Errors about Apache modules on an Nginx server | The Debian and Ubuntu steps use Apache commands. | Check that php -v shows the new version. The Apache messages can be ignored on an Nginx-only server. |
| The install fails on a RHEL-family server | The version isn't offered for your OS version, or the Remi release package doesn't match your OS version. | Check which release package the script installs. See Red Hat family. |
| A PHP extension is missing afterward | Some extensions don't exist for every PHP version and are skipped silently. | Install it with extension. |
Details
What it does
flowchart TD
A["defaultphp [version]"] --> B{"Version given?"}
B -- "No" --> C["Print the current PHP version, exit 1"]
B -- "Yes" --> D{"PHP install lock in use?"}
D -- "Yes" --> E["Print Instance already running, exit 1"]
D -- "No" --> F["Take the lock"]
F --> G{"Version in the supported list?"}
G -- "No" --> H["Print Invalid PHP Version, exit 1"]
G -- "Yes" --> I{"Operating system"}
I -- "Red Hat family" --> J["Remove php-* packages, install the version from Remi, install PHP packages"]
I -- "Debian or Ubuntu" --> K{"Version installed?"}
K -- "No" --> L["Print the installphp hint, exit 1"]
K -- "Yes" --> M["Switch the Apache module and the php alternative, restart Apache"]
J --> N["Run composer, session, so, and fpm"]
M --> N
N --> O["Remove the lock.db file and release the lock"]
Red Hat family (AlmaLinux, Rocky, CentOS, Red Hat, Fedora)
This branch installs the version, so it does not need to be installed beforehand.
- Removes every
php-*package withdnf remove. - Installs the Remi release package for Enterprise Linux 8.
- Disables all
remi-phprepositories (5.6 through 8.8). - Enables the repository for the chosen version, installs
php, resets thephpmodule, and installs the matchingphp:remi-<version>module stream. - Installs a set of PHP packages with
--skip-broken:memcached,mysqlnd,pgsql,dba,devel,embedded,fpm,gd,imap,interbase,intl,ldap,zip,mbstring,mcrypt,odbc,opcache,pear,bcmath,soap,process,pspell,recode,xml,xmlrpc,ssh2,pecl-ssh2, andgmp. A package that doesn't exist for the chosen version, such asmcrypton recent PHP, is skipped without an error. - Enables the
php-fpmservice.
[!NOTE] Step 2 always installs the Enterprise Linux 8 release package, whatever your OS version is. On AlmaLinux or Rocky 9 and later, check that this step succeeds and that the packages match your system.
Debian and Ubuntu
This branch only switches to a version that is already installed.
- Checks that
/etc/php/<version>/fpm/php.iniexists. - Disables the Apache PHP modules for every version from 5.6 to 8.8.
- Enables the Apache module for the chosen version.
- Sets the
phpcommand to/usr/bin/php<version>withupdate-alternatives. - Restarts
apache2.
The Apache commands are not run with sudo, so run the whole command as root.
Other operating systems
Neither branch runs. The follow-up steps below still run, and the default version is not changed.
After the switch
On every supported system, the command then runs:
| Command | Purpose |
|---|---|
composer |
Install Composer (PHP dependency manager) |
session |
Create and set permissions on PHP session directories |
so |
Run the so helper |
fpm |
Restart all installed PHP-FPM versions |
It also deletes /usr/local/goadmio/db/lock.db.
Locking
The command uses /usr/local/goadmio/lock/installphp.lock, the same lock as installphp, so the two can't run at once. A lock older than 600 seconds (10 minutes) is treated as stale. The lock is released when the command exits, including after errors.
Side effects
- Every call is logged to
/var/log/go/defaultphp.log. - The version check and lock apply only when a version is given.
- The
phpcommand and Apache's PHP module change for the whole server.
See also
| Command | Description |
|---|---|
installphp |
Install a different PHP version on GoAdmio |
listphp |
List the available PHP versions on a GoAdmio server |
removephp |
Remove a PHP version from a GoAdmio server |
multiphp |
Manage PHP versions per domain |
extension |
List, install, or remove PHP extensions across every version |
fpm |
Restart all installed PHP-FPM versions on your server |