Ricerca nel sito web

Come installare il software di gestione delle risorse OCS Inventory su Ubuntu 22.04


OCS è un inventario aperto di computer e software di nuova generazione. Aiuta gli amministratori di sistema a gestire le risorse IT in modo più semplice e organizzato. Con OCS puoi raccogliere l'inventario hardware e software da tutti i dispositivi attivi sulla rete, inclusi router, switch, computer, stampanti e molti altri dalla posizione centrale. Può essere installato su molti sistemi operativi come Sun Solaris, IBM AIX, HP-UX, Windows, Linux, macOS e molti altri.

In questo tutorial spiegheremo come installare il server OCS Inventory su Ubuntu 22.04.

Prerequisiti

  • Un server che esegue Ubuntu 22.04.
  • Sul server è configurata una password di root.

Iniziare

Innanzitutto è una buona idea aggiornare tutti i pacchetti di sistema alla versione più recente. Puoi aggiornarli tutti con il seguente comando:

apt-get update -y
apt-get upgrade -y

Una volta aggiornato il tuo server, dovrai installare altre dipendenze richieste nel tuo server. Puoi installarli tutti con il seguente comando:

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

Una volta installati tutti i pacchetti, puoi procedere al passaggio successivo.

Installa il server LAMP

Successivamente, dovrai installare il server web Apache, il server MariaDB, PHP e altre estensioni PHP richieste sul tuo server. Puoi installarli tutti eseguendo il seguente comando:

apt-get install apache2 mariadb-server libapache2-mod-perl2 libapache-dbi-perl libapache-db-perl php libapache2-mod-php php-common php-sqlite3 php-mysql php-gmp php-curl php-mbstring php-gd php-cli php-xml php-zip php-soap php-json php-pclzip composer

Una volta installati tutti i pacchetti, modifica il file php.ini e cambia le impostazioni predefinite:

nano /etc/php/8.1/apache2/php.ini

Modifica le seguenti impostazioni:

memory_limit = 256M
post_max_size = 100M
upload_max_filesize = 100M
max_execution_time = 360
date.timezone = America/Chicago

Salva e chiudi il file quando hai finito.

Installa Perl e i moduli richiesti

Dovrai anche installare Perl e alcuni moduli Perl sul tuo server. Puoi installarli tutti con il seguente comando:

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

Dopo aver installato tutti i moduli, abilitarli con il seguente comando:

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'

Una volta terminato, puoi procedere al passaggio successivo.

Creare un database per OCS

Successivamente, dovrai creare un database e un utente per l'inventario OCS. Innanzitutto, accedi alla shell MariaDB con il seguente comando:

mysql

Una volta effettuato l'accesso, crea un database e un utente con il seguente comando:

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

Successivamente, concedi tutti i privilegi a ocsdb con il seguente comando:

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

Successivamente, svuota i privilegi ed esci dalla shell MariaDB con il seguente comando:

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

Scarica e installa OCS Inventory

Successivamente, dovrai scaricare l'ultima versione di OCS dal repository Git. Puoi scaricarlo con il seguente comando:

git clone https://github.com/OCSInventory-NG/OCSInventory-Server.git

Dovresti vedere il seguente output:

Cloning into 'OCSInventory-Server'...
remote: Enumerating objects: 8628, done.
remote: Counting objects: 100% (755/755), done.
remote: Compressing objects: 100% (307/307), done.
remote: Total 8628 (delta 442), reused 647 (delta 377), pack-reused 7873
Receiving objects: 100% (8628/8628), 52.87 MiB | 31.04 MiB/s, done.
Resolving deltas: 100% (6004/6004), done.

Una volta scaricato, cambia la directory in OCSInventory-Server e scarica il progetto ocsreport con il seguente comando:

cd OCSInventory-Server
git clone https://github.com/OCSInventory-NG/OCSInventory-ocsreports.git ocsreports

Successivamente, modifica la directory in ocsreports e installa il compositore con il seguente comando:

cd ocsreports
curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer

Una volta installato il compositore, dovresti ottenere il seguente output:

All settings correct for using Composer
Downloading...

Composer (version 2.4.4) successfully installed to: /usr/local/bin/composer
Use it: php /usr/local/bin/composer

Successivamente, torna alla directory OCSInventory-Server e modifica il file setup.sh:

cd ..
nano setup.sh

Definisci le impostazioni del tuo database come mostrato di seguito:

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"

Salva e chiudi il file quando hai finito.

Successivamente, avvia l'installazione dell'inventario OCS eseguendo il comando seguente:

./setup.sh

Durante l'installazione ti verranno poste diverse domande. Rispondi a tutte le domande come mostrato di seguito:

+----------------------------------------------------------+
|                                                          |
|  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 ;-)

Abilita inventario OCS per Apache

Successivamente, dovrai anche abilitare il file di configurazione dell'host virtuale Apache OCS Inventory. Puoi abilitarli con il seguente comando:

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

Successivamente, modifica la proprietà della directory OCS inventory-reports in www-data con il seguente comando:

chown -R www-data:www-data /var/lib/ocsinventory-reports

Successivamente, riavvia il servizio Apache per applicare le modifiche:

systemctl restart apache2

Puoi anche controllare lo stato di Apache usando il seguente comando:

systemctl status apache2

Dovresti vedere il seguente output:

? apache2.service - The Apache HTTP Server
     Loaded: loaded (/lib/systemd/system/apache2.service; enabled; vendor preset: enabled)
     Active: active (running) since Fri 2022-11-04 14:52:58 UTC; 6s ago
       Docs: https://httpd.apache.org/docs/2.4/
    Process: 86019 ExecStart=/usr/sbin/apachectl start (code=exited, status=0/SUCCESS)
   Main PID: 86023 (/usr/sbin/apach)
      Tasks: 6 (limit: 4579)
     Memory: 38.9M
        CPU: 815ms
     CGroup: /system.slice/apache2.service
             ??86023 /usr/sbin/apache2 -k start
             ??86024 /usr/sbin/apache2 -k start
             ??86025 /usr/sbin/apache2 -k start
             ??86026 /usr/sbin/apache2 -k start
             ??86027 /usr/sbin/apache2 -k start
             ??86028 /usr/sbin/apache2 -k start

Nov 04 14:52:58 ubuntu2204 systemd[1]: Starting The Apache HTTP Server...

Accedi all'inventario OCS

Ora apri il tuo browser web e digita l'URL http://your-server-ip/ocsreports/install.php. Dovresti vedere la schermata di installazione di OCS Inventory:

Fornisci il tuo database OCS, il nome utente del database, la password e fai clic sul pulsante Invia. Una volta completata con successo l’installazione, dovresti vedere la seguente schermata:

Fare clic su fai clic qui per accedere alla GUI di OCS-NG. Dovresti vedere la schermata di accesso di OCS Inventory come mostrata di seguito:

Fornisci il nome utente e la password predefiniti come admin/admin e fai clic sul pulsante Invia. Dovresti vedere la dashboard di OCS Inventory nella schermata seguente:

Fare attenzione a modificare la password di accesso predefinita dell'utente amministratore con una password sicura. Infine, rimuovi il file install.php per eliminare il messaggio di avviso sulla dashboard.

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

Conclusione

Congratulazioni! Hai installato con successo OCS Inventory sul tuo server Ubuntu 22.04. Ora puoi utilizzare OCS nella tua organizzazione e iniziare a gestire facilmente le tue risorse IT dal browser web. Sentiti libero di chiedermi se hai qualche domanda.

Articoli correlati: