How to Install OCS Asset Management Tool on Debian 10
OCS stands for "Open Computers and Software Inventory" is a free and open-source assets management solution. It is based on the client-server model that collects the hardware and software information of remote systems running the OCS agent. OCS uses SNMP protocol to discover network devices such as, printers, scanners, routers and computers. It comes with a simple and user-friendly interface that allows you to visualize the inventory through a web interface. You must install the OCS client on the client machine to collect detailed information. OCS client agents are available for several operating systems, including Windows, Linux, Mac OS, IBM AIX, FreeBSD, Android, and Sun Solaris.
This tutorial will show you how to install the OCS Asset Management Tool on a Debian 10 server.
Prerequisites
- A server running Debian 10 with minimu 2GB RAM.
- A root password is configured on the server.
Getting Started
Before starting, updating your system with the latest version is a good idea. You can update your system with the following command:
apt-get update -y
apt-get upgrade -y
After updating the system, restart it to implement the changes.
Next, you will need to install some dependencies required by OCS in your system. You can install them with the following command:
apt-get install git curl make cmake gcc make build-essential -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 webserver, MariaDB database server, PHP and other PHP extensions in your system. You can install all of htem by just running the following command:
apt-get install apache2 mariadb-server php libapache-db-perl libapache2-mod-php php-soap php-curl php-json php-xml php-mbstring php-zip php-pclzip php-gd php-mysql -y
After installing all the packages, you will also need to install Perl and required modules in your system.
Run the following command to install Perl and all the modules:
apt-get install perl libnet-ip-perl libxml-simple-perl libarchive-zip-perl libxml-simple-perl libcompress-zlib-perl libdbi-perl libapache-dbi-perl libapache2-mod-perl2 libapache2-mod-perl2-dev libdbd-mysql-perl libdbd-mysql-perl libnet-ip-perl libsoap-lite-perl libio-compress-perl -y
Once all the packages are installed, run the following command to enable Perl modules:
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 will need to edit php.ini file and modify some settings like, timezone, memory limit, upload maximum file size, max execution time, etc.
You can do it with the following command:
nano /etc/php/7.3/apache2/php.ini
Change the following values:
memory_limit = 256M upload_max_filesize = 100M max_execution_time = 360 date.timezone = Asia/Kolkata
Save and close the file when you are finished. Then, restart the Apache service to implement the changes:
systemctl restart apache2
Note: You can change the above PHP value as per your requirements.
At this point, the LAMP server is installed. You can now proceed to the next step.
Configure MariaDB Database
By default, the MariaDB root password is not configured in Debian 10. So you will need to set it for security reasons.
First, log in to the MariaDB shell with the following command:
mysql
After login, set the MariaDB root user password with the following command:
MariaDB [(none)]> SET PASSWORD FOR 'root'@'localhost' = PASSWORD("yournewpassword");
Next, create a database and user for OCS with the following command:
MariaDB [(none)]> CREATE DATABASE ocs;
MariaDB [(none)]> GRANT ALL PRIVILEGES ON ocs.* TO ocs@localhost IDENTIFIED BY "password";
Next, flush the privileges and exit from the MariaDB shell with the following command:
MariaDB [(none)]> FLUSH PRIVILEGES;
MariaDB [(none)]> EXIT;
After configuring the MariaDB database, you can proceed to the next step.
Install OCS Server
First, you will need to download the latest version of OCE Server from the Git repository. You can download it using the git command as shown below:
git clone https://github.com/OCSInventory-NG/OCSInventory-Server.git
You should see the following output:
Cloning into 'OCSInventory-Server'... remote: Enumerating objects: 80, done. remote: Counting objects: 100% (80/80), done. remote: Compressing objects: 100% (57/57), done. remote: Total 7563 (delta 28), reused 45 (delta 16), pack-reused 7483 Receiving objects: 100% (7563/7563), 52.63 MiB | 32.78 MiB/s, done. Resolving deltas: 100% (5348/5348), done.
Once the download is completed, change the directory to the OCSInventory-Server and download the ocsreport project from the Git repository with the following command:
cd OCSInventory-Server
git clone https://github.com/OCSInventory-NG/OCSInventory-ocsreports.git ocsreports
Next, change the directory to the ocsreports with the following command:
cd ocsreports
Next, install the Composer package to install the PHP dependencies required for OCS server:
curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
Once the installationis completed, you should see the following output:
All settings correct for using Composer Downloading... Composer (version 1.9.2) successfully installed to: /usr/local/bin/composer Use it: php /usr/local/bin/composer
Next, install all the required PHP dependencies with the following command:
composer install
Once all the dependencies are installed, change the directory to the OCSInventory-Server and edit setup.sh file:
cd ..
nano setup.sh
Define your database settings as shown below:
DB_SERVER_HOST="localhost" DB_SERVER_PORT="3306" DB_SERVER_USER="ocs" DB_SERVER_PWD="password"
Save and close the file when you are finished. Then, run the setup.sh script to start the installation:
./setup.sh
Durring the installation, you will be asked for several questions, select default settings and type y for all questions. Once the installation has been completed successfully. You should see the following output:
+----------------------------------------------------------------------+ | OK, Communication server setup successfully finished ;-) | | | | Please, review /etc/apache2/conf-available/z-ocsinventory-server.conf | | to ensure all is good. Then restart Apache daemon. | +----------------------------------------------------------------------+ +----------------------------------------------------------------------+ | 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 ;-)
At this point, the OCS server is installed. You can now proceed to the next step.
Configure OCS Server
After installing the OCS server, you will need to enable OCS server configuration files for Apache. 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, set proper permissions to the OCS server directory with the following command:
chown -R www-data:www-data /var/lib/ocsinventory-reports
chmod -R 775 /var/lib/ocsinventory-reports
Finally, restart the Apache service to apply the changes with the following command:
systemctl restart apache2
At this point, the OCS server is installed and configured. It's time to access its web interface.
Access OCS Server Web Interface
Open your web browser and type the URL http://your-server-ip/ocsreports/install.php. You will be redirected to the following page:
Now, provide your OCS database name, database username, password and click on the Send button. You should see the following page:
Next, click on the "Click here to enter OCS-NG GUI" link. You should see the following page:
Click on the Perform the update button to update the database. Once the update has been completed, you should see the following page:
Now, click on the "Click here to enter OCS-NG GUI" link. You will be redirected to the OCS login page as shown below:
Provide the default username and password as admin/admin and click on the Send button. You will be redirected to the OCS dashboard as shown below:
Next, it is recommended that the installation file be removed for security reasons. You can remove it with the following command:
rm -rf /usr/share/ocsinventory-reports/ocsreports/install.php
Conclusion
Congratulations! you have successfully installed and configured the OCS server on Debian 10. You can now explore the OCS dashboard and start managing your IT infrastructure inventory. Feel free to ask me if you have any questions.