LiteSpeed Web Server

商用高性能Webサーバー。Apache互換性を保ちながら大幅な高速化を実現。WordPressサイトで特に高い性能を発揮。イベント駆動アーキテクチャとHTTP/3先行対応。

Webサーバー高性能WordPressHTTP/3商用Apache互換

LiteSpeed Web Server

LiteSpeed Web Serverは、LiteSpeed Technologies社が開発した商用の高性能Webサーバーです。Apache HTTP Serverとの互換性を保ちながら、大幅な性能向上を実現し、特にWordPressサイトでの高速化で注目されています。

概要

LiteSpeed Web Serverは、従来のWebサーバーの課題であった同時接続数の制限や高負荷時のパフォーマンス低下を解決するために設計されました。Apache互換の設定が可能でありながら、最大84倍高速な処理を実現し、現在市場シェア12.6%を獲得しています。

技術的特徴

アーキテクチャ

  • 非同期イベント駆動モデル: NginxライクなC10K問題の解決
  • Apache互換性: .htaccessやmod_rewriteが動作
  • プロセス/ワーカーハイブリッド: 安定性と性能を両立

パフォーマンス

  • 高速処理: Apache比84倍の高速化を実現
  • メモリ効率: 効率的なメモリ使用による低リソース消費
  • HTTP/3対応: 業界最先端のHTTP/3プロトコル先行サポート

長所

高い性能

  • 驚異的な速度: Apache HTTP Serverと比較して最大84倍高速
  • 低メモリ使用: Nginxと同等の効率的なメモリ管理
  • 高い同時接続数: 数万の同時接続を安定して処理

Apache互換性

  • 既存設定の活用: .htaccessファイルをそのまま使用可能
  • mod_rewrite対応: ApacheのURL書き換えルールが動作
  • スムーズな移行: Apacheからの移行が容易

先進的な機能

  • HTTP/3サポート: 業界最先端のプロトコル対応
  • WordPress最適化: WordPress専用の高速化機能
  • LSCacheプラグイン: 専用キャッシュシステム

短所

ライセンス

  • 商用ライセンス: 有料ライセンスが必要(OpenLiteSpeedは無料版)
  • コスト: エンタープライズ利用では高額なライセンス料
  • 制限: 無料版OpenLiteSpeedには機能制限がある

学習コスト

  • 独自機能: LiteSpeed特有の設定項目
  • ドキュメント: Apacheほど豊富ではない情報量
  • コミュニティ: 比較的小さなユーザーコミュニティ

基本的なコード例

OpenLiteSpeed CMake設定

# OpenLiteSpeed Lua モジュール設定
cmake_minimum_required(VERSION 3.0)
INCLUDE(${PROJECT_SOURCE_DIR}/CMakeModules/common.cmake)

# LuaJIT設定
set(LUAJITDIR "${PROJECT_SOURCE_DIR}/../third-party/include/luajit-2.1/")
include_directories(${LUAJITDIR})

# コンパイルフラグ設定
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}")

# ソースファイル定義
set(lua_STAT_SRCS
    lsluaengine.cpp
    edluastream.cpp
    lsluaapi.cpp
    lsluasession.cpp
    lsluaheader.cpp
    lsluashared.cpp
    lsluaregex.cpp
    modlua.cpp
)

# ライブラリ作成
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 -->
<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互換設定

# LiteSpeedでもApacheの.htaccessが動作
RewriteEngine On

# WordPress用Pretty URLs
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

# LSCache設定(LiteSpeed専用)
<IfModule LiteSpeed>
    CacheLookup public on
    CacheEnable public /
    CacheHeader on
    CacheTTL 1800
    
    # WordPress最適化
    CacheKeyModify -qs:utm*
    CacheKeyModify -qs:gclid
    CacheKeyModify -qs:fbclid
</IfModule>

# ブラウザキャッシュ
<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設定

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設定
  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

メインサーバー設定(httpd_config.conf)

<httpServerConfig>
  <!-- サーバー基本設定 -->
  <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>
  
  <!-- ネットワーク設定 -->
  <mime>$SERVER_ROOT/conf/mime.properties</mime>
  <showVersionNumber>0</showVersionNumber>
  <adminEmails>[email protected]</adminEmails>
  <indexFiles>index.html, index.php</indexFiles>
  <autoIndex>0</autoIndex>
  
  <!-- パフォーマンス設定 -->
  <maxConnections>2000</maxConnections>
  <maxSSLConnections>200</maxSSLConnections>
  <connTimeout>300</connTimeout>
  <maxKeepAliveReq>1000</maxKeepAliveReq>
  <keepAliveTimeout>5</keepAliveTimeout>
  <sndBufSize>0</sndBufSize>
  <rcvBufSize>0</rcvBufSize>
  
  <!-- ログ設定 -->
  <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>

キャッシュ設定(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>
  
  <!-- キャッシュストレージ設定 -->
  <cacheStoragePolicy>
    <cacheStoreDir>/usr/local/lsws/cachedata/$VH_NAME</cacheStoreDir>
    <cacheStorePolicy>0</cacheStorePolicy>
  </cacheStoragePolicy>
</cache>

参考リンク