GoAdmio

multiphp

Change the PHP version of one domain or all domains, or list the installed PHP versions

On this page: Overview · Quick start · Syntax · Arguments · Output · Examples · Troubleshooting · Details · See also


Overview

/go/multiphp sets which PHP version a hosting account runs. For each domain it changes, it:

It can also print the PHP versions that are installed on the server.

The command re-runs itself with sudo if it isn't started as root.


Quick start

# See which versions are installed
/go/multiphp return

# Change one domain
/go/multiphp example.com 8.2

Syntax

/go/multiphp return
/go/multiphp <domain> [version]
/go/multiphp all [version]
Form Behavior
/go/multiphp return Prints the installed versions on one line, separated by |.
/go/multiphp <domain> <version> Sets that domain to the given version.
/go/multiphp <domain> Sets that domain to the newest installed version.
/go/multiphp all <version> Sets every domain on the server to the given version.
/go/multiphp all Sets every domain to the newest installed version.

[!WARNING] all changes every site on the server. Without a version it moves every site to the newest installed PHP, which can break older applications. Always give a version, and test on one domain first.


Arguments

Argument Required Default Notes
<domain> Yes, unless using all or return — The account's primary domain, as stored in GoAdmio. Subdomains and aliases are not accepted.
all — — Applies the change to every domain in /home whose name contains a dot. Case-sensitive.
return — — Lists the installed versions. Not case-sensitive.
[version] No Newest installed version Use a value printed by multiphp return.

The command has no --option flags.

Version names

The version is the name of the PHP configuration folder.

System Folder checked Example name
AlmaLinux, Rocky, CentOS, Red Hat, Fedora /etc/opt/remi/<version>/php.ini The Remi folder name, for example php83
Debian, Ubuntu /etc/php/<version>/fpm/php.ini 8.3

Only versions whose php.ini exists are listed by return and picked as the newest.


Output

Outcome What you get
return The installed versions on one line, for example 7.4|8.1|8.3. Exit code 1.
Single domain changed PHP Version for <domain> changed to <version>
all [N/C] PHP Version for <domain> changed to <version> for each domain. Exit code 1.
Version not installed Installed PHP Versions: followed by the list. Exit code 1.
Domain not found Domain <domain> not exists. Exit code 1.
Unsupported operating system Unknown operating system.

return and all always exit with code 1, even when they succeed.

Logging

Every run is appended to /var/log/go/multiphp.log.


Examples

# List installed versions
/go/multiphp return
# Move one domain to PHP 8.2
/go/multiphp example.com 8.2
# Move one domain to the newest installed version
/go/multiphp example.com
# Move every domain to PHP 8.3
/go/multiphp all 8.3

Troubleshooting

Symptom Likely cause Fix
Installed PHP Versions: and a list The version you passed isn't a folder on this server. Use a name from the list, or install it with installphp.
Domain <domain> not exists The domain isn't in the panel's Site table. Check the domain. For subdomains, see subdomain.
A site shows errors after the change The application doesn't support the new version. Set the previous version with the same command. Turn on error display with displayerrors to see the cause.
The version is accepted but the site doesn't work The folder exists but PHP-FPM isn't installed for that version. Install it with installphp.
Success message, but the site still runs the old version The pool or web server didn't reload. Run reload or restart.
A subdomain still uses the old version Only the account's own record is changed. Subdomains keep their own version. Change it with subdomain.
Running it with no arguments printed PHP Version for changed to ... An empty domain passes the existence check. See Notes for maintainers. Always give a domain, all, or return.
A script treats the run as failed return and all exit with code 1 on success. Ignore the exit code for those forms.

Details

What it does

  1. Re-runs itself with sudo if not root, and logs the call.
  2. Reads the operating system name from /usr/local/goadmio/linux/os.db.
  3. For return: lists the installed versions and stops.
  4. If no version was given, picks the last installed version in alphabetical order.
  5. Stops with the list of installed versions if neither /etc/opt/remi/<version> nor /etc/php/<version> exists.
  6. For all: for every folder in /home with a dot in its name, runs steps 8 to 10, then reloads once at the end.
  7. For a single domain: stops with Domain <domain> not exists if the Site table has no such domain.
  8. Updates the PHPVersion column in the Site table.
  9. Rebuilds the web server configuration with apache and nginx, both of them whatever the active server is.
  10. Recreates the PHP-FPM pool with /go/php-fpm.
  11. Reloads PHP-FPM and the active web server with reload.
flowchart TD
    A["multiphp first second"] --> B{"First argument"}
    B -- "return" --> R["Print installed versions"]
    B -- "domain or all" --> V["Pick version, check it exists"]
    V -- "Not installed" --> E["List installed versions, exit 1"]
    V -- "OK" --> M{"all?"}
    M -- "Yes" --> L["For each domain: update record, rebuild vhosts, recreate pool"]
    L --> RL["Reload once, exit 1"]
    M -- "No" --> D{"Domain in Site table?"}
    D -- "No" --> E2["Domain not exists, exit 1"]
    D -- "Yes" --> U["Update record, rebuild vhosts, recreate pool, reload"]

Notes for maintainers

Issue Why it matters Suggested fix
An empty domain passes the existence check With no domain, the helper commands are called with an empty argument. Check what apache, nginx, and php-fpm do with that before relying on it. Exit with a usage message if $1 is empty.
The version check accepts any existing folder .. or 8.3/fpm pass and are written to the database. Check the value against the list built for return, or a pattern such as ^[0-9]+\.[0-9]+$ or ^php[0-9]+$.
Both operating systems' paths are checked regardless of the system A name valid on the other system is accepted. Check only the folder for the current system.
Domain and version are placed directly in SQL A quote in the value breaks the query and can be abused. Validate both before use.
all handles every dotted folder in /home, not only accounts Stray folders get vhosts and pools, because the UPDATE matches no row but the rebuild still runs. Skip domains that aren't in the Site table.
all without a version upgrades every site to the newest PHP One command can break many sites. Require a version, or ask for confirmation.
"Newest" is the last name in alphabetical order Wrong when versions sort differently from numeric order, such as 10.0 before 7.4. Use sort -V.
The database is updated before the configuration is rebuilt If a rebuild fails, the panel shows the new version while the pool runs the old one, and the message still says "changed". Check each step and roll the record back on failure.
The same version-finding code appears three times Hard to maintain. Use one function.
return and all exit with 1 on success, and an unknown OS exits with 0 Callers can't tell success from failure. Use exit 0 on success and exit 1 on errors.
Subdomain versions are not updated They keep their own PHPVersion and can stay on an old version. Offer an option to update them too.

See also

Command Description
listphp List the available PHP versions on a GoAdmio server
installphp Install a different PHP version on GoAdmio
removephp Remove a PHP version from a GoAdmio server
defaultphp Change the default PHP version in the CLI
subdomain Create, edit, or delete a subdomain
reload Reload PHP-FPM and the active web server
fpm Restart all installed PHP-FPM versions on your server