CentOS / RHEL: Install php-tidy Module / Extension

I am a new CentOS / RHEL / Red Hat / Fedora Linux server user. I need to provide tidy library support using php. How do I install php-tidy on RHEL or CentOS Linux for Apache web server?

Tutorial details
Difficulty level Easy
Root privileges Yes
Requirements CentOS or RHEL with EPEL and remi repo
Est. reading time 3 minutes
You need to install the following module using the yum command on RHEL/CentOS/Fedora/Scientific Linux server:
  1. php-tidy – The php-tidy package contains a dynamic shared object that will add support for using the tidy library to PHP.

Install php-tidy module on RHEL/CentOS

First enable EPEL repo, run:
# yum install epel-release
Here is what I see on my RHEL/CentOS 7.x:

Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.piconets.webwerks.in
 * extras: mirrors.piconets.webwerks.in
 * updates: mirrors.piconets.webwerks.in
Resolving Dependencies
--> Running transaction check
---> Package epel-release.noarch 0:7-11 will be installed
--> Finished Dependency Resolution
 
Dependencies Resolved
 
===============================================================================
 Package                Arch             Version        Repository        Size
===============================================================================
Installing:
 epel-release           noarch           7-11           extras            15 k
 
Transaction Summary
===============================================================================
Install  1 Package
 
Total download size: 15 k
Installed size: 24 k
Is this ok [y/d/N]: y
Downloading packages:
epel-release-7-11.noarch.rpm                              |  15 kB   00:00     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : epel-release-7-11.noarch                                    1/1 
  Verifying  : epel-release-7-11.noarch                                    1/1 
 
Installed:
  epel-release.noarch 0:7-11                                                   
 
Complete!

Searching and installing php-tidy

Type the following commands along with grep command and then install it:
yum update
yum search php-tidy
yum search php | grep tidy

Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.piconets.webwerks.in
 * epel: download.nus.edu.sg
 * extras: mirrors.piconets.webwerks.in
 * updates: mirrors.piconets.webwerks.in
============================ N/S matched: php-tidy ============================
php-tidy.x86_64 : Standard PHP module provides tidy library support
 
  Name and summary matches only, use "search all" for everything.

Open the Terminal and type the following yum command:
# yum install php-tidy
Sample outputs:

Loaded plugins: auto-update-debuginfo, protectbase, rhnplugin, security
This system is receiving updates from RHN Classic or RHN Satellite.
0 packages excluded due to repository protections
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package php-tidy.x86_64 0:5.3.3-27.el6_5 will be installed
--> Processing Dependency: libtidy-0.99.so.0()(64bit) for package: php-tidy-5.3.3-27.el6_5.x86_64
--> Running transaction check
---> Package libtidy.x86_64 0:0.99.0-19.20070615.1.el6 will be installed
--> Finished Dependency Resolution
 
Dependencies Resolved
 
=============================================================================================
 Package     Arch      Version                        Repository                        Size
=============================================================================================
Installing:
 php-tidy    x86_64    5.3.3-27.el6_5                 rhel-x86_64-server-optional-6     36 k
Installing for dependencies:
 libtidy     x86_64    0.99.0-19.20070615.1.el6       rhel-x86_64-server-6             127 k
 
Transaction Summary
=============================================================================================
Install       2 Package(s)
 
Total download size: 164 k
Installed size: 0  
Is this ok [y/N]: y
Downloading Packages:
(1/2): libtidy-0.99.0-19.20070615.1.el6.x86_64.rpm                    | 127 kB     00:00     
(2/2): php-tidy-5.3.3-27.el6_5.x86_64.rpm                             |  36 kB     00:00     
---------------------------------------------------------------------------------------------
Total                                                        654 kB/s | 164 kB     00:00     
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing : libtidy-0.99.0-19.20070615.1.el6.x86_64                                   1/2 
  Installing : php-tidy-5.3.3-27.el6_5.x86_64                                            2/2 
  Verifying  : php-tidy-5.3.3-27.el6_5.x86_64                                            1/2 
  Verifying  : libtidy-0.99.0-19.20070615.1.el6.x86_64                                   2/2 
 
Installed:
  php-tidy.x86_64 0:5.3.3-27.el6_5                                                           
 
Dependency Installed:
  libtidy.x86_64 0:0.99.0-19.20070615.1.el6                                                  
 
Complete!

Restart / reload web-server

Type the following command to restart / reload Apache server:
# service httpd restart

Verify new settings

# php -i | grep -color tidy

How to install php-tidy on a CentOS / RHEL version 8

Run the following command to enable remi remo
sudo yum install yum-utils http://rpms.remirepo.net/enterprise/remi-release-8.rpm
I am going to enable PHP version 7.4 stable:
sudo yum module list php
sudo yum module reset php
sudo yum module enable php:remi-7.4

Now search it:
$ sudo yum search php-tidy
We will see a list as follows:

Last metadata expiration check: 0:03:05 ago on Wed Mar 10 06:47:18 2021.
======================= Name Exactly Matched: php-tidy ========================
php-tidy.x86_64 : Standard PHP module provides tidy library support
=========================== Name Matched: php-tidy ============================
php56-php-tidy.x86_64 : Standard PHP module provides tidy library support
php70-php-tidy.x86_64 : Standard PHP module provides tidy library support
php71-php-tidy.x86_64 : Standard PHP module provides tidy library support
php72-php-tidy.x86_64 : Standard PHP module provides tidy library support
php73-php-tidy.x86_64 : Standard PHP module provides tidy library support
php74-php-tidy.x86_64 : Standard PHP module provides tidy library support
php80-php-tidy.x86_64 : Standard PHP module provides tidy library support

Next install php74-php-tidy as follows:
sudo yum install php74-php-tidy
Restart the Apache 2 server:
$ sudo systemctl restart httpd
See “How to Install PHP 7.x on CentOS 8 For Nginx” and “How To Install Linux, Apache, MySQL, PHP (LAMP) stack On RHEL 8” for more info.

Summing up

You need to enable EPLE repo and remi and then install php-tidy package as per your PHP version.


🐧 Get the latest tutorials on Linux, Open Source & DevOps via RSS feed or Weekly email newsletter.

🐧 5 comments so far... add one


CategoryList of Unix and Linux commands
Disk space analyzersdf ncdu pydf
File Managementcat cp mkdir tree
FirewallAlpine Awall CentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Network UtilitiesNetHogs dig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg jobs killall kill pidof pstree pwdx time
Searchinggrep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNAlpine CentOS 8 Debian 10 Firewall Ubuntu 20.04
5 comments… add one
  • bob Dec 18, 2013 @ 8:02

    Can you please tell me what does this library do? This php-tidy? Is this related to HTML by any chance?
    Thank you!

  • Grig Larson Dec 18, 2013 @ 16:52
    • bob Dec 19, 2013 @ 9:47

      got it. :) thanks.

  • Danny Nov 5, 2014 @ 7:55

    THis not work at all on centos 6.1

    [root@dedi712 ~]# yum install php-tidy
    Loaded plugins: fastestmirror
    Loading mirror speeds from cached hostfile
    * base: mirror.nl.webzilla.com
    * extras: mirror.nl.webzilla.com
    * updates: centos.mirror1.spango.com
    Setting up Install Process
    No package php-tidy available.
    Error: Nothing to do

    getting stuk

  • Mike Mar 10, 2021 @ 5:59

    yum -config-manager --enable epel
    yum install libtidy

Leave a Reply

Your email address will not be published.

Use HTML <pre>...</pre> for code samples. Still have questions? Post it on our forum