Enter your search

Manually Install PECL Extensions on a Media Temple (dv) Server


Dev with Geoff - Development help and advice from our CTO Geoff Wagstaff

Having used MediaTemple‘s hosting options for quite some time, we’ve built up a fair amount of experience working with their (dv) servers. Every now and again you may find it necessary to extend the core functionality of the pre-compiled PHP supplied with the (dv) server using PECL extensions to give your apps that little bit more of a cutting edge.

There is a quick and easy way to insall the PECL modules on your (dv) server: pecl install [extension]. However, if for whatever reason this does not work for you, this guide documents a manual installation method.

A preliminary word of warning & disclaimer
We have only tested the following guide on (dv) 3.5 servers, and cannot in any way guarantee that this method will provide a stable and/or functional installation of your chosen PECL module(s) on your server, version 3.5 or otherwise. If your (dv) server is not version 3.5, this guide may not work due to possible path and environment differences. Therefore, any attempt to follow this guide is undertaken at entirely at your own risk and we cannot be held responsible for any resultant problems.

Phew, now I got that off my chest, let’s get started.

Paths needed
PHP extension (modules) directory: /usr/lib/php/modules
php.ini file: /etc/php.ini
PHP extension .ini files (to facilitate autoload of extensions): /etc/php.d/

For this to work, you’ll need to have root access to your server, and you’ll most probably need developer tools installed as well. To obtain these, log in to your MediaTemple (ac) panel and enable them both there.

Note: Replace [extension] with actual extension name

Open up your terminal using a remote SSH client (if you don’t have one, install an SSH client like PUTTY) and log into your server as root.

Download the extension from PECL to somewhere on the server (e.g. /tmp/download/):
cd /tmp/download/
wget http://pecl.php.net/get/[extension].tgz

N.B. For this bit, [extension] must be replaced by your extension name including any version numbers of the version you downloaded e.g. memcache-2.2.5

Extract the compressed package and change directory to the extracted source folder
tar -xvf [extension].tgz
cd [extension]

From this point onwards, [extension] now represents the actual name of the extension, for example, memcache instead of memcache-2.2.5

Prepare the build environment for the extension and make the binaries
phpize && ./configure --enable-[extension] && make

You may see lots of code/writing flicking up in your terminal. This is normal.
If all that goes good, run:
make install

This should install the shared extension into /usr/lib/php/extensions. If this works properly, the [extension].so extension file will be automatically placed in the PHP extensions directory (/usr/lib/php/extensions)

Navigate to folder containing the .ini files for extensions:
cd /etc/php.d/

Create a new file called [extension].ini
vi [extension].ini

Press i and write/paste the following inside, replacing [extension] with the extension name:
; Enable [extension] extension

Press ESC then type :wq and press enter to save and exit the file.

Restart apache so PHP can load the new extension when it starts up:
/etc/init.d/httpd restart

That’s it! The new module is now installed and should be working properly. If you want to verify this, create a test.php file somewhere on your site, place

< ?php phpinfo(); ?>

inside and access it with your browser. Information for the new extension will appear in the list of extensions if everything has installed correctly.

We hope this helps you out. We would greatly appreciate it if anyone can test this on (dv) servers older or newer than (dv) 3.5 and let us know the result.

You May Also Like

Group 5 Created with Sketch. Group 11 Created with Sketch. CLOSE ICON Created with Sketch. icon-microphone Group 9 Created with Sketch. CLOSE ICON Created with Sketch. SEARCH ICON Created with Sketch. Group 4 Created with Sketch. Path Created with Sketch. Group 5 Created with Sketch.