How to Enable Essential PHP Extensions on a VPS with CentOS and cPanel 列印

  • 0

Introduction:
In this article, we will guide you through enabling important PHP extensions on a VPS (virtual private server) running CentOS with cPanel. The following PHP extensions will be covered:

1. OpenSSL PHP Extension
2. PDO PHP Extension
3. Mbstring PHP Extension
4. Tokenizer PHP Extension
5. XML PHP Extension
6. Ctype PHP Extension
7. JSON PHP Extension
8. Exif Extension
9. PHP Fileinfo Extension

Prerequisites:
1. A VPS running CentOS
2. cPanel/WHM installed on the VPS

Step 1: Check Existing PHP Extensions
To check the existing PHP extensions on your VPS, open a terminal and run the following command:

php -m

To check if a specific extension is installed, use the following command, replacing `extension_name` with the desired extension:

php -m | grep extension_name

For example, to check if the ctype extension is installed, run:

php -m | grep ctype

Step 2: Enable/Disable PHP Extensions via cPanel/WHM
You can enable or disable PHP extensions in cPanel/WHM by navigating to "WHM » Software » EasyApache 4 » Customize" in the "Currently Installed Packages" section.

 

Cpanel - Easy Apache 4

 

Some PHP extensions are built into PHP and cannot be added or removed through EasyApache. To check if these extensions are present in your system, run the following command, replacing `extension_name` with the desired extension:
```bash
php -i | grep -E -i 'extension_name'
```

For example, to check if the JSON and OpenSSL extensions are installed, run:
```bash
php -i | grep -E -i '(json|openssl)'
```

Step 3: Customize PHP Extensions in EasyApache 4
1. Log in to your WHM account.
2. Navigate to "WHM » Software » EasyApache 4."
3. Click the "Customize" button in the "Currently Installed Packages" section.
4. In the "PHP Extensions" tab, search for the desired extension using the search bar.
5. Click the toggle switch next to the extension to enable or disable it.
6. After making your changes, click the "Review" button at the bottom of the page.
7. Review your changes and click the "Provision" button to apply them.

Conclusion:
You have now learned how to enable essential PHP extensions on a VPS running CentOS with cPanel. By ensuring these extensions are enabled, you can improve the functionality and compatibility of your web applications. If you encounter any issues with your PHP extensions, don't hesitate to consult the official PHP documentation or seek assistance from the cPanel/WHM community.


這篇文章有幫助嗎?

« 返回