I installed OpenLiteSpeed on a server. The default PHP version was 7.3. I wanted PHP 7.4 on this server.
To install PHP 7.4, run
apt install -y lsphp74 lsphp74-apcu lsphp74-common lsphp74-curl lsphp74-dbg lsphp74-dev lsphp74-igbinary lsphp74-imagick lsphp74-imap lsphp74-intl lsphp74-ioncube lsphp74-json lsphp74-ldap lsphp74-memcached lsphp74-modules-source lsphp74-msgpack lsphp74-mysql lsphp74-opcache lsphp74-pear lsphp74-pgsql lsphp74-pspell lsphp74-redis lsphp74-snmp lsphp74-sqlite3 lsphp74-sybase lsphp74-tidy
To change PHP version, i edited file
vi /usr/local/lsws/conf/httpd_config.conf
Find
extProcessor lsphp{ type lsapi address uds://tmp/lshttpd/lsphp.sock maxConns 10 env PHP_LSAPI_CHILDREN=10 env LSAPI_AVOID_FORK=200M initTimeout 60 retryTimeout 0 persistConn 1 pcKeepAliveTimeout respBuffer 0 autoStart 1 path lsphp73/bin/lsphp backlog 100 instances 1 priority 0 memSoftLimit 2047M memHardLimit 2047M procSoftLimit 1400 procHardLimit 1500 }
In that, find
path lsphp73/bin/lsphp
Replace with
path lsphp74/bin/lsphp
Now restart PHP and openlitespeed
killall -9 lsphp systemctl restart lsws
Now the site will use the new PHP version.
You can install multiple PHP versions, to find other PHP versions available, run the command.
apt-cache search lsphp
As of 2023-01, openlitespeed image provided by AWS have PHP versions 7.4, 8.0, 8.1 and 8.2
root@ip-172-31-22-59:~# apt-cache search lsphp | grep common lsphp74-common - Common files for packages built from the PHP source lsphp80-common - Common files for packages built from the PHP source lsphp81-common - Common files for packages built from the PHP source lsphp82-common - Common files for packages built from the PHP source root@ip-172-31-22-59:~#
If you need to install any other available PHP version, use the same apt install command as above, and replace lsphp74 with another version you need. For example, to install PHP 8.2
apt install -y lsphp82 lsphp82-apcu lsphp82-common lsphp82-curl lsphp82-dbg lsphp82-dev lsphp82-igbinary lsphp82-imagick lsphp82-imap lsphp82-intl lsphp82-ioncube lsphp82-json lsphp82-ldap lsphp82-memcached lsphp82-modules-source lsphp82-msgpack lsphp82-mysql lsphp82-opcache lsphp82-pear lsphp82-pgsql lsphp82-pspell lsphp82-redis lsphp82-snmp lsphp82-sqlite3 lsphp82-sybase lsphp82-tidy
After installing, you need to edit the OpenLiteSpeed config file to switch php version.
See OpenLiteSpeed