Get 69% Off on Cloud Hosting : Claim Your Offer Now!
The PECL (PHP Extension Community Library) has a variety of PHP extensions in store. It offers a simple way to download and install PHP extensions on your web server. In certain cases, you may need to add several extensions at the same time, and in such instances, SSH can be quite helpful, especially if you have no control panel or don't have direct access to the web-based control panel.
Before we start, verify that your web server's SSH access is enabled and that you have suitable rights to install PHP extensions. Additionally, you're to have the command pecl available on the server, which is usually accompanied by PHP package installation.
Open your terminal or command prompt and establish an SSH connection to your web server using the appropriate credentials (hostname, username, and password/key). The command should look something like this:
codessh username@hostname
Once connected, verify the PHP version installed on your server by running the following command:
code PHP -v
This command shows the current version of PHP, which requires one to take the extensions compatible with the PHP version.
Use the unique search command to search among available extensions from the PECL repository. In addition, you can search among extensions by name or using a keyword. The search for a suitable extension like "imagick" can be performed by individually running:
codpiece search Imagick
This will display a list of extensions matching your search query, their versions, and a brief description.
After determining the extensions you want, run the PECL install along with the extension name(s) as a final step. You can 'put in' various 'add-ons' by utilizing the space symbol to split their names. This avoids conflicts among different versions of the same library and ensures that packages can be installed appropriately and linked to each other:
codpiece install imagick Redis
PECL will prompt you to confirm the installation and provide any additional prompts or instructions specific to each extension.
If you encounter unrealistic dependencies or conflicts, PECL will manifest them, and you may need to install additional modules or resolve the conflicts before you proceed.
The installation of these extensions is now finished, and you will then need to activate them in your PHP configuration settings. The procedure for finding and adding the line for each extension we installed might be different depending on our server's configuration, but we are about to discuss the necessary steps in detail.
For instance, if you have to install the extensions "imagick" and "redis," then you have to go to your php.ini file where this line extension= "imagick" will be added:
extension=imagick.so
extension=redis.so
The position of the php.ini file may change depending on the server configuration and architecture. Common locations include:
- /etc/php.ini
- /etc/php/
- /etc/php/
Having edited the php.ini file, you're to restart your web server (Apache, Nginx, etc.) and reboot your web server so that the changes will be willing to take effect.
Type `php -i' on your command line to list all the PHP extensions you installed and enabled on your web server. Then, create a PHP script with a part to check whether each extension was installed and enabled correctly.
Your sample file should contain the information below that can be named as test.php:
phpinfo();
Please save the file and access it via your web browser.
(e.g., http://your-server.com/test.php?page=2=4&testDb=Yes. This operates the file information to show you what is loaded to make an extension. Please scroll through the output or search for the names of the extensions you installed to confirm that they're listed and enabled.
Then, you can choose to implement a PHP script and use the get_loaded_extensions() function in another PHP to check for the loaded extensions dynamically:
$loaded_extensions = get_loaded_extensions();
print_r($loaded_extensions);
The script will return a list of all loaded plug-ins. You can then check the list to ensure your new plug-in is present.
That's it! You have loaded PHP with multiple extensions deployed by PECL by SSH. Whenever you add new extensions or modify existing ones, you should be ready to perform this procedure again—enabling them in your php.ini file and then restarting your website server.
Also, importantly, always ensure your PHP installation and extensions are up-to-date to maintain compatibility and safeguard the website. Upgrade is one of the commands used to update installed extensions to the latest versions using php composer install ("pecl upgrade").
Let’s talk about the future, and make it happen!
By continuing to use and navigate this website, you are agreeing to the use of cookies.
Find out more