PHP extension is like a module or plugin for PHP. There are two types of PHP extension, namely PHP extension (or the regular one) and Zend extension. You can read the difference between them on this site (PHP: internals:extensions).
In this guide, we will learn how to add PHP & Zend extensions to a web server managed by Paas.id.
- Have installed a web server on Paas.id
- Have access to the web server
Step 1 - Login to your Server
Login to your server and make sure you are login with a user with write access.
Step 2 - Download the Extension
Download the PHP extensions and unzip them if needed. Usually, the file has an extension
Step 3 - Put the Extension Files in the Specified Folder
If the extension is type of Zend extension then you need to put the extension files in this folder.
If the extension is type of PHP extension then you need to put the extension files in this folder.
Step 4 - Check if the Extension is Enabled
Create a PHP file in
/home/workspace/web-server/www/public/php-ext.php and write the code below to the file.
<?php print_r(get_loaded_extensions()); ?>
Study Case Scenario
In this study case scenario, we will try to install a Zend extension, namely ionCube loader. We will install the extension for PHP 7.4. Firstly, you need to login to your server. Using SSH, you can login by executing the command below (provide the password if asked).
After logged in successfully to the server, we need to download the ionCube loader. You can download the ionCube loader from the link below.
You can use curl to download the file by executing the command below.
curl -fsSL https://downloads.ioncube.com/loader_downloads/ioncube_loaders_lin_x86-64.tar.gz -o ioncube.tar.gz
Because the file is archived, you need to unarchived the file using the command below.
tar -xvf ioncube.tar.gz
The extension file that we will install is
ioncube_loader_lin_7.4.so. Now you need to put the extension file in the specified folder, in this case is
/home/workspace/web-server/paas-php-ext/7.4/zend/ . You can move the extension file by executing the command below.
sudo mv ioncube/ioncube_loader_lin_7.4.so /home/workspace/web-server/paas-php-ext/7.4/zend/
Also, you can check whether the file is copied/moved correctly by executing the command below.
sudo ls -alh /home/workspace/web-server/paas-php-ext/7.4/zend/
Actually, at this point, the file is already installed on your server. Now we need to check if the file is loaded correctly. We can create a PHP script file namely
php-ext.php which will be located in
/home/workspace/web-server/www/public/. The script file will print out all loaded extensions. You can create and write the script file by executing the command below.
sudo bash -c 'echo "<?php print_r(get_loaded_extensions()); ?>" > /home/workspace/web-server/www/public/php-ext.php'
Now you can visit the link below to check whether the extension is loaded or not.
At this point, you have a PHP extension installed on your server. Installing PHP extensions is easy, you just need to download them and put them in the specified folder.