LiteSpeed and OpenLiteSpeed
This page is for hosting companies whose shared or managed hosting runs on LiteSpeed or OpenLiteSpeed. It answers: whether Exponential runs there, which rules to use, what the code knows about LiteSpeed, and what to test before a plan goes on sale. LiteSpeed's own menus and settings are not described here; check your LiteSpeed documentation for them.
Warning
.htaccess slows down every request. When .htaccess files are enabled (AllowOverride anything but None), let alone
used, Apache looks for them and reads and evaluates them on every request, in every directory of the path, and
page loading times go up drastically (measured). The only real fix is to switch the feature off for
the virtual host: AllowOverride None in the HTTPS virtual host, and the rules in the virtual host's own
configuration as mod_rewrite rules. That is far faster in production speed tests and well worth the time it takes
to optimize a production configuration. Switch over right away: copy the rules of the
example HTTPS virtual host into your virtual host (with the static cache, also
staticcache_offload.conf), set AllowOverride None, run apachectl configtest, reload Apache and
test the site. The same rules for other servers: nginx, LiteSpeed,
Caddy, IIS, Velocity (built in); where virtual host rules go in a control
panel: Plesk, cPanel, DirectAdmin, ISPConfig.
On LiteSpeed or OpenLiteSpeed, the server's own page cache can also answer anonymous visitors and crawlers without PHP: Page caching with LiteSpeed and OpenLiteSpeed.
Contents
- What the sources say
- Setting a site up
- PHP under LiteSpeed
- What to test before selling a plan
- Velocity on a LiteSpeed host
- The page cache of LiteSpeed
- Checklist
What the sources say
| Source | Statement |
|---|---|
README.md, "The traditional options" | LiteSpeed and OpenLiteSpeed have an ".htaccess-compatible rewrite engine" that "reads Apache rules directly in most cases" |
README.md, "When a traditional server is still the right answer" | where the hosting does not allow a long-lived process, "Apache or LiteSpeed with .htaccess is the answer" |
| Operating system support, Web servers | LiteSpeed and OpenLiteSpeed: tier 3, expected to work; "reads Apache's rewrite rules in most cases" |
| Operating system support, PHP SAPIs | LiteSpeed (litespeed, LSAPI): "LiteSpeed's own SAPI" |
lib/ezutils/classes/ezexecution.php | under LiteSpeed (lsapi) the shutdown function runs in the PHP binary's directory, which open_basedir does not allow; the kernel copes with that |
Tier 3 means "a reasoned expectation, not a test result" (The four tiers): the project has not watched Exponential run on LiteSpeed in its own tests. "In most cases" is the honest wording; test your own LiteSpeed version.
Setting a site up
Document root is the installation root, the directory with
index.php.Rewrite rules: copy the shipped rules, as for Apache:
cp .htaccess_root .htaccessor, as the site's user,
./console exp:setup:htaccess --apply(Setting up .htaccess and config.php from the console). LiteSpeed Enterprise reads it on the next request. OpenLiteSpeed reads only the rewrite rules, only withautoLoadHtaccesson and only after a restart; put the rules in its virtual host instead (LiteSpeed example). Use.htaccess_root_staticinstead (--static) only when the site serves a generated static cache (Static cache).PHP: 8.0 or later with the required extensions (Chapter 2),
memory_limitat least 64M (the setup wizard's floor; give production more),date.timezoneset,file_uploadson (Chapter 2, php.ini settings).Writable directories:
var/and thesettings/directories, written by one user (Writable directories and permissions).Install with the setup wizard in the browser when the customer has no shell, or with
exp:installor the kickstarter where a shell is available (One-click installers).
PHP under LiteSpeed
- The SAPI is
litespeed(LSAPI). The web PHP and the command-line PHP are configured separately and are often different builds: give both the same version and extensions (Chapter 2, Command line and web PHP). - The setup wizard's optional test wants
open_basedirempty. Shared hosting often sets it; the kernel already handles the LSAPI shutdown directory underopen_basedir, but other features (for example the background preload run, which needsproc_open,setsidand the PHP binary) may be refused by it (Preloading caches, section 7). - Exponential identifies the server it runs under: the system report (
expSystemReport::serverKind()) classifies a LiteSpeed SAPI asother, and the debug bar says "Served by" the server, the SAPI and the port, "not by Velocity", so support staff can see at a glance what answered.
What to test before selling a plan
Run the four routing checks of Web servers and engines first. Then:
| Test | Why |
|---|---|
The front page, a content page and /user/login answer | the rewrite to index.php works |
/api/ reaches index_rest.php and /content/treemenu reaches index_treemenu.php | the two other front controllers of .htaccess_root |
| An uploaded image is shown, an uploaded file downloads | storage paths and content/download |
.php below the root answers 404 | "No PHP file runs because its path was asked for" (Chapter 8) |
| A cronjob runs from the customer's crontab | runcronjobs.php under the CLI PHP (Cron jobs) |
| A cache clear in Setup > Caches works | var/ is writable by the web PHP |
Velocity on a LiteSpeed host
Velocity is a long-running process; on shared LiteSpeed hosting it is usually not allowed. On a LiteSpeed server
that you control, Velocity can run beside it on its own ports and the LiteSpeed server can act as a reverse proxy, the
same shape as with Apache or nginx (Velocity beside Apache or nginx). The proxy
must be trusted and must set X-Forwarded-Proto (Chapter 8, Behind a reverse proxy).
The page cache of LiteSpeed
LiteSpeed Enterprise and OpenLiteSpeed have a page cache built in. For an Exponential site it is switched on without
any plugin and without code: .htaccess_root carries a commented block (## >>> LiteSpeed page cache) that marks
anonymous GET and HEAD requests without a query string, session cookie or is_logged_in cookie, outside the
administration, user, shop and editing views, for max-age (120) seconds. Removing the first # of each line of the
block switches it on; Apache and nginx ignore it (<IfModule LiteSpeed>). For a virtual host, Plesk's "Additional
directives for HTTPS", cPanel's include files or DirectAdmin's custom configuration there is
litespeed-page-cache.conf; OpenLiteSpeed's cache module
is in the OpenLiteSpeed example.
What a host should know before offering it:
| Question | Answer |
|---|---|
| What has to be on the server | a cache directory: CacheRoot at server level (Enterprise) or the cache module's storagePath (OpenLiteSpeed) |
| Who gets stored pages | anonymous visitors and crawlers only; editors and signed-in members carry a session cookie and always reach PHP |
| What editors see after publishing | the live page; anonymous visitors see the change after at most max-age seconds, because Exponential does not purge LiteSpeed |
| How to check | curl -sI https://example.com/ | grep -i x-litespeed-cache twice: miss, then hit |
| What it saves | a hit takes no PHP process and no database query; crawler bursts become cheap |
Step by step for every panel, purging, troubleshooting and security: Page caching with LiteSpeed and OpenLiteSpeed.
Checklist
- To do:
.htaccesscopied from.htaccess_root; document root is the installation root. - To do: Web and CLI PHP are the same version with the same extensions.
- To do: The routing checks and the tests above pass on a staging account.
- To do:
open_basedireffects on preload and other background runs are known and documented for support. - To do: After each upgrade,
.htaccessis refreshed from the new.htaccess_root(./console exp:setup:htaccessshows the diff;--force --applycopies after a backup). - To do: With the page cache on: a second anonymous request says
X-LiteSpeed-Cache: hit, a signed-in request never does, and customers know themax-agedelay after publishing (Page caching with LiteSpeed and OpenLiteSpeed).
Demo mode on LiteSpeed. LiteSpeed reads SetEnv in .htaccess like Apache and passes it to lsphp: SetEnv EXP_DEMO_MODE 1 in a public demo's .htaccess switches demo mode on for its web requests, and security.log then shows demo/mode on ... sapi=litespeed. Recipe: run a public demo on LiteSpeed and Plesk.
Related pages
- Apache with PHP-FPM
- Shared hosting
- Choosing a web server
- Operating system support
- Setting up .htaccess and config.php from the console
- Free documentation: this page is free to copy, translate and improve under the GNU FDL 1.3.
Become an Exponential Partner
Partners share their information, provide funding, contribute back and develop the products with us, and that is how Exponential grows. A partner website and dashboard are planned for mid-2027: please become a partner today to speed up our growth rate and land new features faster.