I have searched through the Internet for the answer, and still don’t get it.
The problem is that I can’t access the remote server’s OS. I can just file-transfer scripts or any files to there and run the scripts there.
So I don’t know how to run any install command in the remote OS.
Can I just install the extension package by downloading the package, unzip it, then put the API files in the httpdocs folder in server, then ‘include’ them in my scripts for use?
In some tutorials for web, they taught that, to check if PEAR is installed in server, we can run phpinfo() in php script, then check the configure command to see if it is –with-pear or –without-pear. But I just can’t see any of them in the configure command row!
they claim that beyond version 4.3 for PHP, PEAR has been installed for us. The version of mine is PHP Version 5.2.17. But I just got no method to check if it is really installed.
Many questions – let me try to answer each of them one by one.
Find PEAR
PEAR should be enabled by default – which would explain that you don’t see this in the configure-string.
Another test is to check the value of
include_path–/usr/local/pear,/usr/share/phpthese values (= the location of your PEAR install) depend on the OS. You can see this viaphpinfo()or:To finally check if PEAR is installed, try this code:
No error? This means that PEAR is installed and correctly configured (in your
include_path).A local PEAR tree
If PEAR is not installed or it is and you don’t have write access to the location (or your administrator cannot install PEAR packages for you), the best is the following:
include_pathin your scriptAdjusting the include_path
Add the following to your script:
It’s important that your new ‘path’ comes first – prepending means that it gets searched for libraries first. So for example, if your version of PEAR is more up to date than the one already on your server, it’ll use that. Less side-effects.
PHP extensions
In most cases you cannot install pecl extensions on a server without access. You could try to pre-compile the extension on in a virtual machine (with the same OS) and then upload the
.sofile and usedl()to load it at runtime, but this probably won’t work in most situations.Fin
I hope that makes sense.
Updated: include_path primer
Imagine this piece of code:
This will make PHP search it’s
include_pathfor the location of PEAR.php.A typical path looks like this:
This means the
include_pathcontains two directories currently (:is the delimiter):./usr/share/phpOrder of these paths is crucial to PHP:
PEAR.php(from our example) is found in the current directory, it’s included firstPEAR.phpis only in/usr/share/php, PHP will still search the current directory firstThe
include_pathis usually set in yourphp.ini, or at runtime (when the script is executed) usingset_include_path(...)or withini_set('include_path', ...). To get the current value of the include path you can useget_include_path()orini_get('include_path')as well.To avoid PHP searching the
include_path, you could use the following:An absolute path stops PHP from using the
include_path. But since the location of PEAR is not standardized across various linux distributions, Unix, MacOSX or Windows, it’s not recommended to do this.HTH