In this tutorial, you will learn how to install and setup OCS NG Inventory Server on CentOS 7. OCS (Open Computers and Software Inventory Next Generation) is an opensource assets inventory management solution. It is used to inventor hardware and software details of IT assets either using the OCS Inventory Agent or SNMP polling for assets that the agent cannot be deployed (e.g routers, switches, printers. Inventoried results can be visualized through a web interface.
Install and Setup OCS NG Inventory Server on CentOS 7
Run System Update
Before installing OCS Inventory server, a list of required packages have to be installed as stated from the prerequisites page on OCS wikis.
To begin with, update the system
yum update -y
Install Additional Required Repositories
Install additional EPEL repository, additional tools and enable PHP 7.2 Remi repository
yum install epel-release yum-utils wget vim -y
yum install http://rpms.remirepo.net/enterprise/remi-release-7.rpm -y
yum-config-manager --enable remi-php7.2
Install and Setup LAMP Stack
OCS Administration console is a web application hence it requires the LAMP/LEMP Stack. In this tutorial we will install the LAMP Stack.Thus, install LAMP stack as follows;
yum install httpd -y
Start and Enable Apache services.
systemctl enable --now httpd
Allow Apache external access on firewalld
firewall-cmd --permanent --add-service=http
firewall-cmd --reload
Install and Configure MariaDB Database Server
yum install mariadb mariadb-server mariadb-client -y
Start and enable MariaDB service.
systemctl enable --now mariadb
Run MySQL initial security script and set root user password:
mysql_secure_installation
Enter current password for root (enter for none):
OK, successfully used password, moving on...
...
Set root password? [Y/n] y
New password:
Re-enter new password:
Password updated successfully!
Reloading privilege tables..
... Success!
...
Remove anonymous users? [Y/n] y
... Success!
...
Disallow root login remotely? [Y/n] y
... Success!
...
Remove test database and access to it? [Y/n] y
- Dropping test database...
... Success!
- Removing privileges on test database...
... Success!
...
Reload privilege tables now? [Y/n] y
... Success!
Cleaning up...
Login to database as root user and create OCS-NG user and database and assign all rights on OCS-NG database to the user.
For demonstration purposes, will be using default ocs configarations i.e
DB_NAME: ocsweb
DB_User: ocs
DB_Password: ocs
NOTE: Change these values in a production environment for security purposes.
Replace the names of the database with the one set for your environment.
mysql -u root -p
create database ocsweb;
CREATE USER 'ocs'@'localhost' IDENTIFIED BY 'ocs';
GRANT ALL PRIVILEGES ON ocsweb. * TO 'ocs'@'localhost' IDENTIFIED BY 'ocs';
flush privileges;
exit;
Install OCS communication server required PERL modules.
yum install perl-XML-Simple perl-Compress-Zlib perl-DBI perl-DBD-MySQL perl-Net-IP perl-SOAP-Lite perl-Archive-Zip perl-Mojolicious perl-Plack perl-XML-Entities perl-Switch mod_perl -y
Install Apache DBI package which is not available on official and Epel repository
wget http://rpm.ocsinventory-ng.org/enterprise/7/x86_64/perl-Apache-DBI-1.12-2.el7.ocs.noarch.rpm
yum install ./perl-Apache-DBI-1.12-2.el7.ocs.noarch.rpm -y
Install Administration console required PHP modules
Since Apache Web server is already installed, proceed and install install php 7.2, PHP Zip support and dependacies
yum install php php-pecl-zip perl-XML-Simple perl-DBI perl-DBD-MySQL perl-Net-IP php-mbstring php-gd php-mysqlnd php-xml -y
Install OCS NG Management Server
Proceed to download OCS NG server tarball “OCSNG_UNIX_SERVER-2.4.x.tar.gz” from OCS Inventory website (at the time of writing 2.9.2).
wget https://github.com/OCSInventory-NG/OCSInventory-ocsreports/releases/download/2.9.2/OCSNG_UNIX_SERVER-2.9.2.tar.gz
Extract the contents of the tarball.
tar xzf OCSNG_UNIX_SERVER-2.9.2.tar.gz
Install OCS-NG Inventory server by running the setup script:
cd OCSNG_UNIX_SERVER-2.9.2
sh setup.sh
Follow through the prompts to install OCS-NG inventory accordingly. Press ENTER to accept the defaults.
+----------------------------------------------------------+
| |
| 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/OCSNG_UNIX_SERVER-2.9.2
Storing log in file /root/OCSNG_UNIX_SERVER-2.9.2/ocs_server_setup.log
+----------------------------------------------------------+
| Checking for database server properties... |
+----------------------------------------------------------+
Your MySQL client seems to be part of MySQL version 5.5.
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/httpd] ?
OK, using Apache daemon /usr/sbin/httpd ;-)
+----------------------------------------------------------+
| Checking for Apache main configuration file... |
+----------------------------------------------------------+
Where is Apache main configuration file
[/etc/httpd/conf/httpd.conf] ?
OK, using Apache main configuration file /etc/httpd/conf/httpd.conf ;-)
+----------------------------------------------------------+
| Checking for Apache user account... |
+----------------------------------------------------------+
Which user account is running Apache web server [apache] ?
OK, Apache is running under user account apache ;-)
+----------------------------------------------------------+
| Checking for Apache group... |
+----------------------------------------------------------+
Which user group is running Apache web server [apache] ?
OK, Apache is running under users group apache ;-)
+----------------------------------------------------------+
| Checking for Apache Include configuration directory... |
+----------------------------------------------------------+
Setup found Apache Include configuration directory in
/etc/httpd/conf.d.
Setup will put OCS Inventory NG Apache configuration in this directory.
Where is Apache Include configuration directory [/etc/httpd/conf.d] ?
OK, Apache Include configuration directory /etc/httpd/conf.d 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 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)?
+----------------------------------------------------------+
| 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/lib64/perl5/vendor_perl] ?
+----------------------------------------------------------+
| OK, looks good ;-) |
| |
| Configuring Communication server Perl modules... |
+----------------------------------------------------------+
Checking if your kit is complete...
Looks good
Writing Makefile for Apache::Ocsinventory
+----------------------------------------------------------+
| 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) ?y
OK, using 'z-ocsinventory-server.conf' as Communication Server Apache configuration file
Removing old communication server configuration to file /etc/httpd/conf.d/ocsinventory.conf
Writing communication server configuration to file /etc/httpd/conf.d/z-ocsinventory-server.conf
+----------------------------------------------------------------------+
| OK, Communication server setup successfully finished ;-) |
| |
| Please, review /etc/httpd/conf.d/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)?y
+----------------------------------------------------------+
| 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)?
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] ?
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] ?
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.
Writing Administration server configuration to file /etc/httpd/conf.d/ocsinventory-reports.conf
+----------------------------------------------------------------------+
| OK, Administration server installation finished ;-) |
| |
| Please, review /etc/httpd/conf.d/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/OCSNG_UNIX_SERVER-2.9.2/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 ;-)
For any installation issues, you can check on the log file, ./OCSNG_UNIX_SERVER_2.9/ocs_server_setup.log.
Confirm/configure DB settings on:
vim /etc/httpd/conf.d/z-ocsinventory-server.conf
configs
...
# Master Database settings
# Replace localhost by hostname or ip of MySQL server for WRITE
PerlSetEnv OCS_DB_HOST localhost
# Replace 3306 by port where running MySQL server, generally 3306
PerlSetEnv OCS_DB_PORT 3306
# Name of database
PerlSetEnv OCS_DB_NAME ocsweb
PerlSetEnv OCS_DB_LOCAL ocsweb
# User allowed to connect to database
PerlSetEnv OCS_DB_USER ocs
# Password for user
PerlSetVar OCS_DB_PWD ocs
...
_
vim /etc/httpd/conf.d/zz-ocsinventory-restapi.conf
Define the database configs;
… $ENV{OCS_DB_HOST} = ‘localhost’; $ENV{OCS_DB_PORT} = ‘3306’; $ENV{OCS_DB_LOCAL} = ‘ocsweb’; $ENV{OCS_DB_USER} = ‘ocs’; $ENV{OCS_DB_PWD} = ‘ocs’; …vim /usr/share/ocsinventory-reports/ocsreports/dbconfig.inc.php
Database configs
...
<?php
$_SESSION["SERVEUR_SQL"]="localhost";
$_SESSION["COMPTE_BASE"]="ocsweb";
$_SESSION["PSWD_BASE"]="ocs";
?>
Save and exit the configs file after making the changes.
Set the proper permissions and ownership of OCS configuration files.
chmod -R 766 /usr/share/ocsinventory-reports
chown -R apache:apache /usr/share/ocsinventory-reports
chown -R apache:apache /var/lib/ocsinventory-reports
Set SELinux permissions on web server configuration files.
chcon -R -t httpd_sys_rw_content_t /usr/share/ocsinventory-reports
Edit the PHP php.ini
to optimize certain settings for OSC best suited for your env.
OCS recommends disabling max_execution_time
and max_input_time
by setting the following value:
vim /etc/php.ini
max_execution_time = -1
max_input_time = -1
These settings define the maximum life time of the script and the time that the script should spend in accepting input.
Adjust file upload limit size:
upload_max_filesize = 50M
post_max_size = 51M
Additionally you can adjust size of memory for php engine.
memory_limit = 256M
Restart Apache and MariaDB.
systemctl restart httpd mariadb
Finalize OCS-NG Configuration via Web Interface
Navigate to http://server-hostname-or-IP/ocsreports
on your browser to access OCS.
Configure OCS Inventory database connection details and click Send.
You might get a warning message about file upload size depending on the size limit set on php.ini file. This can be ignored or increase the size if you will be uploading packages greater than 100MB as stated in the warning message.
Next, click Click here to enter OCS-NG GUI to login to OCS web interface.
Use the default credentials:
- login: admin
- password: admin
If prompted to run a database update, click update and proceed to OCS login interface.
Reset the password: Settings gear > My account > Password.
Remove the installation script.
mv /usr/share/ocsinventory-reports/ocsreports/install.php /usr/share/ocsinventory-reports/ocsreports/install.php.old
That marks the end of our guide on how to install and setup OCS NG Inventory server on CentOS 7.
Reference: OCS Inventory Documentation.
Perfeito! funcionou perfeitamente! Muito obrigado!
Perfect! worked perfectly! Thank you very much!
Glad it helped! Enjoy
thanks for sharing, recognized!