How to Install OpenLiteSpeed and PHP 8 on AlmaLinux 9 and Rocky Linux 9
Install OpenLiteSpeed and LSPHP 8.4 from the official LiteSpeed repository on AlmaLinux 9 or Rocky Linux 9, enable the WebAdmin Console and verify PHP.
This guide installs OpenLiteSpeed from the official LiteSpeed repository together with a supported PHP 8 build (LSPHP) on AlmaLinux 9, Rocky Linux 9 or CentOS Stream 9. When you finish, the server answers on port 8088, runs PHP 8.4 through LiteSpeed's own SAPI, and has the WebAdmin Console enabled and protected with your own password.
Older tutorials on this topic covered CentOS 7 with PHP 7.1. CentOS 7 reached end of life on 30 June 2024 and PHP 7 no longer receives security fixes, so use the RHEL 9 family and PHP 8 instead. The same repository also serves Debian 11 to 13 and Ubuntu 22.04, 24.04 and 26.04; the differences are noted at the end.
Requirements
- AlmaLinux 9, Rocky Linux 9 or CentOS Stream 9 on x86_64 or aarch64.
- A user with
sudorights (the examples usedeploy) on a server at203.0.113.10. - No other web server bound to ports 8088 or 7080.
Step 1: Update the system
sudo dnf upgrade -y
sudo dnf install -y wget
Reboot if a new kernel was installed.
Step 2: Add the LiteSpeed repository
LiteSpeed publishes a small script that detects your distribution and writes the repository definition and signing key:
sudo wget -O - https://repo.litespeed.sh | sudo bash
On the RHEL 9 family the script creates /etc/yum.repos.d/litespeed.repo and also installs the EPEL and Remi release packages and enables the CRB repository, because some LSPHP extensions depend on libraries from them. If you would rather inspect the script before running it as root, download it to a file first and read it.
Step 3: Install OpenLiteSpeed
sudo dnf install -y openlitespeed
The server is installed under /usr/local/lsws and managed by the lsws systemd unit. Make sure it is running and starts at boot:
sudo systemctl enable --now lsws
sudo /usr/local/lsws/bin/lswsctrl status
Step 4: Install PHP 8 (LSPHP)
PHP for OpenLiteSpeed comes as lsphp packages, one set per PHP branch. List what the repository offers:
sudo dnf search lsphp
At the time of writing the EL9 repository carries lsphp80 through lsphp85. Install PHP 8.4 with the extensions most applications need:
sudo dnf install -y lsphp84 lsphp84-common lsphp84-mysqlnd lsphp84-pdo lsphp84-opcache lsphp84-mbstring lsphp84-xml lsphp84-gd lsphp84-intl lsphp84-zip lsphp84-bcmath lsphp84-process
Each branch installs into its own directory, so the binary is /usr/local/lsws/lsphp84/bin/lsphp. Check it and find out which php.ini it reads:
/usr/local/lsws/lsphp84/bin/lsphp -v
/usr/local/lsws/lsphp84/bin/lsphp -i | grep 'Loaded Configuration File'
The mcrypt extension from older tutorials no longer exists in PHP 8; applications use sodium or OpenSSL instead.
Step 5: Point OpenLiteSpeed at the PHP version you installed
OpenLiteSpeed runs PHP through an external application called lsphp. See which binary it currently uses:
sudo grep -i -A 14 '^extprocessor lsphp' /usr/local/lsws/conf/httpd_config.conf
ls -l /usr/local/lsws/fcgi-bin/
Look at the path line inside that block. If it already says lsphp84/bin/lsphp you are done. If it names another version, or says fcgi-bin/lsphp and the second command shows that file linking to a different version, edit /usr/local/lsws/conf/httpd_config.conf and change the line to:
path lsphp84/bin/lsphp
The path is relative to /usr/local/lsws. Further down the same file, the scripthandler block must still map the php suffix to lsapi:lsphp. Then restart PHP and the web server:
sudo touch /usr/local/lsws/admin/tmp/.lsphp_restart.txt
sudo systemctl restart lsws
You can make the same change in the WebAdmin Console under Server Configuration > External App by editing the Command field of the lsphp application.
Step 6: Enable the WebAdmin Console and set its password
Starting with OpenLiteSpeed 1.9.4 the WebAdmin Console is disabled by default, and port 7080 only shows a "WebAdmin Console Is Disabled" page. Enable it by creating a control file. Left empty, the file allows access from any address; to restrict the console, put the allowed IP addresses in it, one per line. Everyone else then gets a 403 error.
echo '198.51.100.25' | sudo tee /usr/local/lsws/admin/conf/enable_webadmin
sudo /usr/local/lsws/bin/lswsctrl restart
Replace 198.51.100.25 with the public IP address you administer the server from. The installer stores a randomly generated password in /usr/local/lsws/adminpasswd. Set your own user name and password instead:
sudo /usr/local/lsws/admin/misc/admpass.sh
Step 7: Open the firewall and test
Allow the default site port and the console port through firewalld:
sudo firewall-cmd --permanent --add-port=8088/tcp
sudo firewall-cmd --permanent --add-port=7080/tcp
sudo firewall-cmd --reload
Browse to http://203.0.113.10:8088/ to see the bundled example site, and to https://203.0.113.10:7080/ for the WebAdmin Console. The console uses a self-signed certificate, so your browser shows a warning the first time.
To confirm PHP end to end, create a test script in the example site's document root, load it, and delete it afterwards:
echo '<?php echo PHP_VERSION, " ", PHP_SAPI, "\n";' | sudo tee /usr/local/lsws/Example/html/version.php
curl http://127.0.0.1:8088/version.php
sudo rm /usr/local/lsws/Example/html/version.php
The output should show an 8.4 version number followed by litespeed. The example site also ships demo scripts such as phpinfo.php and upload.php; do not leave it reachable from the internet once your own site is in place.
Next steps: ports 80 and 443 and your own site
The default listener is on port 8088 for all addresses. For a real site, create your own virtual host and listeners in the WebAdmin Console rather than editing the example:
- Create a directory such as
/usr/local/lsws/example.com/withconf,htmlandlogsinside, and giveconftolsadm:lsadmso only the console can change it. - Under Virtual Hosts, add a virtual host whose document root is the
htmldirectory. - Under Listeners, add an HTTP listener on port 80 and an HTTPS listener on port 443 with Secure set to Yes and a certificate, and map both to the virtual host and its domain names.
- Open the ports with
sudo firewall-cmd --permanent --add-service=http --add-service=httpsfollowed bysudo firewall-cmd --reload, then remove the 8088 rule if you no longer need it.
Maintenance and troubleshooting
- Updates:
sudo dnf upgradeupdates OpenLiteSpeed and every installedlsphppackage from the LiteSpeed repository. - Switching PHP versions later: install the new set, for example
lsphp85and its extensions, change thepathline from step 5 and restart. Note thatlsphp85has no separate opcache package to install. - PHP changes not taking effect: LSPHP processes are long-lived. Run the
touchand restart commands from step 5 after editingphp.ini. - Logs: server logs are under
/usr/local/lsws/logs/; start witherror.log. - Console unreachable: check that
enable_webadminexists and contains your current IP address, and that port 7080 is open.
Debian and Ubuntu differences
The repository script is the same. Install with sudo apt-get install openlitespeed, and note that the MySQL driver package is named lsphp84-mysql rather than lsphp84-mysqlnd. Use apt-cache search lsphp to list packages, and ufw instead of firewalld if you use Ubuntu's firewall.
Frequently asked questions
Can I use the PHP packages from AppStream or Remi with OpenLiteSpeed?
Use the lsphp packages. They are built with the LiteSpeed SAPI, which is how OpenLiteSpeed talks to PHP; the distribution's php-fpm packages are meant for Apache and Nginx.
Can several PHP versions run side by side?
Yes. Each lsphpXX set lives in its own directory. Define one external application per version and add a script handler at the virtual host level to override the server default for that site.
Does OpenLiteSpeed read .htaccess files?
It supports Apache-style rewrite rules in .htaccess, but not every Apache directive, and it reads the files at start-up rather than on each request, so restart the server after changing them.
Is it safe to leave port 7080 open?
Limit it. List only your own addresses in enable_webadmin, or close the port in the firewall and reach the console through an SSH tunnel when you need it.