Installing PHP extensions from the command line on an openlitespeed server using apt is a quick and easy process that can be accomplished in just a few steps. This tutorial will guide you through the process of installing PHP extensions using the apt package manager.
Introduction
Before starting, make sure you have access to the command line on your openlitespeed server and have root privileges. You will also need to have the apt package manager installed.
Step 1
To begin, update the apt package manager by running the following command:
sudo apt-get update
Step 2
Next, search for the PHP extension you want to install. For example, to search for the ioncube extension, you can use the following command:
apt search ioncube
This will list all the available packages that contain the word "ioncube" in their name or description. From the list, choose the package that corresponds to the PHP extension you want to install. Please make sure that you are selecting lsphp extensions as you are installing it on a OpenLiteSpeed server. The OpenLiteSpeed PHP extension will have following syntax
lsphp[version]-extention_name
For example, our previous command will show below results.
--------
lsphp72-ioncube/focal,now 10.3.9-1+focal amd64 [installed]
PHP extension for interfacing with ioncube
lsphp73-ioncube/focal,now 10.3.9-1+focal amd64 [installed]
PHP extension for interfacing with ioncube
lsphp74-ioncube/focal,now 10.4.1-1+focal amd64 [installed]
PHP extension for interfacing with ioncube
--------
Step 3
Once you have identified the correct package, install it using the following command:
sudo apt-get install [package name]
Replace [package name] with the name of the package you want to install. For example, to install the ioncube extension over PHP74 version, you would use the following command:
sudo apt-get install lsphp74-ioncube
The installation process will begin and may take a few minutes to complete. Once it is finished, the PHP extension will be installed and ready to use.
The most commonly installed extensions are following
lsphp[version]-igbinary
lsphp[version]-imagick
lsphp[version]-memcached
lsphp[version]-ldap
lsphp[version]-redis
For example, you can install igbinary with version php81 using below command.
sudo apt-get install lsphp81-igbinary
Install imagick in PHP80 using
sudo apt-get install lsphp80-imagick
Install memcached on PHP74 using
sudo apt-get install lsphp74-memcached
Install ldap on PHP73 using
sudo apt-get install lsphp73-ldap
Install redis on PHP72 using
sudo apt-get install lsphp72-redis
Once again, you can change the version according to your requirement.
Step 4
To verify that the extension was installed correctly, you can run the following command:
/usr/local/lsws/lsphp74/bin/php -m
You can change the version from 74 to your required version.
This will list all the installed PHP modules, including the one you just installed. If you see the extension listed, it has been installed successfully.
You can also restart the lsws service if it's not showing.
service lsws restart
If you are using RunCloud then use
service lsws-rc restart
Conclusion
That's it! You have successfully installed a PHP extension on your openlitespeed server using the apt package manager. You can repeat the process to install additional extensions as needed. Just remember to update the apt package manager before installing each extension to ensure you are installing the latest version.
Comments
Post a Comment