...
To compile the extension, you'll need the PHP source code corresponding to the PHP version you're using. Follow these steps to download the source code:
Check PHP Version: Determine your PHP version by running the following command:
Code Block |
---|
php -v |
Note down the PHP version for later use.
Download PHP Source: Visit the PHP website's downloads page and download the source code for your PHP version. Alternatively, you can use the following command to download it directly:
Code Block |
---|
wget https://www.php.net/distributions/php-X.Y.Z.tar.gz |
Replace X.Y.Z
with your PHP version (e.g., 8.1.22
).
Extract Source Code: Extract the downloaded archive:
Code Block |
---|
tar -xzf php-X.Y.Z.tar.gz |
Step 3: Compile the pcntl Extension
Navigate to Extension Directory: Change into the directory containing the PHP source code:
Code Block |
---|
cd php-X.Y.Z/ext/pcntl |
Compile the Extension: Use the following commands to compile the pcntl
extension:
Code Block |
---|
phpize ./configure make |
...
After successfully compiling the extension, you can proceed to install it:
Install Extension: Run the following command to install the compiled extension:
Code Block |
---|
sudo make install |
Step 5: Enable the Extension
To enable the pcntl
extension, follow these steps:
Edit php.ini: Open the PHP configuration file in a text editor (e.g., nano):
Code Block |
---|
sudo nano /etc/php/X.Y/cli/php.ini |
Replace X.Y
with your PHP version (e.g., 8.1
)
Add Extension: Add the following line to enable the pcntl
extension. Add it under the "Dynamic Extensions" section:
Code Block |
---|
extension=pcntl.so |
Save and Exit: Save the file and exit the text editor.
Step 6: Restart services PHP-FPM and Web server (Apache)
...