VDS Sphera Knowledge Base
| Main / Browse Categories / PHP / How can I install and use PHP's Pear Package Manager? |
How can I install and use PHP's Pear Package Manager?
|
First, download this tar file: http://www.hardhathosting.com/docs/PEAR.tar.gz Then, create this directory inside your VDS account: mkdir /usr/local/pearUpload the PEAR.tar.gz file into the above newly created directory and run this command to untar the files: tar -xzvf PEAR.tar.gzRun the command ls -l and you should see something similar to this: total 524 drwxr-xr-x 24 username vuser 4096 May 26 13:03 PEAR -rw-r--r-- 1 username vuser 514370 May 26 11:49 PEAR.tar.gz drwxr-xr-x 2 username vuser 4096 May 17 17:55 bin -rw-r--r-- 1 username vuser 2398 May 17 17:55 index.php -rw-r--r-- 1 username vuser 387 May 17 17:55 pear.confChange directories to bin: cd binRun the command: pear listYou should see something similar to this: Installed packages: =================== Package Version State Archive_Tar 1.2 stable Benchmark 1.2.1 stable Cache 1.5.4 stable Calendar 0.5.1 beta Console_Getopt 1.2 stable DB 1.6.4 stable Date 1.4.3 stable HTML_Template_IT 1.1 stable HTTP 1.2.3 stable HTTP_Request 1.2.2 stable Mail 1.1.3 stable Net_Portscan 1.0.2 stable Net_SMTP 1.2.6 stable Net_Socket 1.0.2 stable Net_URL 1.0.12 stable Net_UserAgent_Detect 2.0.1 stable PEAR 1.3.1 stable PEAR_Frontend_Web 0.3 beta PHPUnit 1.0.1 stable Pager 2.2.2 stable XML_Parser 1.2.0beta3 beta XML_RPC 1.1.0 stable XML_Serializer 0.10.0 beta XML_Util 0.6.0beta1 betaNow, you must edit your php.ini file and add the new include path. Run this command: vi /ftp/lib/php.iniChange this line: include_path = "./:/usr/local/lib/php"to this: include_path = "./:/usr/local/lib/php:/usr/local/pear/PEAR"Restart Apache: /etc/rc.d/init.d/apachectl restartNow, you need to copy the /usr/local/pear/pear.conf file to /.pearrc cp /usr/local/pear/pear.conf /.pearrcYou can now test your installation with this simple portscan php script. Change www.yourdomain.com to a domain of your choice. Upload the script to your website and run it thru your web browser.
<?php
require_once("Net/Portscan.php");
$scanner = new Net_Portscan;
$host = "www.yourdomain.com";
$minPort = 10;
$maxPort = 100;
$activePorts = $scanner -> checkPortRange( $host, $minPort, $maxPort);
foreach($activePorts as $portnumber => $status) {
if ($status) {
echo "port number $portnumber is open. <br />";
}
}
?>
You can run this command for help and a list of all pear commands:
pear helpYou should see something similar to this: Usage: pear [options] command [command-options] <parameters> Type "pear help options" to list all options. Type "pear help <command>" to get the help for the specified command. Commands: build Build an Extension From C Source bundle Unpacks a Pecl Package clear-cache Clear XML-RPC Cache config-get Show One Setting config-help Show Information About Setting config-set Change Setting config-show Show All Settings cvsdiff Run a "cvs diff" for all files in a package cvstag Set CVS Release Tag download Download Package download-all Downloads each available package from master_server info Display information about a package install Install Package list List Installed Packages list-all List All Packages list-upgrades List Available Upgrades login Connects and authenticates to remote server logout Logs out from the remote server makerpm Builds an RPM spec file from a PEAR package package Build Package package-dependencies Show package dependencies package-validate Validate Package Consistency remote-info Information About Remote Packages remote-list List Remote Packages run-tests Run Regression Tests search Search remote package database shell-test Shell Script Test sign Sign a package distribution file uninstall Un-install Package upgrade Upgrade Package upgrade-all Upgrade All PackagesSo, for example, let's say you wanted to install the package Mail_Mime. You would need to run this command: pear install Mail_MimeYou should see something similar to this: downloading Mail_Mime-1.2.1.tgz ... Starting to download Mail_Mime-1.2.1.tgz (15,268 bytes) .....done: 15,268 bytes install ok: Mail_Mime 1.2.1You can find a list of all available packages from Pear's official website: http://pear.php.net/packages.php
User Comments
|
||||||||
Attachments
| No attachments. |
Related Articles


