1

I am new to a lot of server configurations and options. I want to add extra php libraries/extensions to my server. Where do I add them? (I am on a CENTOS 6.5 VPS)

For example, I want to add the phpseclib php extension:

Their website instructions are minimum:

Usage This library is written using the same conventions that libraries in the PHP Extension > and Application Repository (PEAR) used to be written in (current requirements break PHP4 compatibility). In particular, this library needs to be in your include_path:

    <?php
    set_include_path(get_include_path() . PATH_SEPARATOR . 'phpseclib');

    include('Net/SSH2.php');
    ?>

It tells me how to use it, but it doesn't tell me where to add the actual extension files. Should I added it under?

usr/local/lib ?

usr/local/lib/php ?

usr/local/lib/php/pear ?

Or can I add it under public_html? Also, my VPS has several users under /home/.. is that away to make the library available for only one user?

2
set_include_path(get_include_path() . PATH_SEPARATOR . 'phpseclib');

You place the library/extension files wherever you want to place them (wherever is appropriate for your server setup or web application) - this I believe is what the example above is showing you. Replace phpseclib with the absolute server path of where you decide to save the phpseclib library files. It will differ from server to server, so they can't tell you exactly where they should go, they can only give you an example.

For instance, if you save the files to /home/user/lib/phpseclib (which, in this case is above the DOCUMENT_ROOT of /home/user/public_html) then ...

set_include_path(get_include_path().PATH_SEPARATOR.'/home/user/lib/phpseclib');

If you add these library files to your existing include_path (examine the output of get_include_path() as E Carter Young suggests) then you don't need to modify the include_path by calling set_include_path() as mentioned above.

By making the library path part of the include_path (which you set in your "configuration" script as part of your web application) you then don't need to think about file system paths later in your code. This makes your code a lot more portable.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.