Set up OpenLiteSpeed web server with PHP 8.4, deploy WordPress with database integration, and enable LSCache plugin for maximum performance optimization.
Prerequisites
- Root or sudo access
- Fresh server installation
- At least 2GB RAM
- Domain name (optional)
What this solves
OpenLiteSpeed delivers high-performance WordPress hosting with built-in caching capabilities. This tutorial covers installing OpenLiteSpeed, configuring PHP 8.4 with LiteSpeed SAPI, setting up WordPress with MySQL, and enabling LSCache for optimal performance.
Step-by-step installation
Update system packages
Start by updating your package manager to ensure you get the latest versions.
sudo apt update && sudo apt upgrade -y
Install required dependencies
Install essential packages needed for OpenLiteSpeed compilation and operation.
sudo apt install -y wget curl gnupg2 software-properties-common lsb-release ca-certificates apt-transport-https
Add OpenLiteSpeed repository
Add the official OpenLiteSpeed repository to access the latest stable version.
wget -O - https://repo.litespeed.sh | sudo bash
sudo apt update
Install OpenLiteSpeed
Install the OpenLiteSpeed web server package.
sudo apt install -y openlitespeed
Install PHP 8.4 with LiteSpeed SAPI
Install PHP 8.4 specifically compiled for LiteSpeed with essential extensions for WordPress.
sudo apt install -y lsphp84 lsphp84-common lsphp84-curl lsphp84-mysql lsphp84-opcache lsphp84-mbstring lsphp84-xml lsphp84-gd lsphp84-zip lsphp84-imagick
Install MySQL server
Install and secure MySQL database server for WordPress data storage.
sudo apt install -y mysql-server
sudo systemctl enable --now mysql
sudo mysql_secure_installation
Create WordPress database and user
Set up a dedicated MySQL database and user account for WordPress.
sudo mysql -u root -p
CREATE DATABASE wordpress_db;
CREATE USER 'wordpress_user'@'localhost' IDENTIFIED BY 'SecurePassword123!';
GRANT ALL PRIVILEGES ON wordpress_db.* TO 'wordpress_user'@'localhost';
FLUSH PRIVILEGES;
EXIT;
Set admin password for OpenLiteSpeed
Set the administrator password for the OpenLiteSpeed web console.
sudo /usr/local/lsws/admin/misc/admpass.sh
Enter your desired username and password when prompted. Remember these credentials for accessing the web console.
Start and enable OpenLiteSpeed
Start the OpenLiteSpeed service and enable it to start automatically on boot.
sudo systemctl enable --now lsws
sudo systemctl status lsws
Configure firewall ports
Open the necessary ports for web traffic and OpenLiteSpeed admin panel.
sudo ufw allow 80/tcp
sudo ufw allow 443/tcp
sudo ufw allow 7080/tcp
sudo ufw allow 8088/tcp
sudo ufw --force enable
Configure OpenLiteSpeed for WordPress
Access OpenLiteSpeed web console
Navigate to the OpenLiteSpeed administration interface to configure virtual hosts.
Open your web browser and visit https://your-server-ip:7080. Log in with the credentials you set earlier.
Configure PHP version
Set PHP 8.4 as the default scripting language in OpenLiteSpeed.
- Navigate to Script Handler tab
- Click the + button to add a new script handler
- Set the following values:
| Setting | Value |
|---|---|
| Suffixes | php |
| Script Handler Type | LiteSpeed SAPI |
| Command | lsphp84 |
Click Save and perform a Graceful Restart.
Create WordPress directory
Create the document root directory for your WordPress installation.
sudo mkdir -p /usr/local/lsws/wordpress
sudo chown -R nobody:nogroup /usr/local/lsws/wordpress
sudo chmod -R 755 /usr/local/lsws/wordpress
Configure virtual host
Set up a virtual host for WordPress in the OpenLiteSpeed web console.
- Navigate to Virtual Hosts → +
- Configure the virtual host:
| Setting | Value |
|---|---|
| Virtual Host Name | wordpress |
| Virtual Host Root | /usr/local/lsws/wordpress/ |
| Config File | /usr/local/lsws/conf/vhosts/wordpress/vhconf.conf |
| Enable Scripts/ExtApps | Yes |
Click Save and navigate to the newly created virtual host.
Configure virtual host general settings
Set the document root and index files for the WordPress virtual host.
- Click on the wordpress virtual host
- Go to General tab
- Set these values:
| Setting | Value |
|---|---|
| Document Root | /usr/local/lsws/wordpress/ |
| Index Files | index.php, index.html |
| Auto Index | No |
Set up listener and mapping
Configure the HTTP listener and map the virtual host.
- Navigate to Listeners → Default (*:8088)
- Go to Virtual Host Mappings tab
- Click + and add:
| Setting | Value |
|---|---|
| Virtual Host | wordpress |
| Domain | * |
Click Save and perform a Graceful Restart.
Install and configure WordPress
Download WordPress
Download the latest WordPress release and extract it to the document root.
cd /tmp
wget https://wordpress.org/latest.tar.gz
tar -xzf latest.tar.gz
sudo cp -R wordpress/* /usr/local/lsws/wordpress/
sudo chown -R nobody:nogroup /usr/local/lsws/wordpress
sudo chmod -R 755 /usr/local/lsws/wordpress
Configure WordPress database connection
Create and configure the WordPress configuration file with database credentials.
cd /usr/local/lsws/wordpress
sudo cp wp-config-sample.php wp-config.php
sudo chown nobody:nogroup wp-config.php
define('DB_NAME', 'wordpress_db');
define('DB_USER', 'wordpress_user');
define('DB_PASSWORD', 'SecurePassword123!');
define('DB_HOST', 'localhost');
define('DB_CHARSET', 'utf8mb4');
define('DB_COLLATE', '');
// Security keys - generate at https://api.wordpress.org/secret-key/1.1/salt/
define('AUTH_KEY', 'your-unique-auth-key');
define('SECURE_AUTH_KEY', 'your-unique-secure-auth-key');
define('LOGGED_IN_KEY', 'your-unique-logged-in-key');
define('NONCE_KEY', 'your-unique-nonce-key');
define('AUTH_SALT', 'your-unique-auth-salt');
define('SECURE_AUTH_SALT', 'your-unique-secure-auth-salt');
define('LOGGED_IN_SALT', 'your-unique-logged-in-salt');
define('NONCE_SALT', 'your-unique-nonce-salt');
Set correct file permissions
Configure WordPress file and directory permissions for security and functionality.
sudo find /usr/local/lsws/wordpress/ -type d -exec chmod 755 {} \;
sudo find /usr/local/lsws/wordpress/ -type f -exec chmod 644 {} \;
sudo chmod 600 /usr/local/lsws/wordpress/wp-config.php
sudo mkdir -p /usr/local/lsws/wordpress/wp-content/uploads
sudo chown -R nobody:nogroup /usr/local/lsws/wordpress/wp-content
sudo chmod -R 775 /usr/local/lsws/wordpress/wp-content
Enable and configure LSCache
Enable cache module in OpenLiteSpeed
Activate the built-in cache module in OpenLiteSpeed web console.
- Navigate to Server Configuration → Modules
- Find cache in the module list
- Set the value to Yes
- Click Save and perform a Graceful Restart
Configure cache settings for virtual host
Set up cache configuration specifically for the WordPress virtual host.
- Navigate to Virtual Hosts → wordpress
- Go to Cache tab
- Configure these settings:
| Setting | Value |
|---|---|
| Enable Cache | Yes |
| Cache Root | /usr/local/lsws/cachedata/wordpress/ |
| Cache Expire Time (seconds) | 3600 |
| Cache Max Object Size | 10000000 |
Click Save and perform a Graceful Restart.
Install LSCache WordPress plugin
Complete the WordPress installation and install the LSCache plugin.
- Visit
http://your-server-ip:8088in your browser - Complete the WordPress installation wizard
- Log into WordPress admin panel
- Navigate to Plugins → Add New
- Search for "LiteSpeed Cache"
- Install and activate the plugin
Configure LSCache plugin settings
Optimize the LSCache plugin for maximum performance.
- Navigate to LiteSpeed Cache → Cache
- Enable these cache options:
| Setting | Status |
|---|---|
| Enable Cache | ON |
| Cache Logged-in Users | ON |
| Cache Commenters | ON |
| Cache REST API | ON |
| Cache Login Page | ON |
Click Save Changes.
Configure purge settings
Set up automatic cache purging for content updates.
- Navigate to LiteSpeed Cache → Purge
- Enable these purge rules:
| Setting | Status |
|---|---|
| Purge All On Upgrade | ON |
| Auto Purge Rules for Publish/Update | ON |
| Serve Stale | ON |
Enable object cache
Activate object caching to improve database query performance.
- Navigate to LiteSpeed Cache → Object
- Set Object Cache to ON
- Set Method to Redis (if available) or Memcached
- Click Save Changes
Optimize PHP settings
Configure PHP performance settings
Optimize PHP configuration for WordPress performance.
memory_limit = 512M
max_execution_time = 300
max_input_vars = 3000
upload_max_filesize = 64M
post_max_size = 64M
; OPcache settings
opcache.enable=1
opcache.enable_cli=1
opcache.memory_consumption=256
opcache.interned_strings_buffer=12
opcache.max_accelerated_files=60000
opcache.revalidate_freq=2
opcache.fast_shutdown=1
Restart services
Restart OpenLiteSpeed to apply the PHP configuration changes.
sudo systemctl restart lsws
Verify your setup
Test your OpenLiteSpeed and WordPress installation with these verification commands:
# Check OpenLiteSpeed status
sudo systemctl status lsws
Verify PHP version
/usr/local/lsws/lsphp84/bin/php --version
Test MySQL connection
sudo mysql -u wordpress_user -p -e "SELECT 1;"
Check cache directory permissions
ls -la /usr/local/lsws/cachedata/
Test web server response
curl -I http://localhost:8088
Check LSCache plugin status (if installed)
wp plugin status litespeed-cache --path=/usr/local/lsws/wordpress/
Visit http://your-server-ip:8088 to confirm WordPress is loading correctly. Check the LSCache plugin status in WordPress admin to ensure caching is active.
Common issues
| Symptom | Cause | Fix |
|---|---|---|
| 503 Service Unavailable | PHP handler not configured | Verify lsphp84 script handler in web console |
| WordPress database connection error | Incorrect database credentials | Check wp-config.php database settings |
| File upload errors | Permission issues | Set ownership to nobody:nogroup and correct permissions |
| Cache not working | Cache module disabled | Enable cache module in server configuration |
| High memory usage | OPcache misconfigured | Tune opcache settings in php.ini |
| Admin console inaccessible | Firewall blocking port 7080 | Open port 7080 in firewall configuration |
Next steps
- Configure OpenLiteSpeed load balancing with multiple backend servers for high availability
- Configure MySQL connection pooling with ProxySQL 2.6 for high availability and performance optimization
- Monitor MySQL performance with Prometheus and Grafana dashboards
- Configure OpenLiteSpeed SSL certificates with Let's Encrypt
- Optimize WordPress performance with advanced caching strategies
Running this in production?
Automated install script
Run this to automate the entire setup
#!/usr/bin/env bash
set -euo pipefail
# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m'
# Configuration
DOMAIN="${1:-localhost}"
DB_NAME="wordpress_db"
DB_USER="wordpress_user"
DB_PASS="$(openssl rand -base64 32 | tr -d "=+/" | cut -c1-25)"
ADMIN_USER="admin"
ADMIN_PASS="$(openssl rand -base64 32 | tr -d "=+/" | cut -c1-25)"
WP_PATH="/usr/local/lsws/Example/html"
# Logging
exec > >(tee -a /var/log/openlitespeed-install.log)
exec 2>&1
log() { echo -e "${BLUE}[$(date '+%Y-%m-%d %H:%M:%S')]${NC} $1"; }
success() { echo -e "${GREEN}✓${NC} $1"; }
error() { echo -e "${RED}✗${NC} $1" >&2; }
warning() { echo -e "${YELLOW}⚠${NC} $1"; }
cleanup() {
if [ $? -ne 0 ]; then
error "Installation failed. Check /var/log/openlitespeed-install.log for details"
log "Rolling back..."
systemctl stop lsws mysqld 2>/dev/null || true
fi
}
trap cleanup ERR EXIT
show_usage() {
echo "Usage: $0 [domain]"
echo "Example: $0 example.com"
exit 1
}
check_root() {
if [[ $EUID -ne 0 ]]; then
error "This script must be run as root"
exit 1
fi
}
detect_distro() {
if [ ! -f /etc/os-release ]; then
error "Cannot detect Linux distribution"
exit 1
fi
. /etc/os-release
case "$ID" in
ubuntu|debian)
PKG_MGR="apt"
PKG_UPDATE="apt update && apt upgrade -y"
PKG_INSTALL="apt install -y"
FIREWALL_CMD="ufw"
;;
almalinux|rocky|centos|rhel|ol|fedora)
PKG_MGR="dnf"
PKG_UPDATE="dnf update -y"
PKG_INSTALL="dnf install -y"
FIREWALL_CMD="firewalld"
if ! command -v dnf &> /dev/null; then
PKG_MGR="yum"
PKG_UPDATE="yum update -y"
PKG_INSTALL="yum install -y"
fi
;;
amzn)
PKG_MGR="yum"
PKG_UPDATE="yum update -y"
PKG_INSTALL="yum install -y"
FIREWALL_CMD="firewalld"
;;
*)
error "Unsupported distribution: $ID"
exit 1
;;
esac
success "Detected distribution: $PRETTY_NAME"
}
install_dependencies() {
log "[2/12] Installing dependencies..."
if [ "$PKG_MGR" = "apt" ]; then
$PKG_INSTALL wget curl gnupg2 software-properties-common lsb-release ca-certificates apt-transport-https openssl
else
$PKG_INSTALL wget curl gnupg2 epel-release openssl
fi
success "Dependencies installed"
}
add_litespeed_repo() {
log "[3/12] Adding OpenLiteSpeed repository..."
if [ "$PKG_MGR" = "apt" ]; then
wget -O - https://repo.litespeed.sh | bash
apt update
else
if [ "$ID" = "centos" ] && [ "${VERSION_ID%%.*}" = "8" ]; then
rpm -Uvh http://rpms.litespeedtech.com/centos/litespeed-repo-1.1-1.el8.noarch.rpm
else
rpm -Uvh http://rpms.litespeedtech.com/centos/litespeed-repo-1.1-1.el7.noarch.rpm
fi
$PKG_MGR update -y
fi
success "Repository added"
}
install_openlitespeed() {
log "[4/12] Installing OpenLiteSpeed..."
$PKG_INSTALL openlitespeed
success "OpenLiteSpeed installed"
}
install_php() {
log "[5/12] Installing PHP 8.4 with LiteSpeed SAPI..."
$PKG_INSTALL lsphp84 lsphp84-common lsphp84-curl lsphp84-mysql lsphp84-opcache lsphp84-mbstring lsphp84-xml lsphp84-gd lsphp84-zip lsphp84-imagick || {
warning "Some PHP extensions might not be available, continuing..."
$PKG_INSTALL lsphp84 lsphp84-common lsphp84-curl lsphp84-mysql lsphp84-opcache lsphp84-mbstring lsphp84-xml
}
success "PHP 8.4 installed"
}
install_mysql() {
log "[6/12] Installing MySQL server..."
if [ "$PKG_MGR" = "apt" ]; then
$PKG_INSTALL mysql-server
else
$PKG_INSTALL mysql-server
fi
systemctl enable mysqld || systemctl enable mysql
systemctl start mysqld || systemctl start mysql
# Get temporary password for RHEL-based systems
if [ "$PKG_MGR" != "apt" ]; then
TEMP_PASS=$(grep 'temporary password' /var/log/mysqld.log 2>/dev/null | tail -1 | awk '{print $NF}' || echo "")
fi
success "MySQL installed and started"
}
configure_mysql() {
log "[7/12] Configuring MySQL database..."
# Set root password and create WordPress database
if [ "$PKG_MGR" = "apt" ]; then
mysql -e "CREATE DATABASE IF NOT EXISTS $DB_NAME;"
mysql -e "CREATE USER IF NOT EXISTS '$DB_USER'@'localhost' IDENTIFIED BY '$DB_PASS';"
mysql -e "GRANT ALL PRIVILEGES ON $DB_NAME.* TO '$DB_USER'@'localhost';"
mysql -e "FLUSH PRIVILEGES;"
else
if [ -n "${TEMP_PASS:-}" ]; then
mysql -u root -p"$TEMP_PASS" --connect-expired-password -e "ALTER USER 'root'@'localhost' IDENTIFIED BY '$DB_PASS';" || true
fi
mysql -u root -e "CREATE DATABASE IF NOT EXISTS $DB_NAME;"
mysql -u root -e "CREATE USER IF NOT EXISTS '$DB_USER'@'localhost' IDENTIFIED BY '$DB_PASS';"
mysql -u root -e "GRANT ALL PRIVILEGES ON $DB_NAME.* TO '$DB_USER'@'localhost';"
mysql -u root -e "FLUSH PRIVILEGES;"
fi
success "Database configured"
}
configure_openlitespeed() {
log "[8/12] Configuring OpenLiteSpeed admin password..."
echo "$ADMIN_USER" > /tmp/ols_admin_user
echo "$ADMIN_PASS" >> /tmp/ols_admin_user
/usr/local/lsws/admin/misc/admpass.sh < /tmp/ols_admin_user
rm -f /tmp/ols_admin_user
success "Admin password set"
}
start_services() {
log "[9/12] Starting and enabling services..."
systemctl enable lsws
systemctl start lsws
systemctl status lsws --no-pager
success "OpenLiteSpeed started"
}
configure_firewall() {
log "[10/12] Configuring firewall..."
if [ "$FIREWALL_CMD" = "ufw" ]; then
ufw allow 80/tcp
ufw allow 443/tcp
ufw allow 7080/tcp
ufw allow 8088/tcp
ufw --force enable
else
systemctl enable firewalld
systemctl start firewalld
firewall-cmd --permanent --add-port=80/tcp
firewall-cmd --permanent --add-port=443/tcp
firewall-cmd --permanent --add-port=7080/tcp
firewall-cmd --permanent --add-port=8088/tcp
firewall-cmd --reload
fi
success "Firewall configured"
}
install_wordpress() {
log "[11/12] Installing WordPress..."
cd /tmp
wget https://wordpress.org/latest.tar.gz
tar -xzf latest.tar.gz
# Backup existing files and copy WordPress
if [ -d "$WP_PATH" ]; then
mv "$WP_PATH" "${WP_PATH}.bak.$(date +%s)"
fi
mkdir -p "$(dirname "$WP_PATH")"
cp -r wordpress "$WP_PATH"
# Set permissions
chown -R nobody:nogroup "$WP_PATH"
find "$WP_PATH" -type d -exec chmod 755 {} \;
find "$WP_PATH" -type f -exec chmod 644 {} \;
# Create wp-config.php
cp "$WP_PATH/wp-config-sample.php" "$WP_PATH/wp-config.php"
sed -i "s/database_name_here/$DB_NAME/g" "$WP_PATH/wp-config.php"
sed -i "s/username_here/$DB_USER/g" "$WP_PATH/wp-config.php"
sed -i "s/password_here/$DB_PASS/g" "$WP_PATH/wp-config.php"
# Add security keys
SALT=$(wget -qO- https://api.wordpress.org/secret-key/1.1/salt/)
printf '%s\n' "g?put your unique phrase here?d?$SALT?g" w | ed -s "$WP_PATH/wp-config.php"
chown nobody:nogroup "$WP_PATH/wp-config.php"
chmod 644 "$WP_PATH/wp-config.php"
rm -rf /tmp/wordpress /tmp/latest.tar.gz
success "WordPress installed"
}
verify_installation() {
log "[12/12] Verifying installation..."
# Check services
if ! systemctl is-active --quiet lsws; then
error "OpenLiteSpeed is not running"
return 1
fi
if ! systemctl is-active --quiet mysqld && ! systemctl is-active --quiet mysql; then
error "MySQL is not running"
return 1
fi
# Check ports
if ! ss -tlnp | grep -q ":8088"; then
error "OpenLiteSpeed is not listening on port 8088"
return 1
fi
success "All services are running correctly"
}
show_summary() {
log "Installation completed successfully!"
echo
echo "=========================================="
echo "OpenLiteSpeed Installation Summary"
echo "=========================================="
echo "Domain: $DOMAIN"
echo "OpenLiteSpeed Admin Panel: https://$(hostname -I | awk '{print $1}'):7080"
echo "Admin Username: $ADMIN_USER"
echo "Admin Password: $ADMIN_PASS"
echo
echo "WordPress Site: http://$(hostname -I | awk '{print $1}'):8088"
echo "WordPress Path: $WP_PATH"
echo
echo "Database Name: $DB_NAME"
echo "Database User: $DB_USER"
echo "Database Password: $DB_PASS"
echo
echo "Log file: /var/log/openlitespeed-install.log"
echo "=========================================="
echo
warning "Save these credentials securely!"
}
main() {
log "[1/12] Starting OpenLiteSpeed installation..."
check_root
detect_distro
eval $PKG_UPDATE
install_dependencies
add_litespeed_repo
install_openlitespeed
install_php
install_mysql
configure_mysql
configure_openlitespeed
start_services
configure_firewall
install_wordpress
verify_installation
show_summary
}
if [[ "${1:-}" == "-h" ]] || [[ "${1:-}" == "--help" ]]; then
show_usage
fi
main "$@"
Review the script before running. Execute with: bash install.sh