How to install OCS inventory asset management software CentOS 8
OCS “Next Generation Open Computer and Software Inventory” is an open source asset management solution that can be used to inventory IT assets. It works by collecting the hardware and software information of the remote computer running the OCS client program and visualizing the inventory through a web interface. It uses SNMP protocol to collect information from network printers, switches, computers, etc.
In this tutorial, we will explain how to install OCS inventory on CentOS 8 server.
- Server running CentOS 8.
- A valid domain name pointing to the server IP. In this tutorial, we will use the ocs.example.com domain.
- The root password is configured for the server.
Before starting, you will need to install the EPLE and REMI repositories on the server. You can install both by running the following command:
dnf install https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpmdnf install https://rpms.remirepo.net/enterprise/remi-release-8.rpm
After installing the two packages, you also need to install the dnf-utils package and enable the PowerTools repository. You can do this by running the following command:
dnf install dnf-utils -ydnf config-manager --set-enabled PowerTools
After installing the two packages, you can proceed to the next step.
Install Apache, MariaDB and PHP
OCS runs on a web server, uses MariaDB as the database backend, and is written in PHP. Therefore, you will need to install Apache web server, MariaDB database server, PHP and other required PHP extensions on the server.
First, install Apache and MariaDB server using the following commands:
dnf install httpd mariadb-server -y
After installing the two packages, you will need to install PHP version 7.3 on the server. By default, PHP 7.3 is not available in the CentOS default repository. Therefore, you will need to enable the REMI repository and install PHP 7.3 from the REMI repository.
First, enable the REMI PHP repository by running the following command:
yum-config-manager --enable remi
Next, reset the default PHP module and enable the REMI PHP 7.3 module by running the following command:
dnf module reset phpdnf module install php:remi-7.3
After enabling the PHP 7.3 module, you can install PHP 7.3 and other required extensions by running the following command:
dnf install php php-curl php-zip php-gd php-soap php-xml php-mbstring php-fpm mod_perl unzip curl -y
After installing all the packages, you will need to edit the php.ini file and make some required changes. You can edit it with the following command:
Change the following values according to your requirements:
upload_max_filesize = 10M post_max_size = 10M max_execution_time = 300 max_input_time = 300 memory_limit = 256M
Save and close the file when you are done, then start Apache, MariaDB and PHP-FPM services and use the following command to start them when the system reboots:
systemctl start httpdsystemctl start php-fpmsystemctl start mariadbsystemctl enable httpdsystemctl enable php-fpmsystemctl enable mariadb
Once completed, you can proceed to the next step.
Configure MariaDB database
By default, MariaDB root password is not set in CentOS 8. Therefore, you need to set it first. You also need to ensure the safety of MariaDB installation. You can set it up by running the following command:
The system will ask you to set MariaDB super user password, delete anonymous users, prohibit remote super user login, remote test database and reload privileges, as shown below:
Enter current password for root (enter for none): OK, successfully used password, moving on... Set root password? [Y/n] Y Remove anonymous users? [Y/n] Y Disallow root login remotely? [Y/n] Y Remove test database and access to it? [Y/n] Y Reload privilege tables now? [Y/n] Y
After setting the MariaDB root password, use the following command to log in to the MariaDB shell:
mysql -u root -p
Provide your root password when prompted, and then use the following commands to create the database and user:
MariaDB [(none)]> CREATE DATABASE ocsweb;MariaDB [(none)]> GRANT ALL PRIVILEGES ON ocsweb.* TO [email protected] IDENTIFIED BY "password";
Next, use the following command to refresh the privileges and exit from MariaDB shell:
MariaDB [(none)]> FLUSH PRIVILEGES;MariaDB [(none)]> EXIT;
At this point, MariaDB has been protected and a database has been configured for OCS. Now you can proceed to the next step.
Install OCS checklist
By default, the OCS package is not available in the CentOS 8 default repository. Therefore, you will need to install the OCS repo in your system. You can use the following command to install:
dnf install https://rpm.ocsinventory-ng.org/ocsinventory-release-latest.el8.ocs.noarch.rpm -y
Once the OCS repository is installed, use the following command to install OCS:
dnf install ocsinventory -y
After installing OCS, you will need to import the OCS database. You can import it with the following command:
mysql -u root -p ocsweb < /usr/share/ocsinventory-reports/ocsreports/files/ocsbase.sql
You will be asked to provide your MariaDB root password to import the database.
Next, you will need to enable the rewrite module for Apache. You can enable it by editing the file /etc/httpd/conf/httpd.conf:
Add the following line at the end of the file:
LoadModule rewrite_module modules/mod_rewrite.so
Save and close the file when you are done, then restart the Apache service to apply the configuration changes.
systemctl restart httpd
Now, you can use the following command to verify the status of the Apache service:
systemctl status httpd
You should get the following output:
? httpd.service - The Apache HTTP Server Loaded: loaded (/usr/lib/systemd/system/httpd.service; disabled; vendor preset: disabled) Drop-In: /usr/lib/systemd/system/httpd.service.d ??php-fpm.conf Active: active (running) since Tue 2020-10-27 04:40:05 EDT; 6min ago Docs: man:httpd.service(8) Main PID: 10742 (/usr/sbin/httpd) Status: "Total requests: 150; Idle/Busy workers 100/0;Requests/sec: 0.386; Bytes served/sec: 11KB/sec" Tasks: 278 (limit: 12523) Memory: 150.2M CGroup: /system.slice/httpd.service ??10742 /usr/sbin/httpd -DFOREGROUND ??10744 /usr/sbin/httpd -DFOREGROUND ??10745 /usr/sbin/httpd -DFOREGROUND ??10746 /usr/sbin/httpd -DFOREGROUND ??10747 /usr/sbin/httpd -DFOREGROUND ??10959 /usr/sbin/httpd -DFOREGROUND Oct 27 04:40:05 centos8 systemd: Starting The Apache HTTP Server...
At this point, the OCS inventory has been installed and configured in the server. Now you can proceed to the next step.
Configure Selinux and firewall
By default, SELinux is enabled in CentOS 8. Therefore, you need to configure it for OCS inventory.
You can configure SELinux with the following command:
setsebool httpd_can_network_connect on -Pchcon -R -t httpd_sys_rw_content_t /usr/share/ocsinventory-reports
Next, use the following command to allow ports 80 and 443 through the firewall:
firewall-cmd --permanent --add-service=http
firewall-cmd --permanent --add-service=httpsfirewall-cmd --reload
Once completed, you can proceed to the next step.
Access OCS List Web UI
Now, open your web browser and use the URL to access the OCS web interface http: //your-server-ip/ocsreports/install.php. You will be redirected to the following screen:
Provide your MariaDB database connection details and click send Button. You should see the following screen:
Now, click Click here to enter OCS-NG GUI. The system will ask you to perform a database update as follows:
Click on carried out of Update Button. After the database is updated, you will see the following screen:
Click on Click here to enter OCS-NG GUI. You will be redirected to the OCS login screen:
Provide the default username as admin and password as admin, then click send Button. You should see the OCS dashboard in the following screen:
Click on All computers menu. You should see the following screen:
Next, it is recommended to delete the installation script. You can delete it with the following command:
rm -rf /usr/share/ocsinventory-reports/ocsreports/install.php
Congratulations! You have successfully installed and configured OCS inventory server on CentOS 8. You can now install the OCS inventory agent on the remote computer and start collecting software and hardware information. If you have any questions, please feel free to ask me.