Using WP CLI can be very helpful for a variety of management tasks.
Sites in FlyWP reside in the home directory. You can verify this by using the pwd
command; You will be in the /home/fly
directory. By using ls
command, you’ll find all the available sites on your server.
If my domain is domain.
tld, then the change directory will look like the following command (change it as per your website’s name)
cd domain.tld
First, we will get inside the containers own shell to run these commands.
Now if you have an NGINX site, you can run WP CLI like this:
docker compose exec php wp
Or if you have an OpenLiteSpeed site;
docker compose exec --user=www-data openlitespeed wp
From there for example, showing all post list in an NGINX site:
docker compose exec php wp post list
For OpenLiteSpeed,
docker compose exec --user=www-data openlitespeed wp post list
Alternatively, if the docker compose command seems too long for your, you can go inside the container and run wp commands as usual.
For Nginx site,
docker compose exec php bash
For OpenLiteSpeed,
docker compose exec openlitespeed bash
…and now as you’re inside the container. You will be able to run wp commands like you’re used to.
wp cli version
Example
# Display the version currently installed.
$ wp cli version
WP-CLI 2.10.0