Custom Search
 


How to install PEAR on your shared web hosting account


Inside This Article
1. Install all PEAR packages by yourself
   
2Use the hosting company's PEAR installation

Install all PEAR packages by yourself



After you install PEAR on Windows for development use, you will eventually need to install it on your web hosting account for production use.

There are two choices when installing PEAR.

  1. Install all the PEAR packages by yourself so that you are in full control of everything.

  2. Use the hosting company's PEAR installation and install additional PEAR packages only when you need to.

Install all PEAR packages In this case, you are in full control of the entire PEAR packages installation, including PEAR Base System and any additional packages you need.

Step #1: Install PEAR Base System

1.1 Download Download PEAR Base System

Click the link above to open the download page. The version you download may be newer.

Download PEAR Base System

1.2 Once you have the package downloaded locally, extract it. You should have a folder called PEAR-X.X.X. In my case it's PEAR-1.9.1

To unzip, you can use open source file archiver 7-Zip.

1.3 Drill down to folder PEAR-X.X.X until you find a folder called PEAR.

unzipped PEAR package

1.4 Next connect to your web hosting account by FTP program.

1.5 Create a new folder called PEAR in your web hosting account's home directory. It does not have to be in the root of your web directory (where public_html is).

It's a good idea to create include directory one level above the public_html folder so that sensitive files are placed outside the publicly accessible web folder (where public_html is) - just an extra precaution.

To understand fully about how to create include path, refer to article Five ways to create include path for PHP.

1.6 Select all files and sub-folders in PEAR folder on your computer and upload them to the PEAR folder you just created on your web host.

Step #2: Create PEAR include path.

Depends on how your web hosting company set up their web server, you can include PEAR in two different ways:

  1. If PHP is compiled as a CGI binary, you will need to create include path for PEAR in your custom php.ini file. The file php.ini should normally be in the root of your web directory.

    Add the following line into your php.ini file:

    include_path = ".:/home/your_cpanel_username/PEAR"

    Make sure to replace your_cpanel_username with your actual cpanel username. Note that this php.ini file must be put in each directory where PEAR packages are needed.

    Note: If placing php.ini in your web root folder does not work, contact your hosting company. They must have set up their sever in a way that custom php.ini has to be accessed and modified differently.

  2. If PHP is compiled as an Apache module, you will need to create include path for PEAR in .htaccess file. The file .htaccess must be in the root of your web directory.

    Add the following line into your .htaccess file:

    php_value include_path ".:/home/your_cpanel_username/PEAR"

    Make sure to replace your_cpanel_username with your actual cpanel username.

Step #3: Test if PEAR has been installed correctly.

The best way to test is actually use a PEAR class to do something. We will use PEAR's text_highlighter class to display colored PHP code on a web page.

3.1 Download PEAR Text_Highlighter package

The file I downloaded was Text_Highlighter-0.7.1.tgz

Download Text Highlighter package

3.2 After unzip the package, rename the folder Text_Highlighter-0.7.1 to Text.

To unzip, you may want to use popular open source file archiver 7-Zip.

It looks like this after rename:

Rename text highlighter folder

3.3 Upload the folder Text from your computer to PEAR directory (created in step 1.5 and 1.6) in your web hosting account's home directory.

This will add the Text Highlighter package to the PEAR code library and it's ready to be used.

3.4 Create the style sheet.

Find the file sample.css in folder Text and upload it to your website root directory (where public_html is).

Text highlighter sample.css

On GeeksEngine, it's copied to http://www.geeksengine.com/sample.css

3.5 Create a PHP page and save it as test-pear.php in your localhost website.

On GeeksEngine, it's at http://www.geeksengine.com/test-pear.php

3.6 Open test-pear.php in your text editor and add the following code. The code displays colored PHP code on a web page.

<?
echo "<link rel='stylesheet' type='text/css' href='sample.css'>";

// Include Highlighter class
require_once("Text/Highlighter.php");

// This is the code we want to display
$code "<?
// This is a test page for PEAR Text_Highlighter package
\$message = \"Hello, world!\";

echo \$message;
?>"
;

// What to display - PHP code
$what "php";

// Define the class
$highlighter =& Text_Highlighter::factory($what);

// Call highlight method to display the code to web browser
echo $highlighter->highlight($code);
?>

3.7 Display test-pear.php page.

Open your web browser and view test-pear.php on your site. If you can see the colored PHP code as shown below, you have successfully installed PEAR base library.

Test code highlighter

To use any other packages, just download and add them to PEAR directory on your web host home directory.

Next, read Part II of this article Use the hosting company's PEAR installation.


Copyright© GeeksEngine.com




Inside This Article
1. Install all PEAR packages by yourself
   
2Use the hosting company's PEAR installation
Related Articles:

1.Steps to install PHP 5.x on Windows as a development machine
2.How to install Apache 2.x web server on Windows
3.How to connect two different versions of MySQL server on the same computer
4.How to configure MySQL server 5.1 on Windows
5.How to install MySQL server 5.1 on Windows with screenshots
6.Five ways to create include path for PHP
7.How to use Date and Time data as integer value in PHP and MySQL
8.How to use Apache Virtual Host to run multiple local websites on Windows
9.How to install PEAR on Windows
10.How to use PHP and Microsoft SMTP Virtual Server to send emails
11.How to install PHP server-side scripting language on Windows
12.How to install Apache 1.3 web server on Windows
13.How to install two different versions of MySQL server on the same PC
14.How to configure MySQL server 4.1 on Windows
15.How to install MySQL server 4.1 on Windows with screenshots
16.Export Northwind Access database to MySQL via ODBC


Other Recent Articles from the WAMP & LAMP category:

1.How to resolve Apache web server port 80 access problem
2.The free tools I use to build PHP and MySQL websites
3.Steps to install PHP 5.x on Windows as a development machine
4.How to install Apache 2.x web server on Windows
5.How to connect two different versions of MySQL server on the same computer
6.How to configure MySQL server 5.1 on Windows
7.How to install MySQL server 5.1 on Windows with screenshots
8.How to upgrade from PHP4 to PHP5
9.How to load time zone data for MySQL on Windows
10.How to use Apache Virtual Host to run multiple local websites on Windows
11.How to install PEAR on Windows
12.How to use PHP and Microsoft SMTP Virtual Server to send emails
13.How to install PHP server-side scripting language on Windows
14.How to install Apache 1.3 web server on Windows
15.How to install two different versions of MySQL server on the same PC
16.How to configure MySQL server 4.1 on Windows
17.How to install MySQL server 4.1 on Windows with screenshots
18.How to set up DSN in ODBC Data Source Administrator on Windows

Copyright © 2017 GeeksEngine.com. All Rights Reserved.

This website is hosted by HostGator.

No portion may be reproduced without my written permission. Software and hardware names mentioned on this site are registered trademarks of their respective companies. Should any right be infringed, it is totally unintentional. Drop me an email and I will promptly and gladly rectify it.

 
Home | Feedback | Terms of Use | Privacy Policy