Install OCS Inventory Server on Debian 12/Debian 11

|
Last Updated:
|
|

In this tutorial, you will learn how to install OCS Inventory Server on Debian 12/Debian 11. OCS (Open Computers and Software Inventory Next Generation) is an opensource assets inventory management solution. It is used to inventory hardware and software details of IT assets either using the OCS Inventory Agent or SNMP polling for assets that the agent cannot be deployed (e.g routers, switches, printers. Inventoried results can be visualized through a web interface.

Installing OCS Inventory Server on Debian 12|11

Install MariaDB Database

A database is required by OCS to store inventory information.

Check the link below to install MariaDB database on Debian;

How to install and setup MariaDB database on Debian

Assuming you have already installed MariaDB, let’s create the database and database users for OCS inventory server.

Be sure to replace the name of the database and database user, and the user password.

mysql -u root -p -e "create database ocsng_db;"
mysql -u root -p -e "create user ocsadmin@localhost identified by 'ChangeME'; \
grant all on ocsng_db.* to ocsadmin@localhost; flush privileges;"

Install PHP and Required Modules

Note that PHP 7.4 is default version available on Debian 11 repositories by default. Use the guide below to install PHP 8 on Debian 11;

Install PHP 8.0/8.1/8.2/8.x on Debian 11

On Debian 12, PHP 8 is available on the default repos. Thus, execute the command below to install PHP and required modules;

apt install php php-pclzip php-mbstring php-soap php-mysql php-curl php-xml php-zip php-gd

Confirm the PHP version installed;

php -v
PHP 8.2.7 (cli) (built: Jun  9 2023 19:37:27) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.2.7, Copyright (c) Zend Technologies
    with Zend OPcache v8.2.7, Copyright (c), by Zend Technologies

Install OCS NG Inventory APT Repository

In order to be able to install the latest and stable release version of OCS Inventory server on Debian, you need to install their APT repository.

NOTE: As much there is no support for Debian 12 on the APT repository, the repos for Debian 11 should still be able to work.

Thus, to install the OCS APT repository on Debian 12/Debian 11;

Install the Repository signing key;

apt install gnupg2 curl wget -y
curl -sS http://deb.ocsinventory-ng.org/pubkey.gpg | \
gpg --dearmor -o /etc/apt/trusted.gpg.d/ocs.gpg

Next, install the repo itself;

echo "deb http://deb.ocsinventory-ng.org/debian/ bullseye main" | \
tee /etc/apt/sources.list.d/ocsinventory.list

Install OCS Inventory Server

The use of the APT repository installed above ensures that some of the package dependencies required to setup OCS inventory server on Debian installed.

Run system package cache update;

apt update

Before you can proceed, install some other required Perl module;

perl -MCPAN -e 'install XML::Entities'

When prompted, enter yes and press ENTER to proceed.

Next, install OCS Inventory server and web console; on Debian;

apt install ocsinventory

Update OCS Inventory DB Connection Settings

Open the Communication Server Apache configuration file and update the database connection details

vim /etc/apache2/conf-available/z-ocsinventory-server.conf

...
<IfModule mod_perl.c>
 
  # Which version of mod_perl we are using
  # For mod_perl <= 1.999_21, replace 2 by 1
  # For mod_perl > 1.999_21, replace 2 by 2
  PerlSetEnv OCS_MODPERL_VERSION 2

  # 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 ocsng_db
  PerlSetEnv OCS_DB_LOCAL ocsng_db
  # User allowed to connect to database
  PerlSetEnv OCS_DB_USER ocsadmin
  # Password for user
  PerlSetVar OCS_DB_PWD ChangeME
  # SSL Configuration
...

Save and exit the configuration file when done.

Next, update the database connection details on the API config;

vim /etc/apache2/conf-available/zz-ocsinventory-restapi.conf

...
<Perl>
  $ENV{PLACK_ENV} = 'production';
  $ENV{MOJO_HOME} = '/usr/share/perl5';
  $ENV{MOJO_MODE} = 'deployment';
  $ENV{OCS_DB_HOST} = 'localhost';
  $ENV{OCS_DB_PORT} = '3306';
  $ENV{OCS_DB_LOCAL} = 'ocsng_db';
  $ENV{OCS_DB_NAME} = 'ocsng_db';
  $ENV{OCS_DB_USER} = 'ocsadmin';
  $ENV{OCS_DB_PWD} = 'ChangeME';
  $ENV{OCS_DB_SSL_ENABLED} = 0;
...

Save and exit the file.

Similarly, update the web console database connection settings;

vim /etc/ocsinventory-reports/dbconfig.inc.php

<?php
 define("DB_NAME", "ocsng_db");
 define("SERVER_READ","localhost");
 define("SERVER_WRITE","localhost");
 define("SERVER_PORT","3306");
 define("COMPTE_BASE","ocsadmin");
 define("PSWD_BASE","ChangeMe");
 define("ENABLE_SSL","");
 define("SSL_MODE","");
 define("SSL_KEY","");
 define("SSL_CERT","");
 define("CA_CERT","");
 ?>

Save the changes and exit the file

Update PHP Settings

Edit the PHP php.ini to optimize certain settings for OSC best suited for your env.

vim /etc/php/*/apache2/php.ini

OCS recommends disabling max_execution_time and max_input_timeby setting the following value:

max_execution_time = -1
max_input_time = -1

These settings define the maximum life time of the script and the time that the script should spend in accepting input.

Adjust file upload limit size:

upload_max_filesize = 50M
post_max_size = 51M

Additionally you can adjust size of memory for php engine.

memory_limit = 256M

Save and exit the file.

Update OCS Configs Owership and Permissions

Set the proper permissions and ownership of OCS configuration files.

chmod -R 766 /usr/share/ocsinventory-reports
chown -R www-data:www-data /usr/share/ocsinventory-reports \
/var/lib/ocsinventory-reports

Disable default Apache site;

a2dissite 000-default.conf

Restart Apache and MariaDB.

systemctl restart apache2 mariadb

Finalize OCS-NG Configuration via Web Interface

If there is a firewall in place, open web ports to allow external access to OCS inventory web console.

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

Configure OCS Inventory database connection details and click Send.

Install OCS Inventory Server on Debian

Installation complete;

Install OCS Inventory Server on Debian

Next, click Click here to enter OCS-NG GUI to proceed.

If prompted to perform database update, please do so and proceed to login page when update is done.

Install OCS Inventory Server on Debian 12/Debian 11

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

OCS Inventory Server Web Dashboard

Use the default credentials:

  • login: admin
  • password: admin
Install OCS Inventory Server on Debian

OCS Inventory server dashboard;

Install OCS Inventory Server on Debian

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 server on Debian 12/Debian 11.

Reference: OCS Inventory Documentation.

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
Kifarunix
Linux Certified Engineer, with a passion for open-source technology and a strong understanding of Linux systems. With experience in system administration, troubleshooting, and automation, I am skilled in maintaining and optimizing Linux infrastructure.

2 thoughts on “Install OCS Inventory Server on Debian 12/Debian 11”

  1. Depois de tudo feito e configurado, reiniciei o servidor debian e o OCS não abriu na web mais
    ———-
    After everything was done and configured, I restarted the debian server and OCS didn’t open on the web anymore

    Reply

Leave a Comment