How to: Make Bulk Changes to SiteWorx Account PHP Versions

To Check the Current PHP Version for All Domains

  1. Log in to the server at the CLI as root, either via SSH or from the terminal

  2. Run the following:

    nodeworx -u -n -c siteworx -a listSiteworxAccounts | awk '{print $2}' | while read i ; do siteworx -n -u -h --login_domain $i -c DomainsPhp -a listPhpVersions | awk '{print $1, $2, $3}' | while read d t p ; do echo "SWDomain:$i Domain:$d Type:$t PHPConf:$(~iworx/bin/config.pex --siteworx $i --get --name SITEWORX_PHP_VERSION)" PHPVer:$p; done ; done
    

    Example output:

    • SWDomain: The SiteWorx account

    • Domain: The domain

    • Type: Whether the domain is the main domain for the account (master) or a secondary domain (slave)

    • PHPConf: The default PHP version, which is what is used when the account is created

    • PHPVer: The version of PHP the domain is currently using

    [root@server ~]# nodeworx -u -n -c siteworx -a listSiteworxAccounts | awk '{print $2}' | while read i ; do siteworx -n -u -h --login_domain $i -c DomainsPhp -a listPhpVersions | awk '{print $1, $2, $3}' | while read d t p ; do echo "SWDomain:$i Domain:$d Type:$t PHPConf:$(~iworx/bin/config.pex --siteworx $i --get --name SITEWORX_PHP_VERSION)" PHPVer:$p; done ; done
    SWDomain:example.com Domain:example.com Type:master PHPConf:system-php PHPVer:7.2.34
    SWDomain:example.com Domain:newexample.com Type:slave PHPConf:system-php PHPVer:8.1.2
    SWDomain:mydomain.com Domain:mydomain.com Type:master PHPConf:system-php PHPVer:7.3.33
    SWDomain:domain.com Domain:domain.com Type:master PHPConf:system-php PHPVer:5.5.38
    [root@server ~]#
    

To Enable PHP Versions for All Accounts

Enabling a PHP version for a SiteWorx account adds it as an option for domains under that account. It does not set any domains to use that version.

Enabling All PHP Versions for All Accounts

Note

This command requires that all PHP versions are already installed via the Multiple PHP Tool on the Webserver page in NodeWorx.

  1. Log in to the server at the CLI as root, either via SSH or from the terminal

  2. Run the following. In this example, all versions up to PHP 8.1 are included. Any subsequent PHP versions can be added with /opt/remi/php{version number}, replacing {version number} with the PHP version (sans decimal). No output is expected from this command:

    ~iworx/bin/listaccounts.pex --domain | xargs -I {} -n1 nodeworx -u -n -c Siteworx -a edit --domain {} --php_available /opt/remi/php54,/opt/remi/php55,/opt/remi/php56,/opt/remi/php70,/opt/remi/php71,/opt/remi/php72,/opt/remi/php73,/opt/remi/php80,/opt/remi/php81,system-php
    

To Enable a Specific PHP Version for All Accounts

Note

This command requires that the PHP version being enabled is already installed via the Multiple PHP Tool on the Webserver page in NodeWorx.

  1. Log in to the server at the CLI as root, either via SSH or from the terminal

  2. Run the following. This example uses PHP 7.4. No output is expected from this command:

    ~iworx/bin/listaccounts.pex --domain | xargs -I {} -n1 nodeworx -u -n -c Siteworx -a edit --domain {} --php_available /opt/remi/php74
    

To Set the Default Versions for All Accounts

The default PHP version is the version that newly created domains will automatically be set to use.

  1. Log in to the server at the CLI as root, either via SSH or from the terminal

  2. Run the following. This example uses PHP 7.4. No output is expected from this command:

    ~iworx/bin/listaccounts.pex --domain | xargs -I {} -n1 nodeworx -u -n -c Siteworx -a edit --domain {} --php_version /opt/remi/php74
    

To Set All Domains to Use a Specific PHP Version

  1. Log in to the server at the CLI as root, either via SSH or from the terminal

  2. Run the following. This example uses PHP 7.4. No output is expected from this command:

    ~iworx/bin/listaccounts.pex --domain | xargs -I {} -n1 nodeworx -u -n -c Siteworx -a changePhpVersion --master_domain {} --php_version /opt/remi/php74