If you use the Ubuntu operating system, when you try to install a PHP extension, you may encounter the problem that there is no extension. This is because Ubuntu's PHP does not include all possible extensions by default. This problem is actually easy to solve. Next we will briefly introduce how to configure PHP extensions on Ubuntu.
Before installing the extension, you must confirm your PHP version number. On Ubuntu, you can check by running the following command in the terminal:
php -v
The result will display the PHP version information.
After confirming the PHP version number, you can include it in the APT repository via Ubuntu Use the search command to find and install the required PHP extensions.
For example, if you need to install the MySQL extension, you can enter the following command:
sudo apt-get update sudo apt-get install php-mysql
This command will install the php-mysql package, which will add the MySQL extension to your PHP instance.
After you install a new PHP extension, you must restart PHP for the extension to take effect.
sudo systemctl restart apache2
This command will restart the Apache service and make the new PHP extension take effect.
Sometimes, you may need to install some PHP extensions manually. This process requires downloading a specific version of the extension source code and then installing it locally. The following is an example:
Download the extension source code:
wget https://pecl.php.net/get/redis-4.3.0.tgz
Unzip the extension source code:
tar -zxvf redis-4.3.0.tgz
Enter the unzipped directory:
cd redis-4.3.0
Compile and install Extensions:
sudo phpize sudo ./configure sudo make sudo make install
Configuring PHP extensions on Ubuntu is actually very simple. If you still encounter problems, it may be because different versions of PHP require different processing methods. I recommend that you take some time to carefully read the documentation and instructions before finding and applying any solution.
The above is the detailed content of How to solve the problem that there is no Extension in PHP configuration under Ubuntu. For more information, please follow other related articles on the PHP Chinese website!