Installation d’OCS-Inventory sur Centos
Version de l’OS: 6.8
Version de OCS: 2.3.1
Pré-requis
Un serveur LAMP opérationnel
Voir l’aricle pour activer / désactiver plusieurs vhost sur Centos
Le serveur Ocs sera sur la même vm que le serveur Glp.
Commençons par installer quelques paquets utiles.
1 |
$ sudo yum install vim git wget |
Il faut ensuite installer perl et ces dépendances
1 |
$ sudo yum install perl-XML-Simple perl-Compress-Zlib perl-DBI perl-DBD-MYSQL perl-Net-IP perl-XML-Entities perl-Apache-DBI perl-Apache2-SOAP perl-SOAP-Lite perl-Archive-Zip mod_perl |
Récupérer le dépôt ocs via git et plaçons le répertoire sur /opt
1 |
$ sudo git clone https://github.com/OCSInventory-NG/OCSInventory-ocsreports.git /opt/ocs |
1 2 3 4 5 6 |
Initialized empty Git repository in /opt/ocs/.git/ remote: Counting objects: 24480, done. remote: Compressing objects: 100% (12/12), done. remote: Total 24480 (delta 2), reused 0 (delta 0), pack-reused 24468 Receiving objects: 100% (24480/24480), 80.27 MiB | 1.18 MiB/s, done. Resolving deltas: 100% (15332/15332), done. |
Créer une db et un user mysql
/!\ Mysql est déjà installé pour glpi.
1 |
$ mysql -u root -p |
1 2 3 4 5 6 |
mysql> CREATE DATABASE <strong>ocs_db</strong> COLLATE UTF8_general_ci; mysql> CREATE USER <strong>ocs_admin</strong> identified by '<strong>mot_de_passe</strong>'; mysql> GRANT ALL PRIVILEGES ON <strong>ocs_db</strong>.* to <strong>ocs_admin</strong>@localhost identified by '<strong>mot_de_passe</strong>'; mysql> quit |
Éditer le fichier php.ini et corriger les valeurs ci dessous par celle affiché
1 |
$ sudo vim /etc/php.ini |
1 2 |
php_value post_max_size 201m php_value upload_max_filesize 200m |
Créer les répertoires sites-available et sites-enabled
1 2 |
$ cd /etc/httpd/ $ sudo mkdir sites-available sites-enabled |
puis ajouter la directive include au fichier httpd.conf
1 |
$ vim conf/httpd.conf |
1 2 3 |
# Load config files from the config directory "/etc/httpd/conf.d". Include sites-enabled/*.conf |
De-commenter la directive NameVirtualHost dans le fichier httpd.conf
1 |
$ sudo vim /etc/httpd/conf/httpd.conf |
1 |
NameVirtualHost *:80 |
Créer les vhosts dans le répertoire sites-available
1 |
$ sudo vim /etc/httpd/sites-available/glpi.domaine.tld.conf |
1 2 3 4 |
<VirtualHost *:80> ServerName glpi.domain.tld DocumentRoot "/opt/glpi" </VirtualHost> |
1 |
$ sudo vim /etc/httpd/sites-available/ocs.domaine.tld.conf |
1 2 3 4 |
<VirtualHost *:80> ServerName ocs.domain.tld DocumentRoot "/opt/ocs" </VirtualHost> |
Pour lister les vhosts, utiliser la commande apachectl
1 |
$ apachectl -S |
Changer le propriétaire d’ocs
1 |
$ sudo chown -R apache:apache /opt/ocs |
Reste plus qu’a redemarrer les services apache et mysql
1 |
$ sudo service restart httpd |
1 |
$ sudo service restart mysqld |
Connecter vous ensuite sur http://ocs.domaine.tld et renseigner les informations mysql
Le compte par défaut est admin / admin
/!\ Penser a supprimer le fichier install.php
1 |
$ sudo rm /opt/ocs/install.php |
/!\ Ancienne version par Wget datant du 18 octobre 2016
Le serveur GLPI étant mis en place précédemment, je vais installer l’instance d’OCS sur la même VM, je récupère ainsi les services LAMP.
Il faut Installer Perl et ces dépendances
1 |
$ sudo yum install perl-XML-Simple perl-Compress-Zlib perl-DBI perl-DBD-MYSQL perl-Net-IP perl-XML-Entities perl-Apache-DBI perl-Apache2-SOAP perl-SOAP-Lite perl-Archive-Zip mod_perl |
Télécharger la source d’OCS-Inventory serveur
1 |
$ wget https://github.com/OCSInventory-NG/OCSInventory-ocsreports/releases/download/2.2.1/OCSNG_UNIX_SERVER-2.2.1.tar.gz |
Dé-zipper
1 |
$ tar xzf OCSNG_UNIX_SERVER-2.2.1.tar.gz |
Lancer le setup.sh
L’installation se fait par défaut a l’exception de 2 points,
l’installation du paquet mod_perl demandera dans la configuration d’OCS de confirmer la version.
L’autre point porte sur le module Apache2::SOAP qui dit qu’il n’est pas installé. continuer ceci n’est pas bloquant, voir faq plus bas pour explications
1 |
$ cd OCSNG_UNIX_SERVER-2.2.1 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
$ sudo ./setup.sh +----------------------------------------------------------+ | | | Welcome to OCS Inventory NG Management server setup ! | | | +----------------------------------------------------------+ Trying to determine whitch 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)? |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
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.2.1 Storing log in file /root/OCSNG_UNIX_SERVER-2.2.1/ocs_server_setup.log +----------------------------------------------------------+ | Checking for database server properties... | +----------------------------------------------------------+ Your MySQL client seems to be part of MySQL version 5.1. Your computer seems to be running MySQL 4.1 or higher, good ;-) Which host is running database server [localhost] ? |
1 2 3 |
OK, database server is running on host localhost ;-) On which port is running database server [3306] ? |
1 2 3 4 5 6 |
OK, database server is running on port 3306 ;-) +----------------------------------------------------------+ | Checking for Apache web server daemon... | +----------------------------------------------------------+ Where is Apache daemon binary [/usr/sbin/httpd] ? |
1 2 3 4 5 6 7 |
OK, using Apache daemon /usr/sbin/httpd ;-) +----------------------------------------------------------+ | Checking for Apache main configuration file... | +----------------------------------------------------------+ Where is Apache main configuration file [/etc/httpd/conf/httpd.conf] ? |
1 2 3 4 5 6 |
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] ? |
1 2 3 4 5 6 7 |
OK, Apache is running under user account apache ;-) +----------------------------------------------------------+ | Checking for Apache group... | +----------------------------------------------------------+ Which user group is running Apache web server [apache] ? |
1 2 3 4 5 6 7 8 9 10 |
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] ? |
1 2 3 4 5 6 7 8 |
OK, Apache Include configuration directory /etc/httpd/conf.d found ;-) +----------------------------------------------------------+ | Checking for PERL Interpreter... | +----------------------------------------------------------+ Found PERL Intrepreter at </usr/bin/perl> ;-) Where is PERL Intrepreter binary [/usr/bin/perl] ? |
1 2 3 |
OK, using PERL Intrepreter /usr/bin/perl ;-) Do you wish to setup Communication server on this computer ([y]/n)? |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
Faire un rpm -q mod_perl pour connaitre sa version <img class="alignnone size-full wp-image-3514" src="http://it.izero.fr/wp-content/uploads/2016/10/ocs11.png" alt="ocs11" width="661" height="350" /> +----------------------------------------------------------+ | 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] ? |
1 2 3 4 5 6 7 8 |
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] ? |
1 2 3 4 5 6 7 8 |
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] ? |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
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 SOAP::Lite Perl module... Found that PERL module SOAP::Lite is available. Checking for Archive::Zip Perl module... Found that PERL module Archive::Zip is available. +----------------------------------------------------------+ | Checking for optional Perl Modules... | +----------------------------------------------------------+ Checking for Apache2::SOAP PERL module... <span style="color: #ff0000;">*** Warning: PERL module Apache2::SOAP is not installed ! This module is only required by OCS Inventory NG SOAP Web Service.</span> Do you wish to continue ([y]/n] ? |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
Checking for XML::Entities PERL module... Found that PERL module XML::Entities is available. +----------------------------------------------------------+ | 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) ? |
1 2 3 4 5 6 7 8 9 10 11 12 13 |
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)? |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
+----------------------------------------------------------+ | 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)? |
1 2 3 4 5 |
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] ? |
1 2 3 4 |
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] ? |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
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 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/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.2.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 his content ! DON'T FORGET TO RESTART APACHE DAEMON ! Enjoy OCS Inventory NG ;-) |
Comme indiqué plus haut le vhost est crée dans /etc/httpd/conf.d/ocsinventory-reports.conf
Pour se connecter a Ocs il faut simplement ouvrir un navigateur et taper http://server//ocsreports. dans mon cas http://glpi.domaine.tld/ocsreports
Il me manque le paquet php-soap, et des droits sur le répertoire ocsreports
pour rappel ma version de PHP est 5.6, voici donc le paquet a installer puis redémarrer apache
1 |
$ sudo yum install php56u-soap-5.6.27-1.ius.centos6.x86_64 |
1 |
$ sudo chown -R apache:apache /usr/share/ocsinventory-reports/ocsreports/ |
1 |
$ sudo service httpd restart |
Il faut fixer les limites minimum des variables post_max_size et upload_max_size
Éditer le vhost ocsinventory-reports.conf et le fichier php.ini
1 2 |
$ sudo vim /etc/httpd/conf.d/ocsinventory-reports.conf $ sudo vim /etc/php.ini |
Modifier les champs
1 2 |
php_value post_max_size 101m php_value upload_max_filesize 100m |
par
1 2 |
php_value post_max_size 201m php_value upload_max_filesize 200m |
Il faut maintenant créer db/user Mysql pour OCS.
Pour rappel, OCS et installé sur mon serveur GLPI, du coup mysql tourne deja avec un couple db/user pour glpi.
1 |
$ mysql -u root -p |
1 2 3 4 5 |
CREATE DATABASE ocs_db COLLATE UTF8_general_ci; CREATE USER 'ocs_admin' identified by 'mot_de_passe'; GRANT ALL PRIVILEGES ON ocs_db.* to 'ocs_admin'@localhost identified by 'mot_de_passe'; |
Si on change la db et le user mysql d’OCS, il faut le remplacer dans le fichier z-ocsinventory-server.conf
“WARNING: If you change default database name (ocsweb) or user (ocs), don’t forget to update the file ‘z-ocsinventory-server.conf’ in your Apache configuration directory”
1 |
$ sudo vim /etc/httpd/conf.d/z-ocsinventory-server.conf |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
# Which version of mod_perl we are using # For mod_perl <= 1.999_21, replace 2 by 1 # For mod_perl > 1.999_21, replace 2 by 2 PerlSetEnv OCS_MODPERL_VERSION 2 # 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 <span style="color: #ff0000;">ocsweb <-- db name a changer</span> PerlSetEnv OCS_DB_LOCAL <span style="color: #ff0000;">locahost </span> # User allowed to connect to database PerlSetEnv OCS_DB_USER <span style="color: #ff0000;">ocs <-- utilisateur a changer</span> # Password for user PerlSetVar OCS_DB_PWD <span style="color: #ff0000;">ocs <-- password a changer</span> |
On finalise l’installation
In progress ..
Completed !
y’a plus qu’a se connecter a et a changer le mot de passe par défaut admin / admin
Bon ben 1er update !
Update completed !
admin / admin
pensez a supprimer le fichier d’install
1 |
$ cd /usr/share/ocsinventory-reports/ocsreports/ |
1 |
$ sudo rm install.php |
Changer le mot de passe Admin
aller dans Config puis Users, sectionner le compte admin et mettre a jour le profil
————————
Next step, integration au LDAP
————————
Ajout dans la GPO pour la remonter auto des machines dans le domaine
FAQ
** Warning: PERL module Apache2::SOAP is not installed !
This module is only required by OCS Inventory NG SOAP Web Service.
—
le module est bien installé mais impossible de zapper cette erreur.
j’ai cherché sur des forums, j’ai même usé de la commande cpan qui me dit que j’ai bien la version 0.73 … c’est une échec ! 😀
Ceci dit la majorité des réponses lus indique le Ce module n’est nécessaire que si il est prévu de requête le serveur OCS via SOAP. Si ce n’est pas le cas l’absence du module générera un message d’erreur dans le fichier error_log d’apache, seulement au démarrage d’apache.