Re: Set up PEAR on webserver

From: Date: Mon, 23 Jan 2012 15:49:09 +0000
Subject: Re: Set up PEAR on webserver
References: 1  Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-54744@lists.php.net to get a copy of this message
Hello Olivier, I am assuming you have no previous knowledge on anything below - so I am trying to put it in the easiest way to understand as possible. I am sorry if that is not the case and sometimes I get too pedantic. Roughly speaking, PEAR are just a collection of libraries (files) that you can use on your own application. Besides PHP files (PHP classes, tests etc.), a PEAR package (or library) may also contain documentation, data files and executable scripts among other kind of files. PEAR itself is made of a code part (that is the code base for all the PEAR packages) and a user interface - called the "PEAR installer". Once PEAR is correctly installed in your system, the PEAR installer is an easy way to download and install new PEAR packages. Also, the PEAR installer is what we call a "command line interface" - that means it has no graphical front end so you need a terminal - that kind of text-only window, sometimes with a greenish font, usually linked to computer experts by Hollywood movies - to run it. So, when the documentation tells you to do a : $ pear Commands: build Build an Extension From C Source bundle Unpacks a Pecl Package channel-add Add a Channel it means that you are supposed to type in a terminal the given commands when the lines starts with a "$" (as a regular user) or "#" (as a super user) and everything else is expected to be the output of that command. in the example above, you are supposed to type in a terminal the command "pear" and as the result, it should print the other lines on your screen. now that we know we need a terminal, let's learn how to get access to one. there are lots of different ways to do it on your local machine - and all of them depends on what operating system you are running. if you are on: [mac os x] try opening terminal.app from spotlight or double-clicking on it under finder > applications > utilities > terminal [most linux flavors] you can right click on your desktop and look for "terminal" in the menu [windows] try start > run > cmd (its sometimes called the "command prompt" in the Windows menus) by the other hand, if you want to access the terminal of a remote machine, for instance your web server which you have no physical access to, you need to open a remote terminal through a network from your local machine TO your remote server. it is ok to have the internet as the network. and for the network protocol - which is the "language" used to make the remote connection - we usually use something called "ssh". besides the network and the protocol, we also need a client - which is the application that will make the connection. again, the ssh client will depends on what operating system you are running on your local machine but basically if you are running Windows you can try a graphical program called "PuTTY" or for any other UNIX-like OS you can try typing "ssh address-or-domain-name-of-remote-server" on your local terminal. Of course, we are assuming your remote web server provides a SSH service and you were given a valid account (username/password etc.). You can check with your web hosting company if that is the case. If you have no SSH access to your web server, then you will not be able to get a terminal in there nor run the PEAR installer (to easily install PEAR packages) or get PEAR installed by the automated process. Hopefully, like I said before, PEAR are just a bunch of files so you are still able to install it on a remote machine even tough you have no terminal access to it. Like Markus suggested, the procedure goes as follow: - open a terminal on your local machine - install PEAR on you local machine (please refer to the PEAR documentation on how to do it) - install on your local machine all the PEAR packages you need using the PEAR installer (command named "pear") - at this time everything - both PEAR and the packages you installed - should be on the same place below a directory in your local machine - after everything is done, copy all the PEAR files from your local machine to the remote machine using FTP or by any other mean - on your remote machine you need to tell PHP to look for PEAR inside the directory you just copied you can achieve the last step using 1 of 3 ways: 1) edit php.ini and look for the directive include_path (add the PEAR directory in there) 2) call PHP function set_include_path() inside your PHP application before including anything from PEAR [1] 3) if you web server machine runs Apache you can create a .htaccess file and set PHP's include path from there [2] I hope that it covers all the basics needed to get you started. You will still need to read PEAR documentation to get the job done, though. Best regards, ~IF. [1] http://br.php.net/manual/en/function.set-include-path.php [2] http://php.net/manual/en/configuration.changes.php

« previous php.pear.dev (#54744) next »