How to compile custom PHP extensions?
Learn how to compile custom PHP extensions step by step. Guide to building, installing, and enabling PHP extensions for optimized server performance
⚠️ Issue
🛠️ How to compile custom PHP extensions in CloudLinux with PHP Selector?
When using Alt-PHP (CloudLinux), compiling extensions is slightly different than standard PHP because each PHP version has its own binaries and directories.
🖥️ Environment
-
PHP Selector
-
cPanel
-
PHP 5.x / 7.x (applies also to newer Alt-PHP versions with the same process)
✅ Solution
Follow these steps to build and enable a custom PHP extension:
📥 1. Download & unpack extension
⚙️ 2. Prepare with phpize
Run the phpize from the corresponding Alt-PHP version (replace XX with version, e.g., 74, 81):
🔧 3. Configure with correct php-config
🏗️ 4. Compile the extension
📂 5. Copy compiled module to Alt-PHP modules dir
For 64-bit servers:
For 32-bit servers:
📝 6. Create .ini file for extension
Add an ini config file inside Alt-PHP:
🔄 7. Register with PHP Selector
Finally, update CloudLinux PHP Selector:
🐞 Cause
This process is needed because:
-
Each Alt-PHP version uses its own binaries (
phpize,php-config). -
Extensions compiled with system PHP will not work with CloudLinux’s Alt-PHP.
-
Manual registration is required for PHP Selector to detect the extension.
Share
What's Your Reaction?
Like
0
Dislike
0
Love
0
Funny
0
Angry
0
Sad
0
Wow
0
