BareMetal.com

Baremetal
My Account
Domain Registration Management Services
Web Services
Tech Support
Tech Support Contact Info
CGI Library
Your Server
Billing Info
Company Info
Charities
Legal Info
Employment
Privacy Statement

BM


Technical Support

Tech Support: PHP - Installing your own extensions;

PHP - Installing your own extensions

It's not our policy to install arbitrary PHP extensions. If we did we would spend a lot of time doing it, all the servers would end up being different and we could break sites when moving them between servers. Fortunately, if you take a minute to configure pear for your own use, using the pear command to maintain your own extensions is quite easy.

Configuring PEAR

By default, PEAR wants to use the system settings, and that won't work for a number of security related reasons. Ask support to configure your account for ssh access or persuade them to run the following commands as your userid:

   # pear command should be here:
   export PATH=$PATH:/usr/local/scripts/

   export D=/home/$USER/php-exts
   echo extensions directory has been set to $D
   
   mkdir $D
   pear config-set bin_dir $D/bin
   pear config-set doc_dir $D/doc
   pear config-set ext_dir $D/ext
   pear config-set cfg_dir $D/cfg
   pear config-set data_dir $D/data
   pear config-set download_dir $D/download
   pear config-set temp_dir $D/tmp
   pear config-set test_dir $D/test
   pear config-set php_dir $D/php
   pear config-set php_dir $D/php
   pear config-set cache_dir $D/cache


That configures pear for you. The pear command should be quite functional now. You can type "pear list" and it should show you an empty list of installed packages. "pear install" should download, build, and install packages. For example:
   pear install HTTP_Request

Unfortunately, that just configures the pear command, and builds your extensions, you still need to teach PHP to be able to find your extensions.

Configuring PHP to use your extensions

To get PHP to use your extensions, you need to add some lines to your php.ini file (which can be in the top FTP directory, or the top directory of your website). The simplest this is to two lines like this (changing tbrown to match your userid, so it matches the extensions directory reported above):

   extension_dir=/home/tbrown/php-exts/ext
   include_path=.:/home/tbrown/php-exts/php
This is simple and error free. You are now fully in charge of handling your own extensions.

Unfortunately the above configuration will cause you to lose access to the baremetal installed (e.g. system) extensions. You can easily install your own private versions of those via the "pear install ..." command (see above section).

Another appoach will work well in most cases. Most extensions do not use code written in C to extend the PHP interpreter, and will not use the extension dir specified above. If this is the case, you can leave that out and add /usr/local/scripts/php5/lib/php to your include path... now you will have access to both your own extensions and the baremetal installed ones (and your installation should over-ride the baremetal one).

   include_path=.:/home/tbrown/php-exts/php:/usr/local/scripts/php5/lib/php

If your extensions do include C code you may need to force PHP to load the extension with a line in your script like "dl('example_extension.so');" or a line in your php.ini file like: "extension=example_extension"

(Unfortunately, extensions including C code may break when baremetal updates the version of PHP interpreter.)



 
Home Page    Domain Registration Services    Web Services    Technical Support
About Baremetal    Privacy Statement    Billing Info    Charities
My Account    Legal Info    Search BareMetal

Copyright © 1996-2012, BareMetal.com Inc.
Last updated: Wednesday, 26-Oct-2016 14:31:10 PDT
Last Accessed from: ec2-18-153-48-112.eu-central-1.compute.amazonaws.com
Questions and comments to support@baremetal.com