LiteSpeed is a high-performance web server that is becoming increasingly popular as an alternative to Apache. At Theory7, we use LiteSpeed on our servers due to its excellent performance, especially with WordPress. In this guide, we explain how to configure and optimize LiteSpeed so that you get the most out of your hosting.

Why LiteSpeed?

LiteSpeed offers significant advantages that make it an attractive choice for web hosting:

  • Faster than Apache - Thanks to its event-driven architecture, LiteSpeed can handle multiple requests more efficiently, resulting in faster loading times for your website.
  • Drop-in replacement - LiteSpeed can read Apache .htaccess files, making the transition to LiteSpeed easy without needing to rewrite your existing configurations.
  • LSCache - LiteSpeed has built-in caching without needing to install extra plugins, significantly improving your website's performance.
  • Lower resource usage - LiteSpeed consumes less CPU and memory, which is especially beneficial for VPS environments with limited resources.
  • Better WordPress performance - LiteSpeed can be up to 300x faster than Apache, especially for high-traffic WordPress websites.

For high-traffic websites or those with limited resources, LiteSpeed is often the best choice. It offers not only speed but also stability and scalability.

Accessing LiteSpeed WebAdmin

LiteSpeed has a web-based admin panel that is accessible on port 7080:

https://your-server-ip:7080

The default login credentials can be found with the following command:

cat /usr/local/lsws/adminpasswd

Don't forget to change the password after your first login for added security.

Basic Server Configuration

Server Configuration

In the WebAdmin, go to Configuration > Server > General:

  • Server Name: Your hostname
  • Admin Email: For notifications about server status
  • Processes: Leave at 1 for most setups, but increase this if your server receives a lot of traffic.

Connection Settings

Under Server > Tuning:

Max Connections: 2000
Connection Timeout: 300
Keep-Alive Timeout: 5
Max Keep-Alive Requests: 1000

Adjust these settings based on your traffic and available resources. Monitor your server performance to determine if adjustments are needed.

Configuring Virtual Hosts

Document Root

For each virtual host:

  1. Go to Virtual Hosts > [your host]
  2. Click General
  3. Set Document Root: /var/www/yoursite/public

Index Files

Under General > Index Files:

index.php, index.html, index.htm

Rewrite Rules

LiteSpeed reads .htaccess files by default. For additional rules:

  1. Go to Rewrite
  2. Enable Rewrite: Yes
  3. Rewrite Rules: Add as needed

Configuring LSCache

LSCache is LiteSpeed's powerful built-in cache, which can significantly speed up your website.

Activate Cache per Virtual Host

  1. Go to Virtual Hosts > [host] > Cache
  2. Enable Cache: Yes
  3. Cache Root: /var/www/lscache/yoursite
  4. Cache Storage: filesystem

Cache Rules

Basic cache configuration:

checkPublicCache    1
checkPrivateCache   1
cacheStatic         1
maxCacheObjSize     10000000

WordPress with LSCache

For WordPress, install the LiteSpeed Cache plugin:

  1. Install via WordPress admin
  2. Configure cache in plugin settings
  3. LiteSpeed communicates automatically with the plugin

This provides the best WordPress performance without external caching solutions. Don't forget to regularly update the plugin for optimal performance.

PHP Configuration

PHP Handler

LiteSpeed works best with lsphp. Configure under External App:

Name: lsphp82
Address: uds://tmp/lshttpd/lsphp.sock
Max Connections: 35
Environment: PHP_LSAPI_MAX_REQUESTS=500

Per-Site PHP Version

You can configure a different PHP version per virtual host:

  1. Go to Virtual Hosts > [host] > Script Handler
  2. Add handler for php files
  3. Select desired PHP version

SSL Configuration

Installing Certificate

  1. Go to Listeners > [HTTPS] > SSL
  2. Fill in:
    • Private Key File: /path/to/privkey.pem
    • Certificate File: /path/to/fullchain.pem
  3. Click Save

Lets Encrypt Integration

LiteSpeed supports automatic Lets Encrypt certificates. This can be easily done with the following command:

/usr/local/lsws/bin/lswsctrl issue

Or via DirectAdmin if you are using that, which makes the configuration even easier.

Restarting LiteSpeed

After configuration changes, it is important to restart the server:

# Graceful restart (no downtime)
/usr/local/lsws/bin/lswsctrl restart

# Or force
/usr/local/lsws/bin/lswsctrl stop
/usr/local/lsws/bin/lswsctrl start

Performance Tuning

Worker Processes

Under Server > Tuning > Worker Processes:

For servers with multiple CPU cores:

Number of Workers: 2

Connection Tuning

Increase your server's efficiency with the following settings:

Max SSL Connections: 2000
Max Pipelining: 10

Static File Serving

LiteSpeed serves static files very efficiently. Enable gzip compression to further improve loading times:

  1. Server > Tuning > Gzip Compression: Yes
  2. Compression Level: 6

Troubleshooting

503 Service Unavailable

If you see this error message, it may be that the PHP handler is not working correctly. Check the log files for more information:

tail -f /usr/local/lsws/logs/error.log

Cache Not Working

Check the cache permissions to ensure that LiteSpeed has access:

ls -la /var/www/lscache/

Configuration Changes Not Applying

Always remember to restart the server after making changes:

/usr/local/lsws/bin/lswsctrl restart

More information about VPS servers at Theory7

Need Help?

We are here for you! Are you facing any issues or have questions? Our support team is happy to assist you personally. Send us a message via the ticket system - we usually respond within a few hours and are happy to help.