I always, always forget how to do this and it takes an hour of googling to figure this out again. Basically I often need to see not just what php modules are installed on my system, but also what can be installed.
For example you can see what is already installed and available to you on your current system you simply type
in your command line. This command will list all of what is installed currently on your system.
But that is not what I want and probably not what you want if you are reading this. What I want is to know what is available for installing, or better what are the exact names of the packages. For this information you need a different command.
sudo apt-cache search php7*
This command searches the apt cache for packages that contain php7* the * is a wildcard meaning anything that looks like php7 such as php7.4-mysql. Try the command above and you will get a list of all of the php modules specifically for version 7.4. Not all modules will be listed. You can use another command to see all of the available php modules even if they don’t contain 7.4 in the name you can install them.
To see all php modules available use this command.
sudo apt-cache search php*
Minus the 7 and it will return every last module that contains the word php.
Then to install anything you need you use a command like the following
sudo apt install php7.4-mysql php7.4-curl php7.4-json php7.4-cgi php7.4-xsl
And that is how you list and install php modules/extensions.
Pro-tip : add -y to the end of the apt install command so you don’t have to keep answering yes during the module installs
After you install the modules you need to restart the PHP service. To see all the services currently running in order to find your PHP service type
That will list all of your systems services. Find the name of your php installation and restart it with this line of code
service php7.4-fpm restart
Here is an interesting article about how apt-cache works on linux
Here is a link to some more resources about this topic.
You must log in to post a comment.