(Last Updated On: June 8, 2018)

OCS – Open Computers and Software Inventory Next Generation is an assets management and deployment solution. It is designed to help you manage your IT assets in a simpler and organized manner.

OCS Inventory NG asks its agents to know the software and hardware composition of every computer or server.  It can also discover network’s elements which can’t receive an agent using IP discovery. It then uses SNMP to complete the data retrieved from the IP Discover scan. This is useful for devices like printers, scanner, routers e.t.c.

Installing OCS Inventory Server on Ubuntu 18.04

Below are the software requirements for installing  OCS Inventory Server on Ubuntu 18.04:

  • MySQL Server – version 4.1 or higher
  • Perl
  • Apache Web server
  • Apache Mod_perl
  • PHP with ZIP support enabled.
  • Apache Mod_php
  • Perl module XML::Simple
  • Perl module Compress::Zlib
  • Perl module DBI
  • Perl module DBD::Mysql
  • Perl module Apache::DBI
  • Perl module Net::IP
  • Perl module Archive::Zip
  • Perl module Apache2:SOAP
  • Perl module SOAP::Lite
  • Perl module XML::Entities

So let’s begin by installing these dependencies.

Step 1: Install MySQL Server, make and gcc

Instead of installing MySQL server, I prefer to install MariaDB. For installation of MariaDB on Ubuntu 18.04, refer to our guide how to Install MariaDB 10.3 on Ubuntu 18.04 and CentOS 7.

To install make and gcc, run:

$ sudo apt-get install make cmake gcc make

Step 2: Install Apache Web server

To install Apache and required modules on Ubuntu 18.04, run the following commands:

$ sudo apt-get install libapache2-mod-perl2 libapache-dbi-perl \
libapache-db-perl libapache2-mod-php

Step 3: Install PHP and php-zip module

We also need to install php and php-zip module. On Ubuntu 18.04, the default version of PHP is 7.2.

$ sudo apt-get install php php-zip \
php-pclzip php-gd php-soap php-curl

Step 4: Install Perl and all required modules

Perl and all its modules can be installed by running the commands below:

$ sudo apt-get install libxml-simple-perl libcompress-zlib-perl \
libdbi-perl libdbd-mysql-perl libnet-ip-perl libsoap-lite-perl
$ sudo cpan -i XML::Entities

Step 5: Create OCS Inventory database

Login to your MariaDB database as root user and create a database for OCS:

$ mysql -u root -p
Enter password: 
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 19258
Server version: 10.3.7-MariaDB-1:10.3.7+maria~bionic-log mariadb.org binary distribution

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> grant all privileges on ocs.* to ocs_user identified by "strongpassword";
Query OK, 0 rows affected (0.000 sec)

MariaDB [(none)]> flush privileges;
Query OK, 0 rows affected (0.001 sec)

Step 6: Install OCS Inventory Server

Clone the project from Github:

# git clone https://github.com/OCSInventory-NG/OCSInventory-Server
Cloning into 'OCSInventory-Server'...
remote: Counting objects: 7297, done.
remote: Compressing objects: 100% (20/20), done.
remote: Total 7297 (delta 8), reused 1 (delta 0), pack-reused 7277
Receiving objects: 100% (7297/7297), 52.57 MiB | 26.65 MiB/s, done.
Resolving deltas: 100% (5173/5173), done.

Change to clone directory.

# cd OCSInventory-Server/
# git clone https://github.com/OCSInventory-NG/OCSInventory-ocsreports.git ocsreports
Cloning into 'ocsreports'...
remote: Counting objects: 26318, done.
remote: Compressing objects: 100% (61/61), done.
remote: Total 26318 (delta 50), reused 50 (delta 27), pack-reused 26230
Receiving objects: 100% (26318/26318), 81.05 MiB | 30.99 MiB/s, done.
Resolving deltas: 100% (16553/16553), done.

Edit setup.sh script to change MySQL credentials:

DB_SERVER_HOST="localhost"
DB_SERVER_PORT="3306"
DB_SERVER_USER="ocs_user"
DB_SERVER_PWD="strongpassword"

If you’re using remote database server, change DB_SERVER_HOST to it. Feel free to modify other changes to your liking and start the installation process my running the script.

# ./setup.sh 

+----------------------------------------------------------+
|                                                          |
|  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/OCSInventory-Server
Storing log in file /root/OCSInventory-Server/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/apache2ctl] ?
OK, using Apache daemon /usr/sbin/apache2ctl 😉


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

Where is Apache main configuration file [/etc/apache2/apache2.conf] ?
OK, using Apache main configuration file /etc/apache2/apache2.conf 😉


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

Which user account is running Apache web server [www-data] ?
OK, Apache is running under user account www-data 😉


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

Which user group is running Apache web server [www-data] ?
OK, Apache is running under users group www-data 😉


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

Setup found Apache Include configuration directory in
/etc/apache2/conf-available.
Setup will put OCS Inventory NG Apache configuration in this directory.
Where is Apache Include configuration directory [/etc/apache2/conf-available] ?
OK, Apache Include configuration directory /etc/apache2/conf-available found 😉


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

Found PERL interpreter at </usr/bin/perl> 😉
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 </usr/bin/make> 😉

+----------------------------------------------------------+
|        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 SOAP::Lite Perl module...
Found that PERL module SOAP::Lite is available.
Checking for Archive::Zip Perl module...
*** ERROR: PERL module Archive::Zip is not installed !
*** ERROR: There is one or more required PERL modules missing on your computer !
Please, install missing PERL modules first.
 
OCS setup.sh can install perl module from packages for you
The script will use the native package from your operating system like apt or rpm
Do you wish to continue (y/[n])?y

If the installation was successful, you should get a message:

+----------------------------------------------------------+
|      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 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/apache2/conf-available/ocsinventory-reports.conf

+----------------------------------------------------------------------+
|        OK, Administration server installation finished 😉           |
|                                                                      |
| Please, review /etc/apache2/conf-available/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/OCSInventory-Server/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 his content !

DON'T FORGET TO RESTART APACHE DAEMON !

Enjoy OCS Inventory NG 😉

Step 7: Configure  OCS Inventory server

When OCS is installed, it generates Apache configuration file for you. You need to enable this by creating alias:

$ sudo ln -s /etc/apache2/conf-available/ocsinventory-reports.conf \
/etc/apache2/conf-enabled/ocsinventory-reports.conf
$ sudo ln -s /etc/apache2/conf-available/z-ocsinventory-server.conf \
/etc/apache2/conf-enabled/z-ocsinventory-server.conf

If you need REST API, also add:

$ sudo ln -s /etc/apache2/conf-available/zz-ocsinventory-restapi.conf \
/etc/apache2/conf-enabled/zz-ocsinventory-restapi.conf

Restart the Apache server

$ sudo chown -R www-data:www-data /var/lib/ocsinventory-reports
$ sudo apachectl -t
Syntax OK
$ sudo systemctl restart apache2

Edit /usr/share/ocsinventory-reports/ocsreports/dbconfig.inc.php and add the name and password for the user created for MySQL. If you had modified setup.sh with correct credentials, they will appear.

<?php
 $_SESSION["SERVEUR_SQL"]="localhost";
 $_SESSION["COMPTE_BASE"]="$user";
 $_SESSION["PSWD_BASE"]="$password";
?>

Open the following URL in your browser, check the information and click Send

http://$server_ip_address/ocsreports/install.php

Provide database credentials as created earlier and click Send.

Click the “Clikc here to enter OCS-NG GUI” link to get dashboard.

Confirm the “Perform the update” message.

For security reasons, move the following to some web-inaccessible location

sudo mv /usr/share/ocsinventory-reports/ocsreports/install.php \
/usr/share/ocsinventory-reports/ocsreports/install.php.bak

To make administrative TAGs updateable by the client edit /etc/apache2/conf.d/z-ocsinventory-server.conf and alter the following directive from 0 to 1

PerlSetEnv OCS_OPT_ACCEPT_TAG_UPDATE_FROM_CLIENT 1

Step 8: Accessing Web interface

After a successful installation, access Web dashboard.

http://$server_ip_address/ocsreports

The default login credentials are:

Username: admin
Password: admin

Change admin password by navigating to settings > My account > Password. 

Provide new password and click on the OK button. From here you can explore OCS Inventory and start feeding data to it.