Reload OpenLiteSpeed Automatically with DirectAdmin

You are here:
< Back

Reload OpenLiteSpeed Automatically with DirectAdmin

Under DirectAdmin, you can set up OpenLiteSpeed to reload automatically after .htaccess changes.

Currently OpenLiteSpeed reads .htaccess at starting time, so if some new .htaccess files are created, or the current ones are modified, changes will not go into effect until OpenLiteSpeed is restarted. Please note that DirectAdmin provides customers the ability to reload OpenLiteSpeed directly from the user level, and does this automatically for any .htaccess files edited in File Manager. However, if you would like to set up a cron job that would reload OpenLiteSpeed every 3 minutes (for example) to check for any newer .htaccess files, you may create a cron job like so:

 

*/3 * * * * root if ! find /home/*/domains/*/*_html/ -maxdepth 2 -type f -newer /usr/local/lsws/cgid -name '.htaccess' -exec false {} +; then /usr/local/lsws/bin/lswsctrl restart; fi* * root if ! find /home/*/domains/*/*_html/ -maxdepth 2 -type f -newer /usr/local/lsws/cgid -name '.htaccess' -exec false {} +; then /usr/local/lsws/bin/lswsctrl restart; fi

 

You can add the above line to /etc/cron.d/openlitespeed_htaccess_scan. It will scan for .htaccess files in public/private_html folders, with a max depth of 2 folders. Max depth can be changed to 3 or more (even unlimited), but please be aware it could slow down scanning.