Home / How To / How to install OCS Inventory Asset Management Software on Ubuntu 20.04 LTS

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 way. OCS allows you to collect hardware and software inventory from all active devices in 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.

conditions

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

Getting Started

First, it is recommended that you 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 on your server. You can install all with the following command:

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

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

Install LAMP Server

First you need to install the Apache web server, MariaDB server, PHP and other necessary PHP extensions on your server. You can install them all 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

After installing all the packages, edit the php.ini file and adjust 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 done.

Install Perl and required modules

OCS inventory also required that Perl and some Perl modules be installed on your server. You can install all 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 the modules, activate 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'

When you are done, you can move on to the next step.

Configure the MariaDB database

Next, you need to create a database and users for OCS inventory. Log in to the MariaDB shell with the following command:

mysql

After logging in, create a database and a user with the following command:

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

Then grant all permissions to ocsdb with the following command:

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

Then flush the privileges and leave the MariaDB shell with the following command:

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

Download and install OCS Inventory

First you 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

After downloading, 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

Then change the directory to reports and install 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

Then 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 done.

Then start the OCS warehouse installation by running the following command:advertisement

./setup.sh

During the installation, you will ask several questions. Answer all the questions 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 must also enable the OCS Inventory virtual host configuration file. You can activate 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

Then 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

Then restart the Apache service to apply the changes:

systemctl restart apache2

Access OCS Inventory

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

database information

Enter your OCS database, database username, password and click Send button. When the installation is complete, you will see the following screen:

OCS OF INSTALLATION

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

OCS loginadvertisement

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

Be sure to change the default login password for the admin user to a secure password. Finally, delete the install.php file to get rid of the warning message on the dashboard.

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

Conclusion

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


Source link