We recently moved our websites from a Linux-Apache-MySQL-PHP (LAMP) server to individual OpenLiteSpeed servers. Hosting costs were one consideration, but it was mainly the performance boost that sold us on OpenLiteSpeed. One of the costs of moving is learning how to configure an unfamiliar server architecture. But then, learning new stuff can be beneficial as well. You probably agree, or you wouldn’t be reading this tutorial.
OpenLiteSpeed is similar to LAMP, so the configuration tasks are often identical, or nearly so. But there are some “gotchas,” such as the location of PHP. Depending on the version of PHP you are running, in OpenLiteSpeed the binary file is located at /usr/local/lsws/lsphp††/bin/lsphp
where ††
is the version number, e.g., if you are running PHP 7.3, the binary is located at /usr/local/lsws/lsphp73/bin/lsphp
.
The Problem with WordPress Cron
WordPress cron (WP-cron) does not run continuously. Instead, the wp-cron.php
runs every time a page loads. On high-traffic sites this can overwhelm server resources. Conversely, on low-traffic sites, schedules might easily be missed since no one has loaded a page.
To disable WP-cron and enable PHP cron:
- Add
define('DISABLE_WP_CRON', 'true');
towp-config.php
. - Edit the crontab for the www-data user:
- In the command line, enter
sudo crontab -u www-data -e
. This will open the editor. - Paste the following lines. Important! Replace †† with the actual PHP version number and replace
/path/to/wordpress/wp-cron.php
with the actual path to your wordpress installation.# WP cron disabled; using real cron via PHP instead. Runs every 5 minutes. */5 * * * * /usr/local/lsws/lsphp††/bin/lsphp /path/to/wordpress/wp-cron.php > /dev/null 2>&1 # Crontab must end on a blank line. Ensure that such a line exists after this comment
- In the command line, enter
- Save and exit the editor. PHP cron is now enabled.
If you need to test whether your cron job is working, follow these instructions, replacing PHP
with the file path to the real PHP executable.
Very nice, tks!