Installing PHP extensions on Linux

Solution 1:

It might help to know what distro you are running, and what version of php. I'm talking about the process of finding packages as well since its better to know how to find stuff than just install what you're told. Teach an man to fish and all that.

Now, I have ubuntu and centos boxen on hand, and through the magic of the package search command....

For Ubuntu

I used apt-cache search KEYWORD php to find the packages in question - in this case the name of the plugin as the keywords. From that, you can install the 3 packages you need through apt-get install php5-mcrypt php5-gd php5-mysql - the last package should cover PDO on debian like distros I believe

For Centos/Red Hat

I used dnf search KEYWORDS the same way - but not all the packages you need seem available by default. Older versions of these distributions use yum rather than dnf.

The packages you're interested in are php-pdo php-gd and php-mcrypt - the last is not in the default repository (I checked on yum, then googled)- you may need to add the EPEL repository to get that package instead

Using the default package manager should result in easier to install and maintain packages, since your updates will happen with everything else.

Solution 2:

Have a look at

Often Linux system have the pear application in repository, so you would just need to run a command for each extension you'd like to install.