PHP modules are extensions that can greatly extend the core functionality of PHP. These modules are compiled libraries that can help you utilize different methods to connect to other services without the need to rewrite these methods yourself each time you’d like to use them. By enabling these modules your php code can have the capability and adaptable to seamlessly interact with other services such as MySQL. The focus of this article is to help show you how to install PHP modules quickly and easily. This article implies that you have already installed PHP on your Ubuntu 14.04 server, however if you have not yet done so please review the following article: How to install PHP (Ubuntu 14.04).
How To Install PHP Modules In Ubuntu 14.04
Before getting started you’ll need to login to your server using SSH. If you’re not familiar with how to do this, please take a moment and read through the following article: Connecting to Your Server via SSH. Once you have connected to your server via SSH you can move on with the installation.
To install software in Ubuntu you’d generally use apt-get followed by the install option and finally the package name, so the full command would be something like apt-get install <package-name>. Installing PHP modules is pretty much the same process, but what if you weren’t sure what PHP modules are available? Simple, you’d use the apt-cache search command. For example, to search for PHP 5 modules, you’d use:
apt-cache search php5-
This would provide you with a list of available modules and a short description of each module. However if you need additional information you can either Google the module name or use the following command and syntax:
apt-cache show package-name
So if for example you wanted to see more information about php5-fpm you’d use the following:
apt-cache show php5-fpm
Once you’re ready to install a PHP module you can do so using the following command, again we will use php5-fpm as an example:
apt-get install php5-fpm
You can also install multiple modules or packages by placing a space between each separate module or package like so:
apt-get install php5-fpm php5-cli
The command above would install fpm and the cli package for PHP 5. Like most things, moderation is the key and it is best to only install modules that you need. We hope that after reading this article you now feel more comfortable installing PHP modules. If you’re interested in testing your servers PHP processing, we have an article that you might enjoy which covers how to do just that: How to create a PHP info page