Install OCS-NG Inventory on CentOS 8 Stream

|
Last Updated:
|
|

In this guide, we are going to learn how to install OCS-NG Inventory on CentOS 8 Stream. OCS (Open Computer and Software) Inventory Next Generation is an opensource tool that is used to inventory IT assets. It collects information about the hardware and software of networked machines running the OCS client program (“OCS Inventory Agent”). OCS can be used to visualize the inventory through a web interface. It is deployed in a agent-server architecture where an OCS NG agent is installed on an asset to be inventoried to collect the information about that asset. In cases where an agent cannot be installed like in routers, switches, SNMP polling can be used to collect asset information.

Install OCS-NG Inventory on CentOS 8 Stream

Prerequisites

OCS-NG Inventory is a web application and thus requires a LAMP/LEMP Stack. It also requires a number of perl Libraries and PHP extensions as stated on prerequisites page.

Update your system packages

dnf update

The update command may fail with the error below;

Error: Failed to download metadata for repo 'appstream': Cannot prepare internal mirrorlist: No URLs in mirrorlist

The official announcement from CentOS Project stated that CentOS 8 will reach end-of-life (EOL) on December 31, 2021, and its repositories will be archived. After that date, no further updates or security patches will be provided for CentOS 8.

As a result, you need to switch to Vault Repositories.

sed -i 's/mirrorlist/#mirrorlist/g' /etc/yum.repos.d/CentOS-*
sed -i 's|#baseurl=http://mirror.centos.org|baseurl=http://vault.centos.org|g' /etc/yum.repos.d/CentOS-*

Thereafter, re-run the update;

dnf update -y

Install Apache Web server on CentOS 8

In this demo, we are using LAMP for OCS-NG and hence, LAMP stack components are installed as follows;

dnf install httpd -y

Start and Enable Apache services.

systemctl enable --now httpd

If FirewallD is running, allow Apache external access.

firewall-cmd --permanent --add-service=http
firewall-cmd --reload

Install MariaDB Database Server on CentOS 8

dnf install mariadb mariadb-server -y

Start and enable MariaDB service.

systemctl enable --now mariadb

Create OCS-NG Inventory Database and Database User

Begin by running MySQL initial security script.

mysql_secure_installation

Next, login and create OCS-NG database. Replace the names of the database accordingly.

mysql -u root -p
create database ocsdb;

After that, create OCS-NG database user and assign all rights on OCS-NG database. Replace the username and Password accordingly.

grant all on ocsdb.* to ocsadmin@localhost identified by 'ocsDBpassW0rd';

Reload privileges table and exit the database.

flush privileges;
quit

Install PHP and Required Extensions for OCS-NG Inventory

In order to avoid issues as we have experienced with other versions of PHP like OCS-NG blank screen, OCS-NG stuck on Processing… with PHP 7.3, this guide will stick to using PHP 7.2 which is the default available version on CentOS 8. If you know how to get around this issue, kindly drop the lead on the comments section.

In order to install all required PHP modules, install PHP Remi repos;

dnf install epel-release
dnf install centos-release-stream
dnf install -y https://rpms.remirepo.net/enterprise/remi-release-8.rpm

Enable PHP 8.1 Remi repos;

dnf module reset -y php
dnf module enable php:remi-8.1 -y

Also, enable PowerTool Repos on CentOS 8;

sed -i 's/enabled=0/enabled=1/' /etc/yum.repos.d/CentOS-Linux-PowerTools.repo

Next, install PHP and the required PHP modules.

dnf install -y \
    php \
    php-domxml \
    php-gd \
    php-imap \
    php-ldap \
    php-mbstring \
    php-mysqlnd \
    php-opcache \
    php-pdo \
    php-pear \
    php-pecl-apcu \
    php-pecl-zip \
    php-soap \
    php-xmlrpc \
    php-xml \
    php-zip \
    php-fpm \
    php-bcmath \
    php-intl

Start and enable PHP-FPM;

systemctl enable --now php-fpm

Install Perl and Build Tools

Run the command below to install Perl, perl modules and the required build tools.

dnf install -y \
    make \
    wget \
    gcc \
    perl-Archive-Zip \
    perl-Compress-Zlib \
    perl-DBD-MySQL \
    perl-DBI \
    perl-Mojolicious \
    perl-Net-IP \
    perl-Plack \
    perl-SOAP-Lite \
    perl-Switch \
    perl-XML-Entities \
    perl-XML-Simple \
    perl-Apache-DBI \
    perl-Digest-SHA1 \
    perl-Apache2-SOAP

Download OCS-NG Inventory Server Tarball

Navigate to OCS downloads page and download the current release version of OCS Server.

You can simply run the command below to grab OCS 2.12.0, which is the current stable release version as of this guide update.

Be sure to replace the versions accordingly by updating the value of the VER variable below;

VER=2.12.0
wget https://github.com/OCSInventory-NG/OCSInventory-ocsreports/releases/download/${VER}/OCSNG_UNIX_SERVER-${VER}.tar.gz

Once the download is donem extract the archive.

tar xzf OCSNG_UNIX_SERVER-${VER}.tar.gz

Install OCS-NG Inventory on CentOS Stream

Navigate to OCS source directory.

cd OCSNG_UNIX_SERVER-${VER}/

Execute the installation script.

sh setup.sh

If you happen to get the error, setup.sh: line 16: source: setup.answers: file not found, then fix by running the command below;

sed -i 's/source setup.answers/source .\/setup.answers/' setup.sh

Then re-run the setup.

./setup.sh

Follow through the prompts to install OCS-NG inventory accordingly. Press ENTER to accept the defaults.


+----------------------------------------------------------+
|                                                          |
|  Welcome to OCS Inventory NG Management server setup !   |
|                                                          |
+----------------------------------------------------------+

Trying to determine which OS or Linux distribution you use
+----------------------------------------------------------+
| Checking for Apache web server binaries !				|
+----------------------------------------------------------+

CAUTION: If upgrading Communication server from OCS Inventory NG 1.0 RC2 and
previous, please remove any Apache configuration for Communication Server!

Do you wish to continue ([y]/n)?y
Assuming Communication server 1.0 RC2 or previous is not installed
on this computer.

Starting OCS Inventory NG Management server setup from folder /root/OCSNG_UNIX_SERVER-2.12.0
Storing log in file /root/OCSNG_UNIX_SERVER-2.12.0/ocs_server_setup.log

+----------------------------------------------------------+
| Checking for database server properties...			  |
+----------------------------------------------------------+

Your MySQL client seems to be part of MySQL version 10.3.
Your computer seems to be running MySQL 4.1 or higher, good ;-)

Which host is running database server [localhost] ?
OK, database server is running on host localhost ;-)

On which port is running database server [3306] ?
OK, database server is running on port 3306 ;-)


+----------------------------------------------------------+
| Checking for Apache web server daemon...				|
+----------------------------------------------------------+

Where is Apache daemon binary [/usr/sbin/httpd] ?
OK, using Apache daemon /usr/sbin/httpd ;-)


+----------------------------------------------------------+
| Checking for Apache main configuration file...		  |
+----------------------------------------------------------+

Where is Apache main configuration file [/etc/httpd/conf/httpd.conf] ?
OK, using Apache main configuration file /etc/httpd/conf/httpd.conf ;-)


+----------------------------------------------------------+
| Checking for Apache user account...					 |
+----------------------------------------------------------+

Which user account is running Apache web server [apache] ?
OK, Apache is running under user account apache ;-)


+----------------------------------------------------------+
| Checking for Apache group...							|
+----------------------------------------------------------+

Which user group is running Apache web server [apache] ?
OK, Apache is running under users group apache ;-)


+----------------------------------------------------------+
| Checking for Apache Include configuration directory...   |
+----------------------------------------------------------+

Setup found Apache Include configuration directory in
/etc/httpd/conf.d.
Setup will put OCS Inventory NG Apache configuration in this directory.
Where is Apache Include configuration directory [/etc/httpd/conf.d] ?
OK, Apache Include configuration directory /etc/httpd/conf.d found ;-)


+----------------------------------------------------------+
| Checking for PERL Interpreter...						|
+----------------------------------------------------------+

Found PERL interpreter at  ;-)
Where is PERL interpreter binary [/usr/bin/perl] ?
OK, using PERL interpreter /usr/bin/perl ;-)


Do you wish to setup Communication server on this computer ([y]/n)?y


+----------------------------------------------------------+
|             Checking for Make utility...                 |
+----------------------------------------------------------+

OK, Make utility found at  ;-)

+----------------------------------------------------------+
|        Checking for Apache mod_perl version...           |
+----------------------------------------------------------+

Checking for Apache mod_perl version 1.99_22 or higher
Found that mod_perl version 1.99_22 or higher is available.
OK, Apache is using mod_perl version 1.99_22 or higher ;-)

+----------------------------------------------------------+
|    Checking for Communication server log directory...    |
+----------------------------------------------------------+

Communication server can create detailed logs. This logs can be enabled
by setting integer value of LOGLEVEL to 1 in Administration console
menu Configuration.
Where to put Communication server log directory [/var/log/ocsinventory-server] ?
OK, Communication server will put logs into directory /var/log/ocsinventory-server ;-)

+----------------------------------------------------------------------------+
|    Checking for Communication server plugins configuration directory...    |
+----------------------------------------------------------------------------+

Communication server need a directory for plugins configuration files. 
Where to put Communication server plugins configuration files [/etc/ocsinventory-server/plugins] ?
OK, Communication server will put plugins configuration files into directory /etc/ocsinventory-server/plugins ;-)

+-------------------------------------------------------------------+
|   Checking for Communication server plugins perl directory...     |
+-------------------------------------------------------------------+

Communication server need a directory for plugins Perl modules files.
Where to put Communication server plugins Perl modules files [/etc/ocsinventory-server/perl] ?
OK, Communication server will put plugins Perl modules files into directory /etc/ocsinventory-server/perl ;-)


+----------------------------------------------------------+
| Checking for required Perl Modules...					|
+----------------------------------------------------------+

Checking for DBI PERL module...
Found that PERL module DBI is available.
Checking for Apache::DBI PERL module...
Found that PERL module Apache::DBI is available.
Checking for DBD::mysql PERL module...
Found that PERL module DBD::mysql is available.
Checking for Compress::Zlib PERL module...
Found that PERL module Compress::Zlib is available.
Checking for XML::Simple PERL module...
Found that PERL module XML::Simple is available.
Checking for Net::IP PERL module...
Found that PERL module Net::IP is available.
Checking for Archive::Zip Perl module...
Found that PERL module Archive::Zip is available.


Do you wish to setup Rest API server on this computer ([y]/n)?y

+----------------------------------------------------------+
| Checking for REST API Dependencies ...              		 |
+----------------------------------------------------------+

Found that PERL module Mojolicious::Lite is available.
Found that PERL module Switch is available.
Found that PERL module Plack::Handler is available.

+----------------------------------------------------------+
| Configuring REST API Server files ...               		 |
+----------------------------------------------------------+

Where do you want the API code to be store [/usr/lib64/perl5/vendor_perl] ?
Copying files to /usr/lib64/perl5/vendor_perl

+----------------------------------------------------------+
| Configuring REST API Server configuration files ...  		 |
+----------------------------------------------------------+


+----------------------------------------------------------+
|                 OK, looks good ;-)                       |
|                                                          |
|     Configuring Communication server Perl modules...     |
+----------------------------------------------------------+

Checking if your kit is complete...
Looks good
Generating a Unix-style Makefile
Writing Makefile for Apache::Ocsinventory
Writing MYMETA.yml and MYMETA.json

+----------------------------------------------------------+
|                 OK, looks good ;-)                       |
|                                                          |
|      Preparing Communication server Perl modules...      |
+----------------------------------------------------------+


+----------------------------------------------------------+
|                 OK, prepare finshed ;-)                  |
|                                                          |
|     Installing Communication server Perl modules...      |
+----------------------------------------------------------+


+----------------------------------------------------------+
| OK, Communication server Perl modules install finished;-)|
|                                                          |
|     Creating Communication server log directory...       |
+----------------------------------------------------------+

Creating Communication server log directory /var/log/ocsinventory-server.

Fixing Communication server log directory files permissions.
Configuring logrotate for Communication server.
Removing old communication server logrotate file /etc/logrotate.d/ocsinventory-NG
Writing communication server logrotate to file /etc/logrotate.d/ocsinventory-server


+----------------------------------------------------------------------+
|        OK, Communication server log directory created ;-)            |
|                                                                      |
|   Creating Communication server plugins configuration directory...   |
+----------------------------------------------------------------------+

Creating Communication server plugins configuration directory /etc/ocsinventory-server/plugins.


+----------------------------------------------------------------------+
| OK, Communication server plugins configuration directory created ;-) |
|                                                                      |
|        Creating Communication server plugins Perl directory...       |
+----------------------------------------------------------------------+

Creating Communication server plugins Perl directory /etc/ocsinventory-server/perl.


+----------------------------------------------------------------------+
|     OK, Communication server plugins Perl directory created ;-)      |
|                                                                      |
|               Now configuring Apache web server...                   |
+----------------------------------------------------------------------+

To ensure Apache loads mod_perl before OCS Inventory NG Communication Server,
Setup can name Communication Server Apache configuration file
'z-ocsinventory-server.conf' instead of 'ocsinventory-server.conf'.
Do you allow Setup renaming Communication Server Apache configuration file
to 'z-ocsinventory-server.conf' ([y]/n) ?y
OK, using 'z-ocsinventory-server.conf' as Communication Server Apache configuration file
Removing old communication server configuration to file /etc/httpd/conf.d/ocsinventory.conf
Writing communication server configuration to file /etc/httpd/conf.d/z-ocsinventory-server.conf

+----------------------------------------------------------------------+
|       OK, Communication server setup successfully finished ;-)       |
|                                                                      |
| Please, review /etc/httpd/conf.d/z-ocsinventory-server.conf |
|         to ensure all is good. Then restart Apache daemon.           |
+----------------------------------------------------------------------+


Do you wish to setup Administration Server (Web Administration Console)
on this computer ([y]/n)?y

+----------------------------------------------------------+
|    Checking for Administration Server directories...     |
+----------------------------------------------------------+

CAUTION: Setup now install files in accordance with Filesystem Hierarchy
Standard. So, no file is installed under Apache root document directory
(Refer to Apache configuration files to locate it).
If you're upgrading from OCS Inventory NG Server 1.01 and previous, YOU
MUST REMOVE (or move) directories 'ocsreports' and 'download' from Apache
root document directory.
If you choose to move directory, YOU MUST MOVE 'download' directory to
Administration Server writable/cache directory (by default
/var/lib/ocsinventory-reports), especially if you use deployment feature.

Do you wish to continue ([y]/n)?y
Assuming directories 'ocsreports' and 'download' removed from
Apache root document directory.

Where to copy Administration Server static files for PHP Web Console
[/usr/share/ocsinventory-reports] ?
OK, using directory /usr/share/ocsinventory-reports to install static files ;-)

Where to create writable/cache directories for deployment packages,
administration console logs, IPDiscover and SNMP [/var/lib/ocsinventory-reports] ?
OK, writable/cache directory is /var/lib/ocsinventory-reports ;-)


+----------------------------------------------------------+
|         Checking for required Perl Modules...            |
+----------------------------------------------------------+

Checking for DBI PERL module...
Found that PERL module DBI is available.
Checking for DBD::mysql PERL module...
Found that PERL module DBD::mysql is available.
Checking for XML::Simple PERL module...
Found that PERL module XML::Simple is available.
Checking for Net::IP PERL module...
Found that PERL module Net::IP is available.

+----------------------------------------------------------+
|      Installing files for Administration server...       |
+----------------------------------------------------------+

Creating PHP directory /usr/share/ocsinventory-reports/ocsreports.
Copying PHP files to /usr/share/ocsinventory-reports/ocsreports.
Fixing permissions on directory /usr/share/ocsinventory-reports/ocsreports.
Creating database configuration file /usr/share/ocsinventory-reports/ocsreports/dbconfig.inc.php.
Creating IPDiscover directory /var/lib/ocsinventory-reports/ipd.
Fixing permissions on directory /var/lib/ocsinventory-reports/ipd.
Creating packages directory /var/lib/ocsinventory-reports/download.
Fixing permissions on directory /var/lib/ocsinventory-reports/download.
Creating snmp mibs directory /var/lib/ocsinventory-reports/snmp.
Fixing permissions on directory /var/lib/ocsinventory-reports/snmp.
Creating Administration server log files directory /var/lib/ocsinventory-reports/logs.
Fixing permissions on directory /var/lib/ocsinventory-reports/logs.
Creating Administration server temporary files directory /var/lib/ocsinventory-reports/tmp_dir.
Fixing permissions on directory /var/lib/ocsinventory-reports/tmp_dir.
Creating Administration server scripts log files directory /var/lib/ocsinventory-reports/scripts.
Fixing permissions on directory /var/lib/ocsinventory-reports/scripts.
Configuring IPDISCOVER-UTIL Perl script.
Installing IPDISCOVER-UTIL Perl script.
Fixing permissions on IPDISCOVER-UTIL Perl script.
Writing Administration server configuration to file /etc/httpd/conf.d/ocsinventory-reports.conf

+----------------------------------------------------------------------+
|        OK, Administration server installation finished ;-)           |
|                                                                      |
| Please, review /etc/httpd/conf.d/ocsinventory-reports.conf
|          to ensure all is good and restart Apache daemon.            |
|                                                                      |
| Then, point your browser to http://server//ocsreports
|        to configure database server and create/update schema.        |
+----------------------------------------------------------------------+


Setup has created a log file /root/OCSNG_UNIX_SERVER-2.12.0/ocs_server_setup.log. Please, save this file.
If you encounter error while running OCS Inventory NG Management server,
we can ask you to show us its content !

DON'T FORGET TO RESTART APACHE DAEMON !

Enjoy OCS Inventory NG ;-)

For any installation issues, you can check on the log file, $HOME/OCSNG_UNIX_SERVER-${VER}/ocs_server_setup.log.

Configure OCS-NG Database Connection Settings

Edit the OCS-NG web server configurations to configure database connection settings.

vim /etc/httpd/conf.d/z-ocsinventory-server.conf
...
  # Master Database settings
  # Replace localhost by hostname or ip of MySQL server for WRITE
  PerlSetEnv OCS_DB_HOST localhost
  # Replace 3306 by port where running MySQL server, generally 3306
  PerlSetEnv OCS_DB_PORT 3306
  # Name of database
  PerlSetEnv OCS_DB_NAME ocsdb
  PerlSetEnv OCS_DB_LOCAL ocsdb
  # User allowed to connect to database
  PerlSetEnv OCS_DB_USER ocsadmin
  # Password for user
  PerlSetVar OCS_DB_PWD ocsDBpassW0rd
...
vim /etc/httpd/conf.d/zz-ocsinventory-restapi.conf
...
<Perl>
  $ENV{PLACK_ENV} = 'production';
  $ENV{MOJO_HOME} = '/usr/lib64/perl5/vendor_perl';
  $ENV{MOJO_MODE} = 'deployment';
  $ENV{OCS_DB_HOST} = 'localhost';
  $ENV{OCS_DB_PORT} = '3306';
  $ENV{OCS_DB_LOCAL} = 'ocsdb';
  $ENV{OCS_DB_USER} = 'ocsadmin';
  $ENV{OCS_DB_PWD} = 'ocsDBpassW0rd';
  $ENV{OCS_DB_SSL_ENABLED} = 0;
#  $ENV{OCS_DB_SSL_CLIENT_KEY} = '';
#  $ENV{OCS_DB_SSL_CLIENT_CERT} = '';
#  $ENV{OCS_DB_SSL_CA_CERT} = '';
  $ENV{OCS_DB_SSL_MODE} = 'SSL_MODE_PREFERRED';
</Perl>
...

Save and exit.

vim /usr/share/ocsinventory-reports/ocsreports/dbconfig.inc.php
$_SESSION["SERVEUR_SQL"]="localhost";
$_SESSION["COMPTE_BASE"]="ocsdb";
$_SESSION["PSWD_BASE"]="ocsDBpassW0rd";
?>

Save and exit the configs file after making the changes.

Set the proper permissions and ownership of OCS configuration files.

chmod -R 766 /usr/share/ocsinventory-reports
chown -R apache:apache /usr/share/ocsinventory-reports
chown -R apache:apache /var/lib/ocsinventory-reports

Also adjust SELinux permissions on web server configuration files.

chcon -R -t httpd_sys_rw_content_t /usr/share/ocsinventory-reports

Restart Apache, MariaDB and PHP-FPM services.

systemctl restart httpd mariadb php-fpm

Finalize OCS-NG Configuration via Web Interface

Navigate to http://server-hostname-or-IP/ocsreports on your browser to access OCS.

Configure OCS Inventory database connections and click Send.

Next, click Click here to enter OCS-NG GUI to login to OCS web interface.

Use the default credentials: login=admin and password=admin.

If prompted to run a database update, please go ahead and proceed to OCS login interface.

OCS-NG User interface.

Reset the password: Settings gear > My account > Password.

Remove the installation script.

mv /usr/share/ocsinventory-reports/ocsreports/install.php{,.old}

That marks the end of our guide on how to install OCS-NG Inventory on CentOS 8 Stream.

You can then learn how to install OCS-NG inventory agents for collecting information about the hardware and software of networked machines.

Install OCS Inventory Agent on Debian 10/Ubuntu 18.04

Reference:

OCS-NG Inventory Documentation

Install OCS-NG Inventory on Fedora 30/Fedora 29

Install Snipe-IT on Debian 10/Ubuntu 18.04

Install LAMP Stack on CentOS 8

Install LAMP Stack on Fedora 30

Install LAMP Stack on Fedora 28/29

SUPPORT US VIA A VIRTUAL CUP OF COFFEE

We're passionate about sharing our knowledge and experiences with you through our blog. If you appreciate our efforts, consider buying us a virtual coffee. Your support keeps us motivated and enables us to continually improve, ensuring that we can provide you with the best content possible. Thank you for being a coffee-fueled champion of our work!

Photo of author
koromicha
I am the Co-founder of Kifarunix.com, Linux and the whole FOSS enthusiast, Linux System Admin and a Blue Teamer who loves to share technological tips and hacks with others as a way of sharing knowledge as: "In vain have you acquired knowledge if you have not imparted it to others".

11 thoughts on “Install OCS-NG Inventory on CentOS 8 Stream”

  1. Boa noite,
    fiz todos os passos porem na hora de entrar pela web não funciona.
    O que poderia ser? fiz exatamente igual vocês descreveram.
    —–
    Esta página não está funcionando
    10.1.1.42 não consegue atender a esta solicitação no momento.
    HTTP ERROR 500
    —-

    Reply
  2. Hi,

    dont change name of install.php file before “Finalize OCS-NG Configuration via Web Interface”.
    First configure on web then change file install.php

    Reply
  3. i haven’t use remy repo only the official
    i have just backporter php-imap from centos 7 to centos 8

    if you want to use the official php 7.3 from redhat

    dnf module disable php
    dnf module enable php:7.3
    dnf update

    Reply
  4. Buenas!

    Consegui colocar o sistema pra funcionar, mas quando rodo o cliente no windows, os dados do inventário não sobem no OCS.
    O OCS está no servidor:
    http://192.168.0.11/ocsreports/
    Tive o cuidado de colocar o nome do banco de dados e a senha também. Logo na tela web, mas não sobe o inventário.
    Alguém pode dar um help?

    Reply
  5. hi, thanks a lot for the tutorial

    i done everything just like you said, but in this moment im triying to configurate some agents but i cant see the information in the web interface, i look in the database file and the information its there.
    the webapi its said “processing” and keep there.

    Reply
    • Hi Diego,
      That might be an issue with PHP version. Kindly check the section, Install PHP and Required Extensions for OCS-NG Inventory, of the guide.

      Reply
  6. Thank you very much
    I followed your instructions and successfully installed OCS Server (Ver 2.12.1) on CentOS8 – Stream
    Can you provide instructions on how to configure SSL and HTTPS self-signed certificates?

    Reply

Leave a Comment