How To Install OCS Inventory Asset Management Software on Ubuntu 20.04 LTS

OCS Inventory also known as "Open Computers and Software Inventory Next Generation" is a free asset management platform. It is used to manage your IT assets in a simpler and organized manner. OCS allows you to collect hardware and software inventory from all active devices on the network including, routers, switches, computers, printers and many more. It also supports many operating systems including, Sun Solaris, IBM AIX, HP-UX, Windows, Linux, MacOS and many more.

OCS Inventory is the best tool for you if you are looking for an IT hardware inventory system for your business.

In this tutorial, we will explain how to install the OCS Inventory server on Ubuntu 20.04.

Prerequisites

  • A server running Ubuntu 20.04.
  • A root password is configured on the server.

Getting Started

First, it is recommended to update your server to the latest version. You can update it with the following command:

apt-get update -y

Once your server is up-to-date, you will need to install some dependencies in your server. You can install all of them with the following command:

apt-get install make cmake gcc make git curl unzip -y

Once all the packages are installed, you can proceed to the next step.

Install LAMP Server

First, you will need to install the Apache web server, MariaDB server, PHP, and other required PHP extensions in your server. You can install all of them by running the following command:

apt-get install apache2 mariadb-server libapache2-mod-perl2 libapache-dbi-perl libapache-db-perl php7.4 libapache2-mod-php7.4 php7.4-common php7.4-sqlite3 php7.4-mysql php7.4-gmp php7.4-curl php7.4-mbstring php7.4-gd php7.4-cli php7.4-xml php7.4-zip php7.4-soap php7.4-json php-pclzip composer

Once all the packages are installed, edit the php.ini file and tweak some recommended settings:

nano /etc/php/7.4/apache2/php.ini

Change the following settings:

memory_limit = 256M
post_max_size = 100M
upload_max_filesize = 100M
max_execution_time = 360
date.timezone = America/Chicago

Save and close the file when you are finished.

Install Perl and Required Modules

OCS inventory also required Perl and some Perl modules to be installed in your server. You can install all of them with the following command:

apt-get install perl libxml-simple-perl libcompress-zlib-perl libdbi-perl libdbd-mysql-perl libnet-ip-perl libsoap-lite-perl libio-compress-perl libapache-dbi-perl libapache2-mod-perl2 libapache2-mod-perl2-dev -y

After installing all modules, enable them with the following command:

perl -MCPAN -e 'install Apache2::SOAP'
perl -MCPAN -e 'install XML::Entities'
perl -MCPAN -e 'install Net::IP'
perl -MCPAN -e 'install Apache::DBI'
perl -MCPAN -e 'install Mojolicious'
perl -MCPAN -e 'install Switch'
perl -MCPAN -e 'install Plack::Handler'

Once you are finished, you can proceed to the next step.

Configure MariaDB Database

Next, you will need to create a database and user for OCS inventory. First, log in to the MariaDB shell with the following command:

mysql

Once login, create a database and user with the following command:

MariaDB [(none)]> CREATE DATABASE ocsdb;
MariaDB [(none)]> CREATE USER 'ocsuser'@'localhost' IDENTIFIED BY 'password';

Next, grant all the privileges to the ocsdb with the following command:

MariaDB [(none)]> GRANT ALL ON ocsdb.* TO 'ocsuser'@'localhost' WITH GRANT OPTION;

Next, flush the privileges and exit from the MariaDB shell with the following command:

MariaDB [(none)]> FLUSH PRIVILEGES;
MariaDB [(none)]> EXIT;

Download and Install OCS Inventory

First, you will need to download the latest version of OCS from the Git repository. You can download it with the following command:

git clone https://github.com/OCSInventory-NG/OCSInventory-Server.git

Once downloaded, change the directory to OCSInventory-Server and download the ocsreport project with the following command:

cd OCSInventory-Server
git clone https://github.com/OCSInventory-NG/OCSInventory-ocsreports.git ocsreports

Next, change the directory to ocsreports and install the Composer with the following command:

cd ocsreports
curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer

Once the Composer is installed, you should get the following output:

All settings correct for using Composer
Downloading...

Composer (version 1.10.10) successfully installed to: /usr/local/bin/composer
Use it: php /usr/local/bin/composer

Next, go back to the OCSInventory-Server directory and edit the setup.sh file:

cd ..
nano setup.sh

Define your database settings as shown below:

# Which host run database server
DB_SERVER_HOST="localhost"
# On which port run database server
DB_SERVER_PORT="3306"
# Database server credentials
DB_SERVER_USER="ocsuser"
DB_SERVER_PWD="password"

Save and close the file when you are finished.

Next, start the OCS inventory installation by running the following command:

./setup.sh

During the installation, you will be asked several questions. Answer all questions as shown below:

+----------------------------------------------------------+
|                                                          |
|  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  ;-)
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

+----------------------------------------------------------------------+
|        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 its content !

DON'T FORGET TO RESTART APACHE DAEMON !

Enjoy OCS Inventory NG ;-)

Enable OCS Inventory

Next, you will also need to enable the OCS Inventory virtual host configuration file. You can enable them with the following command:

ln -s /etc/apache2/conf-available/ocsinventory-reports.conf /etc/apache2/conf-enabled/ocsinventory-reports.conf
ln -s /etc/apache2/conf-available/z-ocsinventory-server.conf /etc/apache2/conf-enabled/z-ocsinventory-server.conf
ln -s /etc/apache2/conf-available/zz-ocsinventory-restapi.conf /etc/apache2/conf-enabled/zz-ocsinventory-restapi.conf

Next, change the ownership of the ocsinventory-reports directory to www-data with the following command:

chown -R www-data:www-data /var/lib/ocsinventory-reports

Next, restart the Apache service to apply the changes:

systemctl restart apache2

Access OCS Inventory

Now, open your web browser and type the URL http://your-server-ip/ocsreports/install.php. You should see the OCS Inventory installation screen:

Database details

Provide your OCS database, database username, password, and click on the Send button. Once the installation has been completed successfully, you should see the following screen:

OCS NG Installation

Click on the click here to enter OCS-NG GUI. You should see the OCS Inventory login screen as shown below:

OCS Login

Provide default username and password as admin / admin and click on the Send button. You should see the OCS Inventory dashboard in the following screen:

Take care to change the default login password of the admin user to a secure password. Finally, remove the install.php file to get rid of the alert message on the dashboard.

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

Conclusion

Congratulations! you have successfully installed OCS Inventory on Ubuntu 20.04. You can now manage your IT assets easily from the web browser. Feel free to ask me if you have any questions.

Share this page:

Suggested articles

0 Comment(s)

Add comment