How to solve the problem that there is no Extension in PHP configuration under Ubuntu

PHPz
Release: 2023-03-21 12:06:01
Original
1561 people have browsed it

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.

  1. Confirm PHP version number

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
Copy after login

The result will display the PHP version information.

  1. Find and install the required PHP extension

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
Copy after login

This command will install the php-mysql package, which will add the MySQL extension to your PHP instance.

  1. Restart PHP

After you install a new PHP extension, you must restart PHP for the extension to take effect.

sudo systemctl restart apache2
Copy after login

This command will restart the Apache service and make the new PHP extension take effect.

  1. Install extensions manually

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
Copy after login

Unzip the extension source code:

tar -zxvf redis-4.3.0.tgz
Copy after login

Enter the unzipped directory:

cd redis-4.3.0
Copy after login

Compile and install Extensions:

sudo phpize
sudo ./configure
sudo make
sudo make install
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template