LiteSpeed Web Server
Commercial high-performance web server. Maintains Apache compatibility while achieving significant speed improvements. Particularly excels with WordPress sites. Features event-driven architecture and early HTTP/3 adoption.
LiteSpeed Web Server
LiteSpeed Web Server is a commercial high-performance web server developed by LiteSpeed Technologies. It maintains compatibility with Apache HTTP Server while achieving significant performance improvements, particularly gaining attention for accelerating WordPress sites.
Overview
LiteSpeed Web Server was designed to solve traditional web server challenges such as concurrent connection limits and performance degradation under high load. While maintaining Apache-compatible configuration, it achieves up to 84 times faster processing and currently holds a 12.6% market share.
Technical Features
Architecture
- Asynchronous Event-Driven Model: Nginx-like solution to C10K problem
- Apache Compatibility: .htaccess and mod_rewrite functionality works
- Process/Worker Hybrid: Balances stability and performance
Performance
- High-Speed Processing: Achieves 84x faster performance compared to Apache
- Memory Efficiency: Low resource consumption through efficient memory usage
- HTTP/3 Support: Industry-leading early support for HTTP/3 protocol
Advantages
High Performance
- Exceptional Speed: Up to 84 times faster than Apache HTTP Server
- Low Memory Usage: Memory management efficiency comparable to Nginx
- High Concurrent Connections: Stable handling of tens of thousands of concurrent connections
Apache Compatibility
- Existing Configuration Utilization: .htaccess files can be used as-is
- mod_rewrite Support: Apache URL rewriting rules work
- Smooth Migration: Easy migration from Apache
Advanced Features
- HTTP/3 Support: Industry-leading protocol support
- WordPress Optimization: WordPress-specific acceleration features
- LSCache Plugin: Dedicated caching system
Disadvantages
Licensing
- Commercial License: Paid license required (OpenLiteSpeed is free version)
- Cost: Expensive licensing fees for enterprise use
- Limitations: Free OpenLiteSpeed version has feature restrictions
Learning Cost
- Unique Features: LiteSpeed-specific configuration items
- Documentation: Not as comprehensive as Apache information
- Community: Relatively small user community
Basic Code Examples
OpenLiteSpeed CMake Configuration
# OpenLiteSpeed Lua module configuration
cmake_minimum_required(VERSION 3.0)
INCLUDE(${PROJECT_SOURCE_DIR}/CMakeModules/common.cmake)
# LuaJIT configuration
set(LUAJITDIR "${PROJECT_SOURCE_DIR}/../third-party/include/luajit-2.1/")
include_directories(${LUAJITDIR})
# Compilation flags configuration
set(CMAKE_VERBOSE_MAKEFILE ON)
set(MY_CMAKE_WARNING_FLAGS " -Wall -Wextra -Wno-unused-parameter")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${MY_CMAKE_WARNING_FLAGS}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${MY_CMAKE_WARNING_FLAGS}")
# Source files definition
set(lua_STAT_SRCS
lsluaengine.cpp
edluastream.cpp
lsluaapi.cpp
lsluasession.cpp
lsluaheader.cpp
lsluashared.cpp
lsluaregex.cpp
modlua.cpp
)
# Library creation
add_library(mod_lua MODULE ${lua_STAT_SRCS} ${LUAJITHEADERS})
target_link_libraries(mod_lua libluajit.a
-nodefaultlibs libstdc++.a
pthread rt
${LIBSAN} crypt m gcc_eh c c_nonshared gcc)
set_target_properties(mod_lua PROPERTIES PREFIX "")
Virtual Host Configuration
<!-- Virtual Host Configuration -->
<virtualHost>
<name>example.com</name>
<vhRoot>/var/www/example.com/</vhRoot>
<configFile>$VH_ROOT/conf/vhconf.conf</configFile>
<allowSymbolLink>1</allowSymbolLink>
<enableScript>1</enableScript>
<restrained>1</restrained>
<setUIDMode>2</setUIDMode>
<!-- Document Root -->
<docRoot>$VH_ROOT/public_html/</docRoot>
<index>
<autoIndex>0</autoIndex>
<indexFiles>index.php, index.html</indexFiles>
</index>
<!-- Error Pages -->
<errorPage>
<errCode>404</errCode>
<url>/error404.html</url>
</errorPage>
<!-- Access Control -->
<accessControl>
<allow>*</allow>
<deny></deny>
</accessControl>
</virtualHost>
.htaccess Compatible Configuration
# Apache .htaccess works with LiteSpeed
RewriteEngine On
# WordPress Pretty URLs
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
# LSCache configuration (LiteSpeed specific)
<IfModule LiteSpeed>
CacheLookup public on
CacheEnable public /
CacheHeader on
CacheTTL 1800
# WordPress optimization
CacheKeyModify -qs:utm*
CacheKeyModify -qs:gclid
CacheKeyModify -qs:fbclid
</IfModule>
# Browser caching
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType text/css "access plus 1 month"
ExpiresByType application/javascript "access plus 1 month"
ExpiresByType image/png "access plus 1 month"
ExpiresByType image/jpg "access plus 1 month"
ExpiresByType image/jpeg "access plus 1 month"
ExpiresByType image/gif "access plus 1 month"
</IfModule>
Docker Compose Configuration
version: '3.8'
services:
openlitespeed:
image: litespeedtech/openlitespeed:latest
ports:
- "80:80"
- "443:443"
- "7080:7080" # Admin Console
volumes:
- ./websites:/usr/local/lsws/Example/html/
- ./lsws-config:/usr/local/lsws/conf/
- ./logs:/usr/local/lsws/logs/
environment:
- SERVER_ROOT=/usr/local/lsws
- [email protected]
restart: unless-stopped
# PHP configuration
php:
image: litespeedtech/openlitespeed:latest-php81
volumes:
- ./websites:/var/www/html/
- ./php-config:/usr/local/lsws/lsphp81/etc/php/8.1/litespeed/
environment:
- PHP_VERSION=81
- OPCACHE_ENABLE=1
- MEMCACHED_ENABLE=1
depends_on:
- openlitespeed
Main Server Configuration (httpd_config.conf)
<httpServerConfig>
<!-- Server basic configuration -->
<serverName>LiteSpeed Web Server</serverName>
<user>lsadm</user>
<group>lsadm</group>
<priority>0</priority>
<inMemBufSize>60M</inMemBufSize>
<swappingDir>/tmp/lshttpd/swap</swappingDir>
<autoFix503>1</autoFix503>
<!-- Network configuration -->
<mime>$SERVER_ROOT/conf/mime.properties</mime>
<showVersionNumber>0</showVersionNumber>
<adminEmails>[email protected]</adminEmails>
<indexFiles>index.html, index.php</indexFiles>
<autoIndex>0</autoIndex>
<!-- Performance configuration -->
<maxConnections>2000</maxConnections>
<maxSSLConnections>200</maxSSLConnections>
<connTimeout>300</connTimeout>
<maxKeepAliveReq>1000</maxKeepAliveReq>
<keepAliveTimeout>5</keepAliveTimeout>
<sndBufSize>0</sndBufSize>
<rcvBufSize>0</rcvBufSize>
<!-- Log configuration -->
<errorlog>
<logLevel>WARN</logLevel>
<debugLevel>0</debugLevel>
<logPath>$SERVER_ROOT/logs/error.log</logPath>
<enableStderrLog>1</enableStderrLog>
</errorlog>
<accesslog>
<logPath>$SERVER_ROOT/logs/access.log</accessPath>
<logFormat>%h %l %u %t "%r" %>s %b "%{Referer}i" "%{User-Agent}i"</logFormat>
<logHeaders>7</logHeaders>
<rollingSize>10M</rollingSize>
<keepDays>30</keepDays>
</accesslog>
</httpServerConfig>
Cache Configuration (LSCache)
<cache>
<cacheRoot>/usr/local/lsws/cachedata</cacheRoot>
<cachePolicy>
<enableCache>1</enableCache>
<qsCache>1</qsCache>
<reqCookieCache>1</reqCookieCache>
<respCookieCache>1</respCookieCache>
<ignoreReqCacheCtrl>1</ignoreReqCacheCtrl>
<ignoreRespCacheCtrl>0</ignoreRespCacheCtrl>
<enablePrivateCache>0</enablePrivateCache>
<privateAge>1000</privateAge>
<maxCacheObjSize>10000000</maxCacheObjSize>
<expireInSeconds>200</expireInSeconds>
<enableStale>200</enableStale>
</cachePolicy>
<!-- Cache storage configuration -->
<cacheStoragePolicy>
<cacheStoreDir>/usr/local/lsws/cachedata/$VH_NAME</cacheStoreDir>
<cacheStorePolicy>0</cacheStorePolicy>
</cacheStoragePolicy>
</cache>