Custom Search
 


How to install PEAR on your shared web hosting account


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

Use the hosting company's PEAR installation



If you use a shared web hosting, the chances are that it has already installed BEAR Base System. You will need to find out in which directory they are placed. It's very often that the PEAR package you need is not part of the default PEAR installation provided by your hosting company. In this case, you have to install your own.

Step #1: Create new folder.

1.1 Connect to your hosting account via FTP program.

1.2 Create a new folder under your account home directory called pear (it is on the same level as public_html folder).

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.

Step #2: Add new PEAR package.

2.1 Download the PEAR package you need.

For illustration purpose, here we assume you need PEAR Text_Highlighter package.

The file I downloaded was Text_Highlighter-0.7.1.tgz

Download Text Highlighter package

2.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

2.3 Upload the entire folder Text to pear folder you created in step 1.2 above. Note that folder Text is now inside folder pear.

Step #3: Add include path for PEAR package.

3.1 Contact your hosting company to find out where their PEAR library is stored. Normally it should be at /usr/local/lib/php

3.2 Add include path in either php.ini or .htaccess file.

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 = ".:/usr/local/lib/php:/home/your_cpanel_username/pear"

    Note that /usr/local/lib/php is where your hosting company installed PEAR. It could be different though.

    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 Apache module, you will need to create include path for PEAR in .htaccess file. The file .htaccess file must be in the root of your web directory.

    Add the following line into your .htaccess file:

    php_value include_path ".:/usr/local/lib/php:/home/your_cpanel_username/pear"

    Make sure to replace your_cpanel_username with your actual cpanel username.

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

We are going to use PEAR's text_highlighter class to display colored PHP code on a web page.

4.1 Create the style sheet.

Find the file sample.css in folder Text which you renamed in step 2.2 and upload it to your website root directory.

Text highlighter sample.css

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

4.2 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

4.3 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);
?>

4.4 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 below, you have successfully installed PEAR base library.

Test code highlighter

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


Copyright© GeeksEngine.com




Inside This Article
1Install all PEAR packages by yourself
   
2. Use 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.Install all PEAR packages by yourself
10.How to install PEAR on Windows
11.How to use PHP and Microsoft SMTP Virtual Server to send emails
12.How to install PHP server-side scripting language on Windows
13.How to install Apache 1.3 web server on Windows
14.How to install two different versions of MySQL server on the same PC
15.How to configure MySQL server 4.1 on Windows
16.How to install MySQL server 4.1 on Windows with screenshots
17.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.Install all PEAR packages by yourself
12.How to install PEAR on Windows
13.How to use PHP and Microsoft SMTP Virtual Server to send emails
14.How to install PHP server-side scripting language on Windows
15.How to install Apache 1.3 web server on Windows
16.How to install two different versions of MySQL server on the same PC
17.How to configure MySQL server 4.1 on Windows
18.How to install MySQL server 4.1 on Windows with screenshots
19.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