Linux Tutorials

Install OCS Inventory on Ubuntu 24.04 / Rocky Linux 10

OCS Inventory (Open Computers and Software Inventory) is an open-source asset management tool that collects hardware and software inventory data from networked machines. It gives sysadmins a centralized web console to track every device on the network – CPUs, RAM, storage, installed software, network interfaces, and more. OCS Inventory supports agents on Linux, Windows, macOS, and Android, making it a solid choice for mixed-environment IT asset tracking.

Original content from computingforgeeks.com - post 60913

This guide walks through a complete OCS Inventory Server 2.12.3 installation on Ubuntu 24.04 LTS and Rocky Linux 10. We cover all dependencies (Apache, MariaDB, PHP, Perl), database setup, the web-based setup wizard, firewall rules, and deploying inventory agents on both Linux and Windows clients.

Prerequisites

Before starting the installation, make sure you have the following in place:

  • A server running Ubuntu 24.04 LTS or Rocky Linux 10 with at least 2GB RAM and 2 CPU cores
  • Root or sudo access to the server
  • A fully qualified domain name (FQDN) or static IP address for the server
  • Internet access to download packages and OCS Inventory source files
  • Ports 80/TCP (HTTP) and 443/TCP (HTTPS) open for web access

Step 1: Install OCS Inventory Dependencies

OCS Inventory Server runs on a LAMP stack with additional Perl modules for the communication server. The administration console is written in PHP, and the communication server that receives agent data is a Perl Apache module.

On Ubuntu 24.04

Start by updating the package index and installing Apache, MariaDB, PHP, Perl, and all required extensions. If you need a detailed LAMP stack setup on Ubuntu, check our dedicated guide.

sudo apt update

Install the web server, database, PHP, and core development tools:

sudo apt install -y apache2 mariadb-server php php-mysql php-gd php-mbstring php-xml php-curl php-soap php-zip php-pclzip libapache2-mod-php libapache2-mod-perl2 libapache2-mod-perl2-dev

Install the required Perl modules for the OCS communication server:

sudo apt install -y perl libxml-simple-perl libdbi-perl libdbd-mysql-perl libapache-dbi-perl libnet-ip-perl libsoap-lite-perl libarchive-zip-perl libcompress-zlib-perl libio-compress-perl make build-essential

Install additional Perl modules from CPAN that are not available in the Ubuntu repositories:

sudo cpan install XML::Entities Apache2::SOAP Mojolicious::Lite Switch Plack::Handler

On Rocky Linux 10

On Rocky Linux, OCS Inventory provides an official RPM repository that simplifies the installation. First, install EPEL and the Remi repository for PHP modules. For a full LAMP stack on RHEL/Rocky Linux, see our separate guide.

sudo dnf install -y epel-release

Install Apache, MariaDB, PHP, and Perl with all required modules:

sudo dnf install -y httpd mariadb-server php php-mysqlnd php-gd php-mbstring php-xml php-soap php-zip php-curl mod_perl mod_perl-devel

Install the Perl dependencies:

sudo dnf install -y perl-XML-Simple perl-DBI perl-DBD-MySQL perl-Net-IP perl-SOAP-Lite perl-Archive-Zip perl-Compress-Zlib perl-Mojolicious perl-Plack perl-Switch perl-XML-Entities make gcc

If any Perl modules are missing from the DNF repositories, install them through CPAN:

sudo cpan install Apache::DBI Apache2::SOAP Plack::Handler

Enable and start the Apache and MariaDB services:

sudo systemctl enable --now httpd mariadb

On Ubuntu, Apache and MariaDB start automatically after installation. Confirm both services are running:

systemctl status apache2 mariadb

On Rocky Linux, check the services with:

systemctl status httpd mariadb

Step 2: Create OCS Inventory Database

Secure the MariaDB installation first by setting a root password and removing anonymous users:

sudo mariadb-secure-installation

Follow the prompts – set a strong root password, remove anonymous users, disallow remote root login, and remove the test database. Once done, create the OCS Inventory database and a dedicated user:

sudo mariadb -u root -p

Run the following SQL commands to create the database and grant privileges:

CREATE DATABASE ocsweb CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE USER 'ocsuser'@'localhost' IDENTIFIED BY 'StrongPassword123!';
GRANT ALL PRIVILEGES ON ocsweb.* TO 'ocsuser'@'localhost';
FLUSH PRIVILEGES;
EXIT;

Replace StrongPassword123! with a secure password of your choice. Note the database name ocsweb – this is the default expected by OCS Inventory.

Step 3: Download and Install OCS Inventory Server

Download the latest OCS Inventory Server package from the official GitHub releases page. At the time of writing, the latest stable version is 2.12.3.

cd /tmp
wget https://github.com/OCSInventory-NG/OCSInventory-ocsreports/releases/download/2.12.3/OCSNG_UNIX_SERVER-2.12.3.tar.gz

Extract the archive and move into the directory:

tar -xzf OCSNG_UNIX_SERVER-2.12.3.tar.gz
cd OCSNG_UNIX_SERVER-2.12.3

Run the setup script to install the communication server, REST API, and administration console:

sudo sh setup.sh

The setup script is interactive. It asks questions about your environment. Here are the recommended answers:

  • Database server host: localhost
  • Database server port: 3306
  • Apache config directory: /etc/apache2/conf-available (Ubuntu) or /etc/httpd/conf.d (Rocky Linux)
  • Apache user: www-data (Ubuntu) or apache (Rocky Linux)
  • Apache group: www-data (Ubuntu) or apache (Rocky Linux)
  • Install Communication server: y
  • Install REST API: y
  • Install Administration console: y
  • Log directory: /var/log/ocsinventory-server

The installer creates log and configuration directories, copies the Perl modules, and sets up the web console files. Check the output for any errors. The installation log is saved to ocs_server_setup.log in the current directory.

Step 4: Configure Apache for OCS Inventory

The setup script creates Apache configuration files for the communication server and the web console. Update the database credentials in the communication server config.

On Ubuntu 24.04

Edit the communication server configuration file:

sudo vi /etc/apache2/conf-available/z-ocsinventory-server.conf

Find and update the database connection settings to match the credentials you created in Step 2:

PerlSetEnv OCS_DB_HOST localhost
PerlSetEnv OCS_DB_PORT 3306
PerlSetEnv OCS_DB_NAME ocsweb
PerlSetEnv OCS_DB_USER ocsuser
PerlSetVar OCS_DB_PWD StrongPassword123!

Enable the OCS configuration files and required Apache modules:

sudo a2enconf z-ocsinventory-server ocsinventory-reports
sudo a2enmod perl rewrite
sudo systemctl restart apache2

On Rocky Linux 10

Edit the communication server configuration:

sudo vi /etc/httpd/conf.d/z-ocsinventory-server.conf

Update the same database connection directives with your credentials, then restart Apache:

sudo systemctl restart httpd

Verify Apache loaded the OCS modules without errors:

sudo apachectl -t

The output should show Syntax OK. If you see errors about missing Perl modules, install them with CPAN and restart Apache.

Step 5: Run OCS Inventory Web Setup Wizard

Open a web browser and navigate to your server’s IP address or hostname followed by /ocsreports/install.php:

http://your-server-ip/ocsreports/install.php

The web wizard runs through the following steps:

  • Step 1 – Database connection: Enter the MySQL/MariaDB user (ocsuser), password, hostname (localhost), port (3306), and database name (ocsweb)
  • Step 2 – Database initialization: The wizard creates all required tables in the ocsweb database
  • Step 3 – Configuration summary: Review settings and complete the installation

After the setup completes, remove the install script for security:

sudo rm -f /usr/share/ocsinventory-reports/ocsreports/install.php

Log in to the OCS Inventory console at http://your-server-ip/ocsreports using the default credentials:

  • Username: admin
  • Password: admin

Change the default admin password immediately after your first login by going to the user settings page.

Step 6: Install OCS Inventory Agent on Linux Clients

The OCS Inventory agent runs on client machines and sends hardware and software inventory data back to the server. The latest Unix agent version is 2.10.4.

Install Agent on Ubuntu/Debian

Install the agent dependencies and build tools:

sudo apt install -y libmodule-install-perl dmidecode libxml-simple-perl libcompress-zlib-perl libnet-ip-perl libdigest-md5-perl libdata-uuid-perl libcrypt-ssleay-perl libnet-ssleay-perl liblwp-protocol-https-perl libproc-pid-file-perl libproc-daemon-perl libfile-pid-perl net-tools libsys-syslog-perl pciutils ipmitool nmap libnet-snmp-perl libnet-netmask-perl

Download and install the Unix agent from the official GitHub release:

cd /tmp
wget https://github.com/OCSInventory-NG/UnixAgent/releases/download/v2.10.4/Ocsinventory-Unix-Agent-2.10.4.tar.gz
tar -xzf Ocsinventory-Unix-Agent-2.10.4.tar.gz
cd Ocsinventory-Unix-Agent-2.10.4

Run the Perl Makefile and install:

sudo perl Makefile.PL
sudo make
sudo make install

During the Makefile.PL step, provide the server URL when prompted:

  • OCS Inventory server URL: http://your-ocs-server-ip/ocsinventory
  • Tag (optional): A label to group this client (e.g., department name)

Install Agent on Rocky Linux / RHEL

Install the required Perl modules:

sudo dnf install -y perl-XML-Simple perl-Compress-Zlib perl-Net-IP perl-Digest-MD5 perl-Data-UUID perl-Net-SSLeay perl-LWP-Protocol-https perl-Proc-Daemon perl-Proc-PID-File dmidecode pciutils nmap net-snmp-perl

Download, build, and install the agent the same way as on Ubuntu:

cd /tmp
wget https://github.com/OCSInventory-NG/UnixAgent/releases/download/v2.10.4/Ocsinventory-Unix-Agent-2.10.4.tar.gz
tar -xzf Ocsinventory-Unix-Agent-2.10.4.tar.gz
cd Ocsinventory-Unix-Agent-2.10.4
sudo perl Makefile.PL
sudo make
sudo make install

Run the agent manually to send the first inventory to the server:

sudo ocsinventory-agent --server=http://your-ocs-server-ip/ocsinventory --force

The agent should report a successful inventory submission. To automate future runs, add a cron job that runs the agent daily:

echo "0 2 * * * root /usr/local/bin/ocsinventory-agent --server=http://your-ocs-server-ip/ocsinventory" | sudo tee /etc/cron.d/ocsinventory-agent

Step 7: Install OCS Inventory Agent on Windows

OCS Inventory provides a native Windows agent (currently version 2.11.0.1) that collects detailed hardware and software data from Windows machines.

Download the Windows agent installer from the OCS Inventory Windows Agent releases page. Get the OCS-Windows-Agent-Setup-x64.exe file for 64-bit systems.

Run the installer and configure the following settings:

  • Server URL: http://your-ocs-server-ip/ocsinventory
  • Server authentication: Leave blank unless you configured HTTP authentication
  • Proxy: Configure if your network requires a proxy
  • Immediately launch inventory: Check this to send the first inventory right after install
  • TAG: Optional label (e.g., department or location)

The Windows agent installs as a service (OCS Inventory Service) and runs at each system startup. It sends inventory data at the interval configured on the server (default is every 24 hours).

For silent deployment across many Windows machines using GPO or SCCM, use the command-line installer:

OCS-Windows-Agent-Setup-x64.exe /S /SERVER=http://your-ocs-server-ip/ocsinventory /NOW

Step 8: Configure Firewall for OCS Inventory

OCS Inventory Server uses standard HTTP/HTTPS ports for communication with agents and for the web console. Open the required ports in your firewall. For more details on firewall management, check our guide on configuring Firewalld on Rocky Linux / RHEL.

On Ubuntu 24.04 (UFW)

Allow HTTP and HTTPS traffic through UFW:

sudo ufw allow 80/tcp
sudo ufw allow 443/tcp
sudo ufw reload

Verify the rules are active:

sudo ufw status

On Rocky Linux 10 (Firewalld)

Open ports using firewalld:

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

Confirm the services are listed in the active zone:

sudo firewall-cmd --list-all

Step 9: OCS Inventory Reports and Plugins

Once agents start reporting in, the OCS Inventory web console provides several useful features for managing your inventory data.

Viewing Inventory Data

Navigate to All Computers in the web console to see every machine that has reported inventory. Click on any computer name to view detailed information including:

  • Hardware summary – CPU, RAM, motherboard, BIOS
  • Storage devices and partitions
  • Network interfaces and IP addresses
  • Installed software with version numbers
  • Running processes and services

Using Search and Groups

OCS Inventory supports advanced search queries to filter machines by hardware specs, installed software, OS version, or any custom field. You can also create dynamic groups based on search criteria – for example, group all machines with less than 4GB RAM or all machines running a specific software version.

Installing Plugins

OCS Inventory has a plugin engine that extends its functionality. Plugins can add custom inventory fields, integrate with third-party tools, or add new report types. To install a plugin:

  • Download the plugin from the OCS Inventory documentation or community repositories
  • Place the plugin files in the /usr/share/ocsinventory-reports/ocsreports/extensions/ directory
  • Activate the plugin from the web console under Extensions > Manage Extensions

The GreenIT plugin is a popular addition that collects energy consumption data from monitored computers.

Conclusion

OCS Inventory Server is now running on your Ubuntu 24.04 or Rocky Linux 10 system, ready to collect hardware and software inventory from your network. With agents deployed on Linux and Windows machines, you get a complete view of every device on your network from a single web console.

For production deployments, enable HTTPS with a valid SSL certificate to encrypt agent-server communication, set up regular database backups using mariadb-dump, and consider placing the OCS server behind a reverse proxy for better security and load handling.

Related Articles

Databases Install MariaDB 11.8 on Ubuntu 24.04|22.04 Ubuntu Install i-doit Asset Management on Ubuntu 22.04|20.04|18.04 Php Install Sentrifugo HRM on Ubuntu 18.04 with Let’s Encrypt SSL Certificate Containers Install Harbor Registry on Ubuntu/Debian/Rocky/Alma

Leave a Comment

Press ESC to close