Skip to main content

Multiple PHP Versions

Learning Focus

By the end of this lesson you will know how to install, configure, and use multiple PHP versions simultaneously on one OpenLiteSpeed server.

Why Multiple Versions

Different sites may require different PHP versions:

  • WordPress site needs PHP 8.4
  • Legacy application runs on PHP 8.1
  • Testing environment uses PHP 8.3

Setup Steps

Step 1: Install Multiple lsphp Versions

# Install PHP 8.4 and PHP 8.1
sudo apt install lsphp84 lsphp84-common lsphp84-mysql lsphp84-curl
sudo apt install lsphp81 lsphp81-common lsphp81-mysql lsphp81-curl

Step 2: Create Separate External Apps

In WebAdmin, create one external app per PHP version:

External App NameCommand Path
lsphp84/usr/local/lsws/lsphp84/bin/lsphp
lsphp81/usr/local/lsws/lsphp81/bin/lsphp

Step 3: Assign Per-Virtual-Host

For each virtual host, map the .php script handler to the appropriate external app:

  1. Virtual Hosts → select site → Script Handler
  2. Add handler: suffix php, handler name lsphp84 (or lsphp81)
  3. Save and Graceful Restart

Verifying

# Test which PHP version each site uses
curl -s http://example.com/info.php | grep "PHP Version"
curl -s http://legacy-app.com/info.php | grep "PHP Version"
info

Each lsphp version has its own php.ini. Configure extensions and settings independently for each version.

Key Takeaways

  • OpenLiteSpeed supports multiple PHP versions via separate external app definitions.
  • Each virtual host can use a different PHP version through script handler mapping.
  • Each version has independent php.ini and extension configurations.

What's Next