OCS Inventory Server is an open-source software. It allows you to scan and inventory all your devices in your IT Department. Once you know everything about your machines, on the hardware and software sides, you can deploy packages to keep your environment safe. Many plugins are available and give high flexibility to fit OCS Inventory to your own system.
OCS Inventory NG uses an agent that launches an inventory on client computers, a management server centralizes the results of inventories. The Web Administration Console allows you to view these inventory results, the detected network hardware, and to create deployment packages
Communications between agents and the management server are performed using the HTTP and HTTPS protocols. All data is formatted as XML and zlib compressed to reduce the network usage. Read more about features of OCS Inventory Server.
In this tutorial, We will learn How to Install and Configure OCS Inventory Server on Ubuntu
Prerequisites:
- LAMP stack installed on your system
- User privileges: root or non-root user with root privileges
Read more:
- How to Install OCS Inventory Agent on Windows
- How to Install OCS Inventory Agent on Ubuntu Debian LinuxMint
- How to Install and Configure LAMP stack on Ubuntu
- How to Install and Configure GLPI on Ubuntu
Step 1 – Update the system
Before we start to install the OCS Inventory server on your system, we need to update the system packages to the latest versions available:
sudo apt update && sudo apt upgrade -y
Step 2 – Install PHP extensions and packages required by OCS Server
Once your server is up-to-date, you will need to install PHP extensions and some dependencies on your server by executing the following command below:
sudo apt install -y git curl wget make cmake gcc make php-mbstring php-xml php-mysql php-zip php-pclzip php-gd php-soap php-curl php-json libapache2-mod-perl2 libapache-dbi-perl libapache-db-perl libapache2-mod-php libarchive-zip-perl mariadb-client
Step 3 – Install and Enable Perl modules
You also need to install Perl and some Perl modules required by the OCS Inventory server:
sudo apt install -y 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
Once the Perl and Perl modules installer has finished, you need to enable them with the following command:
sudo perl -MCPAN -e
'
install Apache2::SOAP'
sudo perl -MCPAN -e
'
install XML::Entities'
sudo perl -MCPAN -e
'
install Net::IP'
sudo perl -MCPAN -e
'
install Apache::DBI'
sudo perl -MCPAN -e
'
install Mojolicious'
sudo perl -MCPAN -e
'
install Switch'
sudo perl -MCPAN -e
'
install Plack::Handler'
Step 4 – Create a database for the OCS Inventory Server
Next, we will create a new database for the OCS Inventory server.
First, log in to the database server:
sudo mysql -uroot -p
Create a new database name called ocs_db
CREATE DATABASE ocs_db;
Create a new database user called ocs_user and set the password is ocs_PWD
CREATE USER ocs_user@localhost IDENTIFIED BY
'
ocs_PWD'
;
Grant all privileges on the ocs_db database to the ocs_user user
GRANT ALL ON ocs_db.* TO ocs_user@localhost;
Reload and exit the database server
FLUSH PRIVILEGES;
EXIT;
Sample output:
Step 5 – Download the OCS Inventory Server latest version
First, go to the download page of the OCS Inventory and click on OCS Inventory Unix/Linux Server button
Enter Name, Country,…email into fields on the pop-up and click Send button:
Next, log in to your email and get the link:
Run the command below to download OCS Inventory
sudo wget Paste_link_to_here
### Example
sudo wget https://github.com/OCSInventory-NG/OCSInventory-ocsreports/releases/download/2.11.1/OCSNG_UNIX_SERVER-2.11.1.tar.gz
Verify downloaded file
ls
Next, unzip the downloaded file
sudo tar -xvf OCSNG_UNIX_SERVER-2.11.1.tar.gz
Verify extracted file
ls
Sample output:
Step 6 – Install the OCS Inventory Server
Go to the OCSNG_UNIX_SERVER-x.y.z
directory
cd OCSNG_UNIX_SERVER-2.11.1/
ls
Open the setup.sh file to re-setup database parameters:
sudo vim setup.sh
Edit lines as below:
### Database User and Database Password created in step 4 DB_SERVER_USER=ocs_user DB_SERVER_PWD=ocs_PWD
Save and close the file when you are done
Sample output:
Then, run the setup.sh script to install OCS Inventory server on your system:
sudo ./setup.sh
During the installation, you will be asked several questions. Press Enter to agree to all options to complete the setup and ensure all Perl checks are successful.
Sample output:
hg@server-1:~/OCSNG_UNIX_SERVER-2.11.1$ hg@server-1:~/OCSNG_UNIX_SERVER-2.11.1$ sudo ./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)? <== Press Enter Assuming Communication server 1.0 RC2 or previous is not installed on this computer. Starting OCS Inventory NG Management server setup from folder /home/hg/OCSNG_UNIX_SERVER-2.11.1 Storing log in file /home/hg/OCSNG_UNIX_SERVER-2.11.1/ocs_server_setup.log +----------------------------------------------------------+ | Checking for database server properties... | +----------------------------------------------------------+ Your MySQL client seems to be part of MySQL version 10.6. Your computer seems to be running MySQL 4.1 or higher, good ;-) Which host is running database server [localhost] ? <== Press Enter OK, database server is running on host localhost ;-) On which port is running database server [3306] ? <== Press Enter OK, database server is running on port 3306 ;-) +----------------------------------------------------------+ | Checking for Apache web server daemon... | +----------------------------------------------------------+ Where is Apache daemon binary [/usr/sbin/apache2ctl] ? <== Press Enter OK, using Apache daemon /usr/sbin/apache2ctl ;-) +----------------------------------------------------------+ | Checking for Apache main configuration file... | +----------------------------------------------------------+ Where is Apache main configuration file [/etc/apache2/apache2.conf] ? <== Press Enter 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] ? <== Press Enter OK, Apache is running under user account www-data ;-) +----------------------------------------------------------+ | Checking for Apache group... | +----------------------------------------------------------+ Which user group is running Apache web server [www-data] ? <== Press Enter 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] ? <== Press Enter 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] ? <== Press Enter OK, using PERL interpreter /usr/bin/perl ;-) Do you wish to setup Communication server on this computer ([y]/n)? <== Press Enter +----------------------------------------------------------+ | 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] ? <== Press Enter 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] ? <== Press Enter 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] ? <== Press Enter 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 Archive::Zip Perl module... Found that PERL module Archive::Zip is available. Do you wish to setup Rest API server on this computer ([y]/n)? <== Press Enter +----------------------------------------------------------+ | Checking for REST API Dependencies ... | +----------------------------------------------------------+ Found that PERL module Mojolicious::Lite is available. Found that PERL module Switch is available. Found that PERL module Plack::Handler is available. +----------------------------------------------------------+ | Configuring REST API Server files ... | +----------------------------------------------------------+ Where do you want the API code to be store [/usr/local/share/perl/5.34.0] ? <== Press Enter Copying files to /usr/local/share/perl/5.34.0 +----------------------------------------------------------+ | Configuring REST API Server configuration files ... | +----------------------------------------------------------+ +----------------------------------------------------------+ | OK, looks good ;-) | | | | Configuring Communication server Perl modules... | +----------------------------------------------------------+ Checking if your kit is complete... Looks good Generating a Unix-style Makefile Writing Makefile for Apache::Ocsinventory Writing MYMETA.yml and MYMETA.json +----------------------------------------------------------+ | OK, looks good ;-) | | | | Preparing Communication server Perl modules... | +----------------------------------------------------------+ +----------------------------------------------------------+ | OK, prepare finshed ;-) | | | | Installing Communication server Perl modules... | +----------------------------------------------------------+ +----------------------------------------------------------+ | OK, Communication server Perl modules install finished;-)| | | | Creating Communication server log directory... | +----------------------------------------------------------+ Creating Communication server log directory /var/log/ocsinventory-server. Fixing Communication server log directory files permissions. Configuring logrotate for Communication server. Removing old communication server logrotate file /etc/logrotate.d/ocsinventory-NG Writing communication server logrotate to file /etc/logrotate.d/ocsinventory-server +----------------------------------------------------------------------+ | OK, Communication server log directory created ;-) | | | | Creating Communication server plugins configuration directory... | +----------------------------------------------------------------------+ Creating Communication server plugins configuration directory /etc/ocsinventory-server/plugins. +----------------------------------------------------------------------+ | OK, Communication server plugins configuration directory created ;-) | | | | Creating Communication server plugins Perl directory... | +----------------------------------------------------------------------+ Creating Communication server plugins Perl directory /etc/ocsinventory-server/perl. +----------------------------------------------------------------------+ | OK, Communication server plugins Perl directory created ;-) | | | | Now configuring Apache web server... | +----------------------------------------------------------------------+ To ensure Apache loads mod_perl before OCS Inventory NG Communication Server, Setup can name Communication Server Apache configuration file 'z-ocsinventory-server.conf' instead of 'ocsinventory-server.conf'. Do you allow Setup renaming Communication Server Apache configuration file to 'z-ocsinventory-server.conf' ([y]/n) ? <== Press Enter OK, using 'z-ocsinventory-server.conf' as Communication Server Apache configuration file Removing old communication server configuration to file /etc/apache2/conf-available/ocsinventory.conf Writing communication server configuration to file /etc/apache2/conf-available/z-ocsinventory-server.conf +----------------------------------------------------------------------+ | 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. | +----------------------------------------------------------------------+ Do you wish to setup Administration Server (Web Administration Console) on this computer ([y]/n)? <== Press Enter +----------------------------------------------------------+ | Checking for Administration Server directories... | +----------------------------------------------------------+ CAUTION: Setup now install files in accordance with Filesystem Hierarchy Standard. So, no file is installed under Apache root document directory (Refer to Apache configuration files to locate it). If you're upgrading from OCS Inventory NG Server 1.01 and previous, YOU MUST REMOVE (or move) directories 'ocsreports' and 'download' from Apache root document directory. If you choose to move directory, YOU MUST MOVE 'download' directory to Administration Server writable/cache directory (by default /var/lib/ocsinventory-reports), especially if you use deployment feature. Do you wish to continue ([y]/n)? <== Press Enter Assuming directories 'ocsreports' and 'download' removed from Apache root document directory. Where to copy Administration Server static files for PHP Web Console [/usr/share/ocsinventory-reports] ? <== Press Enter OK, using directory /usr/share/ocsinventory-reports to install static files ;-) Where to create writable/cache directories for deployment packages, administration console logs, IPDiscover and SNMP [/var/lib/ocsinventory-reports] ? <== Press Enter OK, writable/cache directory is /var/lib/ocsinventory-reports ;-) +----------------------------------------------------------+ | Checking for required Perl Modules... | +----------------------------------------------------------+ Checking for DBI PERL module... Found that PERL module DBI is available. Checking for DBD::mysql PERL module... Found that PERL module DBD::mysql 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. +----------------------------------------------------------+ | 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 temporary files directory /var/lib/ocsinventory-reports/tmp_dir. Fixing permissions on directory /var/lib/ocsinventory-reports/tmp_dir. 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 /home/hg/OCSNG_UNIX_SERVER-2.11.1/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 ;-) hg@server-1:~/OCSNG_UNIX_SERVER-2.11.1$
If OK, you should see a similar result below:
Step 7 – Configure OCS Inventory Server
At this point, OCS Inventory Server was installed, it auto-generates Apache configuration files, you need to enable them with the following command below:
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
sudo ln -s /etc/apache2/conf-available/zz-ocsinventory-restapi.conf /etc/apache2/conf-enabled/zz-ocsinventory-restapi.conf
Sample output:
Next, go to the /etc/apache2/conf-enabled/
directory
cd /etc/apache2/conf-enabled/
ls
Sample output:
Open the z-ocsinventory-server.conf
file
sudo vim z-ocsinventory-server.conf
Edit database parameters as below:
### Database Name, database user, database password created in step 4 PerlSetEnv OCS_DB_NAME ocs_db PerlSetEnv OCS_DB_LOCAL ocs_db PerlSetEnv OCS_DB_USER ocs_user PerlSetVar OCS_DB_PWD ocs_PWD
Save and close the file when you are done
Sample output:
Also open the zz-ocsinventory-restapi.conf
file
sudo vim zz-ocsinventory-restapi.conf
And edit database parameters as below:
### Database Name, database user, database password created in step 4 $ENV{OCS_DB_LOCAL} = 'ocs_db'; $ENV{OCS_DB_USER} = 'ocs_user'; $ENV{OCS_DB_PWD} = 'ocs_PWD';
Save and close the file when you are done
Sample output:
Next, change the Ownership of the ocsinventory-reports
directory to www-data
user:
sudo chown -R www-data:www-data /var/lib/ocsinventory-reports
Then, restart the Apache service to apply the changes:
sudo systemctl restart apache2
Step 8 – Setup OCS Inventory Server
Open your browse and access address http://IP-Server/ocsreports/install.php .You should see the page OCS Inventory installation below. And you need to provide the database parameters created in step 4 then click Send button
Once the installation has finished, you should see the page below. And click on the Click here to enter OCS-NG GUI
Click on the Perform the update button:
After update done, click on the Click here to enter OCS-NG GUI button:
You will be redirected to the login page. Login with default credentials as:
- Username: admin
- Password: admin
then click the Send button
You should see the OCS Inventory dashboard below:
You should see two warnings for security:
First, you need to change the default password by navigating to settings > My account > Password and entering your password.
Second, you need to remove the install.php file in the /usr/share/ocsinventory-reports/ocsreports
directory by the following:
Go to the /usr/share/ocsinventory-reports/ocsreports
directory and rename install.php to install.php.bak then restart the Apache service to apply the change:
cd /usr/share/ocsinventory-reports/ocsreport
ls
sudo mv install.php install.php.bak
sudo systemctl restart apache2
Sample output:
That’s it. You have successfully installed OCS Inventory Server on the Ubuntu system.
Thank you for reading !!!
Video
How to Install and Configure OCS Inventory Server on Ubuntu
thank you very much !!! Excellent post!!! professional!
Thank you !!!