ApisCP provides a variety of command-line helpers that allow you to interact with your accounts. For example, you may want to put the panel in headless mode (opens new window), which disables web-based access, automate account management, or even too run a command as another site.
All helpers live under
/usr/local/apnscp/bin. All commands except for
cpcmd must be run as root.
sudo su - is a quick way to become root if you aren't already.
*Domain binaries: AddDomain, EditDomain, DeleteDomain, ActivateDomain, and SuspendDomain are covered in Plans.md. ImportDomain and ExportDomain are covered in Migrations.md. This document covers other helpers.
cpcmd is the single most important command in your arsenal. As root, it allows you to run a command within any authentication context – any. Need to add a domain to mysite.com named blog-site.com?
cpcmd -d mysite.com aliases_add_domain blog-site.com /var/www/blog-site.com cpcmd -d mysite.com aliases_synchronize_changes
This adds a new domain named blog-site.com with the document root /var/www/blog-site.com, then updates the web server configuration. Alternatively,
aliases_remove_domain blog-site.com would remove the domain from the account.
Now let's configure Let's Encrypt for the addon domain and install Wordpress.
cpcmd -d mysite.com letsencrypt_append blog-site.com cpcmd -d mysite.com wordpress_install blog-site.com
And that's it!
What about removing a vacation auto-responder for a secondary user named sam?
cpcmd -d mysite.com -u sam email_remove_vacation
Let's collect a web app inventory as the server admin of a new site, mydomain.com, then update them as necessary:
cpcmd admin_locate_webapps 'mydomain.com' cpcmd admin_update_webapps '[site:mydomain.com]'
Any command in the panel has a corresponding API (opens new window) method. Quite simply, whatever you can do in the panel you can do too from the command-line or afar with Beacon (opens new window).
# Alternate invocation
Commands may also be written in a clear form separating the module from the function by a colon and replacing function underscores ("_") with hypens ("-"). The above admin command thus becomes:
cpcmd admin:locate-webapps 'mydomain.com'
# Listing all commands
misc:list-commands(string $filter = '') lists commands available to the current role. "filter" is any glob-style patern. For example, to see all admin commands available to the admin:
To see all commands containing "pass" for the Site Administrator of site1,
cpcmd misc:l and
cpcmd -l are shorthand usage for this command.
# Introspecting commands
misc:info(string $filter = '') displays command information including its signature, documentation, return type, and parameter documentation. It behaves similarly to
misc:i is shorthand for this usage.
# Arbitrary execution/interactive mode
cpcmd -r creates an execution context after ApisCP has been loaded. It may be used to interact with panel state as a one-liner.
# Load Laravel configuration, get contents from config/laravel/mail.php cpcmd -r '$app = app("config"); var_dump($app["mail"]);'
cpcmd --interactive is similar to one-liner mode (-r), but launches an interactive shell. State is not maintained in between invocations.
cpcmd --interactive # now in shell var_dump(app('config')['mail']); echo $c->commom_whoami(), "\n"; $i = 0; # This will not work... echo ++$i;
# Input/output types
cpcmd uses a custom parser for input and displays output in Yaml or as a string depending upon return type complexity. Both features may be controlled using
-o flags respectively. Each accepts a transform format.
# Input formats
serialize is useful when working with objects. Variable types will not be lost on ingestion.
json is the fastest format.
cli is a simple representation for complex data types.
# Output formats
When working with serialized output in a shell pipeline, wrap output in
xargs -d otherwise quotes will be lost while evaluating arguments in bash.
cpcmd -o serialize common:whoami | xargs -d$'\n' env DEBUG=1 cpcmd -i serialize test:backend-collector
Get service metadata from site identifier (domain, site id, site).
get_config domain.com siteinfo email
Get site name from domain or site id. Same as "site" +
Get internal site ID from domain or site. Returns 1 on failure otherwise 0.
get_site_id example.com [[ $? -ne 0 ]] && echo "example.com doesn't exist"
All ApisCP scripts are available under
/usr/local/apnscp/bin/scripts. All scripts make use of the ApisCP CLI framework and require invocation with
apnscp_php to operate.
Perform bulk database backups. This can be manually invoked before a system backup to ensure a fresh export of databases.
Blocks any IP addresses with more than 100 open connections to a server.
Summarize ApisCP changes from
Bulk change DNS for an account. IPs may be changed for a single domain by specifying
-d DOMAIN or for all accounts for which DNS is enabled by specifying
cd /usr/local/apnscp/bin/scripts # Reduce TTL for all domains to 15 seconds ./change_dns.php --all --ttl=15 # For all IPs that match "site:ip-address" change the IP to 126.96.36.199 ./change_dns.php -d site1 --new=188.8.131.52 # Command above is equivalent to... ./change_dns.php -d site1 --old="$(cpcmd -d site1 site:ip-address)"--new=184.108.40.206 # Change IP address for all sites that match old IP address 220.127.116.11. If changed, set a TTL value of 2 hours ./change_dns.php --all --old=18.104.22.168 --new=22.214.171.124 --ttl=7200
This is a simpler version of bulk DNS boilerplate.
Metrics compression/rollover helper.
Wrapper for monthly invocation of upcp -sb.
Perform a bulk reissue of all certificates. See SSL.md for further information.
Periodic storage logging.
Migrate an ApisCP site between servers. See [Migrations](Migrations - server.md) for further information.
Similar to mapCheck.php, scans a system for inconsistencies in UID/GID attached to accounts.
Synchronize packages into FST.
# Build scripts
Build PHP for ApisCP. To run, change into PHP source directory, then run:
PHP will be built with ApisCP module requirements.
General utility apxs wrapper to build modules specifically for ApisCP. Installed modules will be placed under
sys/httpd/private/modules. Unless the module conflicts with global Apache instance, modules can be used from
sys/httpd/modules, which is a symlink to