Once you have followed our guide on creating a local LAMP (Linux, Apache, MySQL and PHP/Perl) development environment, you will need to install some additional PHP extensions and packages for web site development. Some PHP extensions are bundled with PHP distribution already, but not necessarily installed by default. You can check the installed PHP extensions with the php -m command. You can also run php -i to get a wealth of information on PHP installation and its running environment.

In case you are in a shared web hosting environment and don't have shell access to your hosting server, you can create a simple PHP file with the following content:

<?php
  phpinfo();
?>

Upload the file to your hosting server and then visit it with your browser. It should give you detailed information that you can use to decide which additional PHP modules you may need to install.

In this article, we describe installation of three PHP extensions if they are not installed.

The first one is the the PHP curl extension with which you can send HTTP requests to fetch Web pages and automate certain tasks.

If you don't have curl installed on your box, then you first need to download it. After that, unpack it and run the following commands:

./configure --prefix=/opt/dev
gmake
gmake install

Since we don't need to update curl often, we can just install it to the common /opt/dev directory.

Now move to your PHP distribution's ext/curl directory and run the following commands:

./configure --with-curl=/opt/dev
gmake
gmake install

Then the file curl.so is installed to your PHP extension's directory /opt/dev/php/lib/php/extensions/no-debug-non-zts-20060613/ assuming you configure PHP with the default options.

Since this is probably the first PHP extension installed manually by you, you also need to modify PHP's initial configuration file /opt/dev/php/lib/php.ini. In this file, update the extension_dir with the right path to your extensions:

extension_dir = "/opt/dev/php/lib/php/extensions/no-debug-non-zts-20060613/"

Then add the following line after the above line to enable the PHP curl extension:

extension=curl.so

Now if you run php -m, it should include curl in the output module list.

The next extension is the PHP Data Objects (PDO) driver module for MySQL. PDO provides higher level of abstraction for database operations so some differences between database management systems (DBMSs) such as MySQL, SQLite and etc are hidden from you. Still, you need to install drivers for individual DBMSs. We assume that you use MySQL in your web site, so you need to install the pdo_mysql extension which also comes with PHP distribution. You can go to the extension's source directory and run the following commands:

./configure --with-pdo-mysql=/opt/dev/mysql
gmake
gmake install

You just need to configure the pdo_mysql extension with the right path to your MySQL base installation directory and then the file pdo_mysql.so is installed to the PHP's extension directly. Similarly, you also need to modify the php.ini file to use this module.

The third extension is the PHP gmp extension module which handles large number operations commonly used in cryptographic functions. This extension enables much faster execution of those functions.

The PHP gmp extension module depends on the GNU Multiple Precision library. If the latter is not installed, you need to download and install it first. Suppose it is installed in the /opt/dev directory, then you can just use this option --with-gmp=/opt/dev when configuring the PHP gmp extension module.

With these extensions installed, you should be able to do more interesting stuff with PHP. :)

Back to articles on setup