Blog / Others/ LiteSpeed Web Server: Basic Configuration and Optimization Guide

LiteSpeed Web Server: Basic Configuration and Optimization Guide

LiteSpeed Web Server 基础配置与优化指南(版)

This guide is based on practical configuration and usage experience with LiteSpeed Web Server (LSWS). LiteSpeed is renowned for its high performance and high compatibility with Apache. Its free edition (LiteSpeed Web Server Starter), despite having connection limits, still delivers excellent performance for personal blogs and small websites.

Initial Login and Interface Overview

After installing the LiteSpeed environment (e.g., LLsmp, OpenLiteSpeed, or via cPanel/DirectAdmin integration), access the admin interface via your browser at the management port (default: http://server_ip:7080). Enter the administrator credentials to access the LiteSpeed WebAdmin Console.

Core Configuration Explained

The following configuration paths are located under the Home → Configuration menu in the WebAdmin Console.

1. General Settings

Typically, the default settings can be kept unless specific requirements exist (e.g., changing the server identifier).

2. Log Settings

Keep the default settings; log paths and rotation policies are usually optimized.

3. Performance Tuning

This is a crucial section for optimizing the free edition:

  • Max Connections: Recommended to set to 2000. While the free edition has a hard limit of 150 worker threads, this parameter defines the total connection queue length the server can accept. Setting it higher helps handle traffic spikes better.
  • Smart Keep-Alive: Strongly recommended to change from the default "No" to "Yes". This feature reuses idle HTTP connections, significantly reducing the overhead of establishing new connections, thereby saving server resources and improving response speed.

4. Security Settings

Server-level security policies are usually kept at default. More granular security rules (e.g., hotlink protection, IP allow/deny lists) are best configured individually at the Virtual Host level.

5. Request Filter

Can be used to set rules to defend against common web attacks like SQL injection and Cross-Site Scripting (XSS). Enable and configure filtering rules as needed.

6. External Application

Used to define external processors like PHP or Ruby. If using the standard LSAPI (LiteSpeed SAPI) method to connect PHP, no changes are typically needed. To configure multiple PHP versions, add them here.

7. Ruby on Rails Application Configuration

If your server hosts Ruby on Rails applications, pay attention to these sub-items:

  • Max Connections: Adjust based on server memory.
    • 512MB VPS: Recommended 10
    • 256MB VPS: Recommended 5
    • 128MB VPS: Maximum 3
  • Environment: It is recommended to add the environment variables LSAPI_MAX_REQS=1000 and LSAPI_MAX_IDLE=60 to control the maximum requests per process and idle timeout.
  • Run On Start Up: Set to "Yes" to ensure the Rails application processor starts automatically after a service restart.

Admin Port Security Hardening

Path: Home → Web Console → AdminListeners (1) → View/Edit

To enhance security, it is strongly recommended to change the default admin port (7080):

  1. In Admin Listener Address Settings, find the Port setting.
  2. Change it to a non-standard port between 10000 and 50000 (e.g., 23456). Note: Ensure the new port does not conflict with other services on the system.
  3. After the change, all subsequent management access must use the new port, e.g., http://server_ip:23456.

Applying Configuration and Restarting Service

After making any configuration changes above, you must follow these steps to apply them:

  1. Click the Save button in the top-right corner of the page.
  2. After saving, a yellow notification bar will appear at the top: "Configuration has been modified. To apply changes, please visit Control Panel and execute a Graceful Restart."
  3. At the end of this notification, click the Apply Changes link.
  4. On the confirmation page that appears, click the Graceful Restart button (or the restart icon next to it). This performs a smooth restart of the LiteSpeed service without affecting active connections.

Note: This guide is based on the latest LiteSpeed WebAdmin interface. Some option names or locations may vary slightly with updates, but the core logic remains consistent.

Post a Comment

Your email will not be published. Required fields are marked with *.