Installing OCS Inventory Asset Management Software on CentOS 8

OCS “Open Computers and Software Inventory Next Generation” is an open-source asset management solution that enables you to inventory IT assets efficiently. It collects hardware and software data from remote machines running the OCS client program and presents the inventory through a user-friendly web interface. Utilizing the SNMP protocol, it gathers information from various network devices like printers, switches, and computers.

In this comprehensive guide, we will walk you through the installation of OCS Inventory on a CentOS 8 server.

Prerequisites

  • A server running CentOS 8.
  • A valid domain name pointing to your server’s IP. For this tutorial, we will use the domain ocs.example.com.
  • The server should have the root password configured.

Getting Started

To begin, it’s essential to install the EPEL and REMI repositories on your server. Execute the following commands:

        dnf install https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm
        dnf install https://rpms.remirepo.net/enterprise/remi-release-8.rpm

Following the installation of these packages, you should install the dnf-utils package and enable the PowerTools repository using:

        dnf install dnf-utils -y
        dnf config-manager --set-enabled PowerTools

After completing these installations, move on to the next step.

Install Apache, MariaDB, and PHP

OCS operates using a web server, employs MariaDB for its database needs, and is developed with PHP. Therefore, your server will require Apache, MariaDB, PHP, and associated PHP extensions.

Start by installing Apache and MariaDB:

        dnf install httpd mariadb-server -y

Next, install PHP version 7.3. Since CentOS’s default repository lacks this version, enable the REMI repository and proceed:

        yum-config-manager --enable remi
        dnf module reset php
        dnf module install php:remi-7.3

Now, install PHP 7.3 along with required extensions:

        dnf install php php-curl php-zip php-gd php-soap php-xml php-mbstring php-fpm mod_perl unzip curl -y

Modify the php.ini file to suit your configuration needs:

        nano /etc/php.ini

Modify these values as needed:

        upload_max_filesize = 10M
        post_max_size = 10M
        max_execution_time = 300
        max_input_time = 300
        memory_limit = 256M

Save the file and restart the Apache, MariaDB, and PHP-FPM services, configuring them to launch on system boot:

        systemctl start httpd
        systemctl start php-fpm
        systemctl start mariadb
        systemctl enable httpd
        systemctl enable php-fpm
        systemctl enable mariadb

Configure MariaDB Database

First, secure your MariaDB instance as it doesn’t come with a set root password. Run the following:

        mysql_secure_installation

Follow the prompts to set your root password and enhance security. Once complete, log into the MariaDB shell:

        mysql -u root -p

Create a necessary database and user:

        CREATE DATABASE ocsweb;
        GRANT ALL PRIVILEGES ON ocsweb.* TO ocs@localhost IDENTIFIED BY "password";
        FLUSH PRIVILEGES;
        EXIT;

Install OCS Inventory

Install the OCS repository first:

        dnf install https://rpm.ocsinventory-ng.org/ocsinventory-release-latest.el8.ocs.noarch.rpm -y

Proceed by installing OCS:

        dnf install ocsinventory -y

Import the OCS database:

        mysql -u root -p ocsweb < /usr/share/ocsinventory-reports/ocsreports/files/ocsbase.sql

Enable Apache’s rewrite module by editing:

        nano /etc/httpd/conf/httpd.conf

Append the following at the file’s conclusion:

        LoadModule rewrite_module modules/mod_rewrite.so

Restart Apache to apply the modifications:

        systemctl restart httpd

Configure SELinux and Firewall

Since SELinux is on by default, configure it thusly:

        setsebool httpd_can_network_connect on -P
        chcon -R -t httpd_sys_rw_content_t /usr/share/ocsinventory-reports

Authorize HTTP and HTTPS traffic through the firewall:

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

Access OCS Inventory Web UI

Access the OCS web interface via http://your-server-ip/ocsreports/install.php. You should see a screen similar to the one below:

OCS GUI

Enter your MariaDB connection details and click Send:

Installer

Following database updates, you’ll see:

Database update

Complete the update, and finally, access the OCS dashboard:

OCS Login

Use default credentials, username: admin, password: admin.

Remember to delete the installation script:

        rm -rf /usr/share/ocsinventory-reports/ocsreports/install.php

Conclusion

Congratulations! You have successfully installed and configured the OCS Inventory server on CentOS 8. You can now install the OCS Inventory agents on remote machines to begin collecting software and hardware data. Feel free to reach out if you have any questions.

FAQ

What is OCS Inventory?

OCS Inventory is an open-source solution to manage and inventory IT assets. It collects and presents hardware and software information from remote machines through a web interface.

Why do I need the REMI repository?

The REMI repository contains the PHP 7.3 version required for running OCS on CentOS 8, which is not available in the default CentOS repositories.

How do I access the OCS Inventory Web UI?

You can access the OCS web interface by entering the URL http://your-server-ip/ocsreports/install.php in your browser.