When I trying to install and configure the Nagios client showed an error Can't locate LWP/UserAgent.pm in INC (you may need to install the LWP::UserAgent module) on CentOS 7.2 and Ubuntu 20.04 Operating system, finally found the solution.

Commonly we can fix the above error for all the Linux environments with the steps below,

Download the libwww-perl-6.06.tar.gz or supported version to your instance by WGET command,

$ wget http://www.cpan.org/modules/by-module/LWP/libwww-perl-6.06.tar.gz

Extract the libwww-perl-6.06.tar.gz file using the tar command,


$ tar xvzf libwww-perl-6.06.tar.gz

$ cd libwww-perl-6.06


Install the package using the commands pers, make and make install


$ sudo perl Makefile.PL

$  sudo make

$ sudo make install


Follw the steps below for CentOS 7.2 and Ubuntu 20.04 to fix the above steps,

For CentOS 7.2:

sudo yum install perl-libwww-perl


For Ubuntu 20.04

apt-get install libwww-perl


or Install the packages from the PERL:

​perl -MCPAN -e 'install Bundle::LWP'

or
​sudo perl -MCPAN -e 'install LWP::UserAgent::Cached'