Tag: command line

  • WpW: Exploring LiteSpeed’s WHM Plugin CLI Script

    WpW: Exploring LiteSpeed’s WHM Plugin CLI Script

    Welcome to another (our 30th!) installment of WordPress Wednesday!

    Back in June we talked about the things you could do with our WHM plugin’s CLI script. At that time, the script was limited to two commands: scan and enable. Today, there are an additional six commands to talk about! Let’s jump right in, shall we?

    setversion

    setversion [--list] | [--latest] | [$VERSION]
    This command lists or sets the active LSCWP version. The active version of the plugin is not necessarily the most recent release. It’s the version that you have chosen to be the default version on all of your installations. You can set the active version to be the most recent release with the --latest parameter, or you can specify an earlier version of your choice.

    Examples
    Display the currently active version:

    ./lscmctl setversion

    Display currently-available versions:

    ./lscmctl setversion --list

    Switch to the latest available version:

    ./lscmctl setversion --latest

    Set the currently active version to 1.6.3:

    ./lscmctl setversion 1.6.3

    disable

    disable -m | $WP_PATH
    Disable the LSCWP plugin. The -m parameter, for all commands where it is an option, always refers to “mass.” It should be used whenever you want to run a command for all known (and unflagged) installations.

    Examples
    Disable LSCWP in all discovered WordPress installations:

    ./lscmctl disable -m

    Disable LSCWP only in user Larry’s WP installation:

    ./lscmctl disable /home/larry/public_html/wp

    upgrade

    upgrade -m | $WP_PATH
    Upgrade LSCWP to the current active version. Usage is similar to that of disable.

    Example
    Upgrade LSCWP only in user Liz’s installation:

    ./lscmctl upgrade /home/liz/public_html/wp

    flag

    flag $WP_PATH
    Flag a single WordPress installation. Flagged installations will be skipped during mass operations.

    unflag

    unflag $WP_PATH
    Unflag a single WordPress installation. Unflagging a previously-flagged installation will allow it to once again be included in subsequent mass operations.

    status

    status $WP_PATH
    This command answers the following questions about the given WordPress installation:

    • Is this installation unflagged? flagged? flagged due to some error?
    • Is LSCWP enabled or disabled in this installation? Is there a conflict with another cache plugin?

    Example
    Get LSCWP status for a single installation:

    ./lscmctl status /home/user/public_html/wp

    These commands make short work of managing your WordPress installations. You can simplify your life even further by hooking some of them into the cron. For instance, you can schedule a ./lscmctl setversion --latest command, followed by a ./lscmctl upgrade -m command to run every Sunday night, so that all of the installations you manage are running the latest version of LSCWP on Monday morning.

    If you feel like you’re missing some of the background for all of this, I suggest you read Autodiscovery, LSCache and the Command Line. We went into quite a bit of detail talking about the CLI script, what it does, and how to automate its functions with cron jobs.

    Do you use our CLI script? Do you have any tricks or useful workflow tips to share? Leave them in the comments!

    —
    Have some of your own ideas for future WordPress Wednesday topics? Leave us a comment!

    Don’t forget to meet us back here next week for the next installment. In the meantime, here are a few other things you can do:

  • WpW: Autodiscovery, LSCache and the Command Line

    WpW: Autodiscovery, LSCache and the Command Line

    Welcome to another installment of WordPress Wednesday!

    Our topics in this series so far, have been mainly aimed at site owners, but today it’s your turn, hosting providers! Today we are going to talk about Autodiscovery through our command-line interface (CLI) script.

    What do I mean by this?

    Shared hosting providers love our WHM plugin’s web cache manager. It allows for autodiscovery of clients’ new WordPress installations and mass enabling of LiteSpeed Cache for all accounts. As more and more accounts are added, more and more hosts have requested to automate this via a CLI script.

    So, since LiteSpeed Web Server v 5.1.14, cPanel users who have the WHM plugin installed have had access to a nifty script that can be run from the command line. This script will automatically discover all of the WordPress installations on the server, and optionally enable LiteSpeed Cache for WordPress for each installation. It can be run by the cron as well, so that you can auto-discover and auto-enable on a schedule.

    Why would you want to do this?

    We’ve discussed before a few of the benefits to having your WordPress installation running our LSCache plugin. Now imagine you are providing hosting to dozens, hundreds, maybe even thousands of WordPress sites. Wouldn’t you want each of those sites to be using as few resources as possible, to keep everything running quickly and smoothly? Enabling LSCache on all of your clients’ sites allows you to host more sites on the same equipment you already own – no extra investment in hardware.

    As a busy hosting provider, you don’t have time to manually enable plugins on each and every site. That’s where the CLI comes in.

    With the CLI, you can auto-discover new WordPress installations and auto-enable the LSCache plugin, all without leaving the comfort of your simple command prompt. What a time saver! You can make it even less labor-intensive by hooking it into the cron. Every night at 3am, while you sleep, LiteSpeed Cache could be quietly enabled in all of the previous day’s new WordPress sites. Sweet dreams!

    How does it work?

    First, make sure you’re using cPanel and the WHM plugin.

    Then, locate the script at /usr/local/lsws/admin/misc/lscmctl, and you’re good to go.

    The CLI takes a command and a few possible parameters like so:

    ./lscmctl [-php path/to/php] command [flag/parameter]
    

    You can pass in the location of your preferred PHP binary, if necessary, via the -php flag, where path/to/php is, you guessed it, the path to your PHP executable.

    Let’s look at the commands you can use.

    Scan (Autodiscover)

    You can scan for all WordPress installations (and optionally enable the LSCache plugin) through the appropriately-named scan command.

    This command creates a lsc_manager_data file under the .../lsws/admin/lscdata directory, which contains information on all of the installations that are discovered.

    There are two options you can use with the scan command:

    • -n only discovers installations that are new since the last scan
    • -e enables the LSCache plugin on all discovered installations after scanning is complete

    Examples

    Discover all installations:

    ./lscmctl scan
    

    Discover new installations only:

    ./lscmctl scan -n
    

    Discover new installations and enable LSCache on them:

    ./lscmctl scan -n -e
    

    Notes

    When a site is discovered, the user’s home directory and the site’s document root are remembered. If a scan for new installations only (scan -n) is then run, it ignores this home directory/document root combination because it has already been discovered.

    This is usually not a problem, but there is one situation where it could be: Say a user, who already has one or more WP sites, installs a new one under an existing document root. That new site will not be found, because that home directory and document root were already previously discovered.

    For this reason, it’s recommended that you run a full scan once in a while, to catch these fringe cases that may have slipped through the cracks of a scan -n.

    Additionally, please keep in mind that autodiscovery only works two levels deep. So, it will find installations in path/doc-root, or path/doc-root/subdir, but not in path/doc-root/subdir/subdir.

    Enable

    The enable command is used to turn on the LSCache plugin on all discovered WordPress installations without running a new scan first.

    There is currently one option you can use with the enable command:

    • -m stands for “mass” and indicates that you want to enable to whole lot at once

    Example

    Enable LSCWP for all previously-discovered WordPress installations:

    ./lscmctl enable -m
    

    Notes

    When running the enable -m command, there are two situations where LSCache may fail to be enabled on a particular site:

    1. The site has opted out of LSCache. The WHM plugin provides the ability to “flag” a particular site so that it is skipped during a mass enable.
    2. The site has been auto-flagged to be skipped. This is usually caused by the detection of another cache plugin, but can sometimes also be triggered by an unspecified error with WordPress.

    Hands-Off Autodiscovery and Enabling

    Now that you know how all of this works, you’re probably thinking, “I don’t want to have to run this every single day by hand.” Well, you’re in luck. You can have the cron take care of the whole thing.

    Let’s say you want to do autodiscovery of new installations once-a-day, and you want to enable LSCWP for each of those newly-discovered installations.

    That’s a ./lscmctl scan -n -e command, which can be easily added to the cron.

    Enter crontab -e at the command-line prompt, and add the following line to the file:

    00 03 * * * /usr/local/lsws/admin/misc/lscmctl scan -n -e
    

    The 00 and 03 represent minute 00 and hour 03 (aka 3am). If you prefer a different time of day, you would change those numbers. If you’re unfamiliar with crontab syntax, you might want to take a look at this post, where we discussed it some detail.

    What if you’re not a cPanel user?

    It’s true that we have started with cPanel, but our goal is to make the CLI script available for users of all of our control panel plugins, including Plesk. So stay tuned, if this is you!

    So, hosting providers, what do you think?

    You can use the command-line interface to easily keep LiteSpeed Cache enabled on all of your clients’ WordPress sites, including brand new installations. Even better, you can hook this process into the cron so that the entire thing is nicely-automated.

    Be sure to leave a comment on this post, or contact us for support, if you have any questions about what the CLI script can do to speed up both your users’ sites and your own administrative tasks!

    [2019 update: there are additional commands beyond what are mentioned here. Please visit our wiki to learn what else you can do with the CLI script.]

    —

    Have some of your own ideas for future WordPress Wednesday topics? Leave us a comment!

    Don’t forget to meet us back here next week for the next installment. In the meantime, here are a few other things you can do:

  • Cache Makes the World Go Round

    Cache Makes the World Go Round

    First, we would like to thank each and every one of you for trying out LiteSpeed Cache for WordPress. We’re proud to see that there are 30,000+ active WordPress sites running LiteSpeed Cache. There was an enormous effort to make this plugin the easiest and most efficient caching solution for both WordPress users and hosts. Our latest release of 1.0.14.1 includes some exciting User Interface changes that hopefully simplify things for the administrator/user.

    (more…)

  • The lsup Command: Update Many Installations in One Stroke

    The lsup Command: Update Many Installations in One Stroke

    We’re adding more command line functions to make it easier to automate multiple installations of LSWS. With that in mind, we introduce the lsup command: lsup allows you to upgrade (or downgrade) your version of LSWS from the command line. The executable is located at $SERVER_ROOT/admin/misc/lsup.sh. Running this basic command automatically upgrades your installation of LSWS to the autoupdate release. (This does not mean the latest release, but the latest release that has been deemed stable enough for autoupdate.) In a basic installation on CentOS, this command would thus be:

    /usr/local/lsws/admin/misc/lsup.sh

    The command can be further customized to upgrade to, downgrade to, or reinstall specific versions. These options are explained in the lsup wiki article.

    This command was the result of requests from our users. If there are other functions you want to see, please let us know.