A command line interface is one of SpinupWP’s most frequently requested features. The wait is finally over!
Visit the SpinupWP CLI project on GitHub for complete installation and usage instructions. The first step is to require the package globally via Composer:
composer global require spinupwp/spinupwp-cli
Make sure the /vendor/bin
directory in your global Composer home directory is in your system’s PATH
. This could be ~/.composer/
or ~/.config/composer/
, depending on your operating system. You can use the composer config --global home
command to check this location.
Once you’ve finished installation, you’ll have access to the spinupwp
command:
spinupwp <subcommand>
You will need to generate an API token to interact with the SpinupWP CLI. You can create a personal API access token in the “API” tab under “Account Settings” in SpinupWP. Team admins can also generate access tokens from the “API” tab on the “Team Settings” page of any team they manage. API tokens can only be used on resources associated with the team or personal account used to generate them. After generating an API token, use the command below to configure your default profile. We strongly recommend configuring a default profile. Otherwise, you’ll need to specify a profile with every command, adding more keystrokes and slowing you down.
spinupwp configure
The same command can be used to configure multiple profiles by adding the --profile
switch. This can be very useful if you’re a member of multiple teams.
abraham@macbookpro:~$ spinupwp configure --profile=hellfishmedia SpinupWP API token: >eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJhdWQiOiIxIiwianRpIjoiMjk4YjU2MTIzNzJlNGQyYWY4NzgwZjFiMTk3OWM3ZnE4YWIzZDg2YmEzMDkxYTEwMTZkOTYwYTI0O2UyZjBjMTdkMTEwYmZkYmRkMWMzMGEiLCJpYXQiOjE2NDk3NjQ4OTAsIm5iZiI6MTY0OTc2NDg5MCwiZXhwIjo0ODA1NDM4NDkwLCJzdWIiOiIxIiwic2NvcGVzIjpbInJlYWQtd3JpdGUiXX0.fmKjZ8p98JTnKfBPLT3SKo2rAXX-2cRb1M3iIR-Eafv4O8b3QNpDrWS6FrBoFI12B61vRl1iWb57x2Gx6dg2oalMqVgiNlsUz45HseUfX1aygOKmW_Jou0roWp50V-VRgIevevDWeCgXFVgoEksBIy-G4E8ECDV0uDW3P3mQxsMRhnFgaFAnEKz-7C6733e_sr7icMVYlnDjzzjTCDk2wzj2ZnB_pCvqhxvUeWPotTRy6aX1tGudSBYL1av25hbwQ91nZSCpMOI1-4WIOyShsCOiyCaA-Jz-7m7DJ3dACahwP224ihccwnj84-lbXOwsTyAbLnn8_cJ3SxYuQb-PQIiGBDy_AHLC_hbOjGw1vyj_MH3qnsnlBHNX4wHa4KcWQz_zsPlnIlu7MNJ0nP5ZgPv_SV_zQDiXVXzLe3aXFZyuZPVXm5E41jgRSe8o_fammnGeEfAO0ydn46umJbcSsqdjtgkaFVh4V8HmdF7E_SocGYu3p4eVtkRHg1T0H0Atckpw55-JXXtn-dhYInt39-zV6_9-W0SDvhNL577TWw512qG7MZrES_SqJQwgbcDKsPqqU--3-GfBMXjOMf8VDe-ATse01Es_hO8V4BRQOJ6OrSBFhTKkz9gKZuNLymHp7nVSk51iiJd4ql-XAjCmYczBJoAjgXv62kuiY89rCjM Default output format (json/table) [table]: > table Profile configured successfully. To use this profile, add the --profile option to your command: `spinupwp servers:list --profile=hellfishmedia`
To run a command using a specific profile, pass the profile option:
$ spinupwp servers:list --profile=hellfishmedia +-----+-----------------------------+---------------------+--------+-----------------+ | ID | Name | IP Address | Ubuntu | Database Server | +-----+-----------------------------+---------------------+--------+-----------------+ | 246 | staging.hellfish.media | 167.99.208.124 | 20.04 | mysql-8.0 | | 245 | hellfish.media | 68.183.3.238 | 20.04 | mysql-8.0 | +-----+-----------------------------+---------------------+--------+-----------------+
The CLI tool is great for viewing details about your server and site resources. It also puts some powerful tools to your fingertips. With it, you can easily perform many common tasks, such as rebooting MySQL on any server with a single command:
abraham@macbookpro:~$ spinupwp services:mysql 245 Are you sure you want to restart MySQL on "hellfish.media"? (yes/no) [yes]: > yes ==> Server queued for MySQL restart. Event ID Server 3184 hellfish.media
The same command allows you to reboot Nginx or PHP by replacing mysql
with nginx
or php
. You can even apply the reboot to all of your servers at the same time by replacing the <server_id>
with --all
.
abraham@macbookpro:~$ spinupwp services:mysql --all Are you sure you want to restart MySQL on all servers? (yes/no) [yes]: > yes ==> Servers queued for MySQL restart. Event ID Server 3185 staging.hellfish.media 3186 hellfish.media
You can also use the CLI to SSH into any of your servers:
abraham@macbookpro:~$ spinupwp servers:ssh Which server would you like to start an SSH session for: [246] staging.hellfish.media [245] hellfish.media > 246 Which user would you like to connect as: > abraham Establishing a secure connection to [staging.hellfish.media] as [abraham]... Last login: Thu Mar 31 14:31:46 2022 from 108.160.234.169 To run a command as administrator (user "root"), use "sudo". See "man sudo_root" for details.
The SpinupWP CLI also simplifies the process of adding sites to an existing server with interactive prompts to gather all the same details you’d normally provide:
abraham@macbookpro:~$ spinupwp sites:create 246 Are you sure you want to deploy to "staging.hellfish.media "? (yes/no) [yes]: > yes What files would you like SpinupWP to install? [WordPress]: [wp ] WordPress [blank] Don't Install Any Files > wp Primary Domain: > staging.hellfish.media Enable HTTPS (yes/no) [yes]: > no Site User [staginghellfishmedia]: > staging Database Name [staginghellfishmedia]: > staging Database Username [staginghellfishmedia]: > staging Database Password [XXXXXXXXXXXX]: > WordPress Title: > Hellfish Media WordPress Admin Email: > abraham@hellfish.media WordPress Admin Username: > abraham WordPress Admin Password [XXXXXXXXXXXX]: > PHP Version [8.0]: [0] 8.0 [1] 7.4 > 0 Enable Page Cache (yes/no) [yes]: > yes ==> Site queued for creation. Event ID Site Database Password WordPress Admin Password 3190 staging.hellfish.media XXXXXXXXXXXX XXXXXXXXXXXX spinupwp sites:create
The same site creation can be achieved using arguments instead of interactive prompts:
abraham@macbookpro:~$ spinupwp sites:create 246 --installation-method=”wp” --domain="staging.hellfish.media" --https-enabled --site-user="staging" --db-name="staging" --db-user="staging" --db-pass="XXXXXXXXXXXX" --wp-title="Hellfish Media" --wp-admin-email="abraham@hellfish.media" --wp-admin-user="abraham" --wp-admin-pass="XXXXXXXXXXXX" --php-version="8.0" --page-cache-enabled –force
Deleting sites is just as easy:
abraham@macbookpro:~$ spinupwp sites:delete 1204 *********************************************************** * You're about to delete "staging.hellfish.media" * *********************************************************** Do you wish to continue? (yes/no) [no]: > yes ==> Site queued for deletion. Event ID Domain 3191 staging.hellfish.media
Currently, the SpinupWP CLI also has commands for purging page and object caches, running Git deployments, and more. For a full list of commands, please visit the documentation on GitHub.
We’ll continue to build on the SpinupWP CLI and add functionality. Let us know about features you’d like to see!