In DirectAdmin, you can set OpenLiteSpeed to reload automatically after .htaccess changes.
Automatic OpenLiteSpeed reload with DirectAdmin
To set up automatic OpenLiteSpeed reloads with DirectAdmin, follow these steps:
- Log in to your DirectAdmin server as root via SSH.
- Create a new file named
/usr/local/directadmin/scripts/custom/autoreload.sh
using your preferred text editor. - Paste the following code into the file:
#!/bin/sh
/usr/local/lsws/bin/lswsctrl reload
- Save and close the file.
- Make the script executable by running the command:
chmod +x /usr/local/directadmin/scripts/custom/autoreload.sh
- Edit the DirectAdmin configuration file
/usr/local/directadmin/conf/directadmin.conf
. Find the following lines:
crontask_frequency=5
crontask_hours=
crontask_days=
- Change
crontask_hours
to0
. - Change
crontask_days
to*
. - Add a new line below it, containing the following text:
cronjobkey10='*/5 * * * * root /usr/local/directadmin/scripts/custom/autoreload.sh >/dev/null 2>&1'
- Save and close the file.
- Restart DirectAdmin by running the command:
service directadmin restart
After completing these steps, OpenLiteSpeed will automatically reload every 5 minutes on your DirectAdmin server.
I hope this helps! Let me know if you have any questions or concerns.
Automatic OpenLiteSpeed reload with DirectAdmin
Currently, OpenLiteSpeed will read .htaccess at start time, so if some new .htaccess files are created or existing files have been modified, the changes will not take effect until OpenLiteSpeed is started again. Please note that DirectAdmin offers customers the ability to reload OpenLiteSpeed directly from the user level and do this automatically for any .htaccess files edited in File Manager. However, if you want to set up a cron job that will reload OpenLiteSpeed every 3 minutes (for example) to check for any newer .htaccess files, you can create a cron job like this:
*/3 * * * * root if ! find /home/*/domains/*/*_html/ -maxdepth 2 -type f -newer /usr/local/lsws/cgid -name '.htaccess' -exec false {} +; then systemctl restart lsws; fi
You can add the above line to /etc/cron.d/openlitespeed_htaccess_scan . It will scan .htaccess files in the public_html/private_html directories, with a maximum of 2 directory levels. The maximum level can be changed to 3 or more (even unlimited), but please note that it may slow down the scan.