How to install the Archive_Tar PHP extension

How to install the Archive_Tar PHP extension

A step-by-step guide for Linux, cPanel, and Windows environments

Archive_Tar is a PEAR package that provides TAR archive creation, extraction, and manipulation in PHP. It is commonly required by CMS platforms, package managers, and installer scripts.

Prerequisites​

Before you begin, make sure you have:

  • PHP 5.4 or higher installed
  • PEAR installed, or Composer available as an alternative
  • SSH or terminal access to your server (for most methods)

Method 1 — Install via PEAR (recommended)​

PEAR is the traditional way to install Archive_Tar. This works on most Linux-based servers.

1 - Check if PEAR is installed
Code:
bash
pear version

If PEAR is not installed, install it first:
Code:
bash (Debian / Ubuntu)
sudo apt-get install php-pear

Code:
bash (CentOS / RHEL / AlmaLinux)
sudo yum install php-pear

2 - Install the package
Code:
bash
sudo pear install Archive_Tar
PEAR will download and install the package along with any dependencies.

3 - Verify the installation
Code:
bash
pear list | grep Archive_Tar

You should see the installed version listed in the output.

Method 2 — Install via Composer​

If you are using Composer in your project, you can pull in Archive_Tar as a dependency without needing PEAR at all.

1 - Require the package
Code:
bash
composer require pear/archive_tar
2 - Include the autoloader in your PHP file
Code:
php
<?php
require_once 'vendor/autoload.php';
$tar = new Archive_Tar('myarchive.tar.gz');

Method 3 — cPanel / WHM (shared hosting)​

If you are on a managed cPanel server and do not have root SSH access, use the built-in PEAR installer through cPanel:

1
Log into your cPanel account and navigate to Software → PHP PEAR Packages.
2
In the Install a PHP PEAR Package field, type Archive_Tar and click Install.
3
Once installed, cPanel will confirm the package and version. No PHP restart is required for PEAR packages.

Verify it works in PHP​

Create a quick test script to confirm the class is available:

Code:
php — test.php
<?php
require_once 'Archive/Tar.php'; // PEAR path
// or use autoload if installed via Composer

if (class_exists('Archive_Tar')) {
    echo 'Archive_Tar is installed and ready.';
} else {
    echo 'Archive_Tar could not be found.';
}

Common issues​

"Class Archive_Tar not found"​

This usually means the PEAR include path is not set in your php.ini. Check the PEAR include path with:

Code:
bash
pear config-get php_dir
Then ensure that path is in your include_path directive inside php.ini.

Permission errors during install​

If you see permission denied errors, make sure you are running the install command with sudo, or contact your hosting provider to install it at the server level.

PEAR install fails on PHP 8.x​

Some older PEAR versions have compatibility issues with PHP 8. In this case, the Composer method is the most reliable alternative.

Note for WordPress / Joomla users: Many CMS platforms bundle their own copy of Archive_Tar inside their package. If you are seeing errors from a CMS, check whether the CMS version is outdated before installing system-wide.
 

Donate: Campaign

Total amount
$0.00
Goal
$100.00
Back
Top