August 17, 2016

How to install OCS Inventory 2.2.1 on CentOS 6.7

System:
CentOS release 6.7 (Final)
Ip address: 192.168.15.51
SELINUX=disabled

1. Setup CentOS Server
2. Using Script below to setup PHP, MYSQL, PHPMYADMIN,
#!/bin/bash
# ******************************************
# Program: LAMP Stack Installation Script
# Developer: La Dai Hiep
# Date: 17-08-2016
# Last Updated: 17-08-2016
# ******************************************
setenforce 0
yum -y update
yum -y install wget
sudo yum -y install httpd mysql mysql-server mysql-devel php php-mysql php-fpm;
service mysqld start
/usr/bin/mysql_secure_installation
service mysqld restart
wget http://download.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
rpm --import https://fedoraproject.org/static/0608B895.txt
rpm -ivh epel-release-6-8.noarch.rpm
sudo yum -y install php-mbstring php-gd httpd-devel apxs php-mcrypt php-mysql pdo-mysql php-sqlite php-mcrypt php-soap;
sudo yum -y install epel-release rpm-build redhat-rpm-config;
sudo yum -y install mysql-community-release-el7-5.noarch.rpm proj;
sudo yum -y install tinyxml libzip mysql-workbench-community;
sudo chmod 755 -R /var/www/;
sudo printf "<?php\nphpinfo();\n?>" > /var/www/html/info.php;
cd //var/www/html
wget https://files.phpmyadmin.net/phpMyAdmin/4.0.10.15/phpMyAdmin-4.0.10.15-all-languages.zip
echo y | yum install unzip
unzip phpMyAdmin-4.0.10.15-all-languages.zip
rm -rf phpMyAdmin-4.0.10.15-all-languages.zip
mv phpMyAdmin-4.0.10.15-all-languages/ phpmyadmin
sudo service mysqld restart;
sudo service httpd restart;
sudo chkconfig httpd on;
sudo chkconfig mysqld on;

save file .sh, upload to server and run it with command :
# bash lamp.sh or bash -x lamp.sh
2. open EPEL Repository and set enabled=0
vi /etc/yum.repos.d/epel.repo
[epel]
name=Extra Packages for Enterprise Linux 6 - $basearch
#baseurl=http://download.fedoraproject.org/pub/epel/6/$basearch
mirrorlist=http://mirrors.fedoraproject.org/metalink?repo=epel-6&arch=$basearch
failovermethod=priority
enabled=0
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6

[epel-debuginfo]
name=Extra Packages for Enterprise Linux 6 - $basearch - Debug
#baseurl=http://download.fedoraproject.org/pub/epel/6/$basearch/debug
mirrorlist=http://mirrors.fedoraproject.org/metalink?repo=epel-debug-6&arch=$basearch
failovermethod=priority
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6
gpgcheck=1

[epel-source]
name=Extra Packages for Enterprise Linux 6 - $basearch - Source
#baseurl=http://download.fedoraproject.org/pub/epel/6/SRPMS
mirrorlist=http://mirrors.fedoraproject.org/metalink?repo=epel-source-6&arch=$basearch
failovermethod=priority
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6

"/etc/yum.repos.d/epel.repo" 26L, 954C

3.Iptables add ports 80 for Apache & 3306 for MySql
# iptables -I INPUT -m multiport -p tcp --dport 80,3306 -j ACCEPT
# service iptables save
# service iptables restart

or stop iptables service:
#services iptables stop
#chkconfig iptables off

4.Install OCS Inventory pre-requisite packages
yum install -y php php-gd php-mysql php-mbstring mod_perl php-pecl-zip php-common libphp-pclzip libxml-simple-perl libio-compress-perl libdbi-perl libdbd-mysql-perl libapache-dbi-perl libnet-ip-perl libsoap-lite-perl php-gd php5-gd perl-XML-Simple perl-Net-IP perl-SOAP-Lite httpd-devel perl-DBI perl-DBD-MySQL perl-Compress-Zlib perl-Apache-DBI
yum install -y --enablerepo=epel perl-Apache-DBI perl-Apache2-SOAP perl-XML-Entities
if you get error:
[root@ocs opt]# yum install -y --enablerepo=epel perl-Apache-DBI perl-Apache2-SOAP perl-XML-Entities
Loaded plugins: fastestmirror
Setting up Install Process
Loading mirror speeds from cached hostfile
Error: Cannot retrieve metalink for repository: epel. Please verify its path and try again
open vi /etc/yum.repos.d/epel.repo
change https to http and then it start working.
[epel]
name=Extra Packages for Enterprise Linux 6 - $basearch
#baseurl=http://download.fedoraproject.org/pub/epel/6/$basearch
mirrorlist=http://mirrors.fedoraproject.org/metalink?repo=epel-6&arch=$basearch
failovermethod=priority
enabled=0
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6

[epel-debuginfo]
name=Extra Packages for Enterprise Linux 6 - $basearch - Debug
#baseurl=http://download.fedoraproject.org/pub/epel/6/$basearch/debug
mirrorlist=http://mirrors.fedoraproject.org/metalink?repo=epel-debug-6&arch=$basearch
failovermethod=priority
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6
gpgcheck=1

[epel-source]
name=Extra Packages for Enterprise Linux 6 - $basearch - Source
#baseurl=http://download.fedoraproject.org/pub/epel/6/SRPMS
mirrorlist=http://mirrors.fedoraproject.org/metalink?repo=epel-source-6&arch=$basearch
failovermethod=priority
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6
gpgcheck=1
Configure CPAN:
#cpan -i XML::Entities
5. Download and setup OCS Inventory
# cd /var/www/html
wget https://github.com/OCSInventory-NG/OCSInventory-ocsreports/releases/download/2.2.1/OCSNG_UNIX_SERVER-2.2.1.tar.gz
tar –xvzf OCSNG_UNIX_SERVER-2.2.1.tar.gz

# rm -rf OCSNG_UNIX_SERVER-2.2.1.tar.gz
cd OCSNG_UNIX_SERVER-2.2.1
sh 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)? y
Assuming Communication server 1.0 RC2 or previous is not installed
on this computer.

Starting OCS Inventory NG Management server setup from folder /opt/OCSNG_UNIX_SERVER-2.1.2
Storing log in file /opt/OCSNG_UNIX_SERVER-2.1.2/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] ? [hit Enter]
OK, database server is running on host localhost ;-)

On which port is running database server [3306] ? [hit Enter]
OK, database server is running on port 3306 ;-)
+----------------------------------------------------------+
| Checking for Apache web server daemon...                 |
+----------------------------------------------------------+
Where is Apache daemon binary [/usr/sbin/httpd] ? [hit Enter]
OK, using Apache daemon /usr/sbin/httpd ;-)
+----------------------------------------------------------+
| Checking for Apache main configuration file...           |
+----------------------------------------------------------+
Where is Apache main configuration file [/etc/httpd/conf/httpd.conf] ? [hit Enter]
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] ? [hit Enter]
OK, Apache is running under user account apache ;-)
+----------------------------------------------------------+
| Checking for Apache group...                             |
+----------------------------------------------------------+
Which user group is running Apache web server [apache] ? [hit Enter]
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/] ? [hit Enter]
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] ? [hit Enter]
OK, using PERL Intrepreter /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 detailled logs. This logs can be enabled
by setting interger value of LOGLEVEL to 1 in Administration console
menu Configuration.
Where to put Communication server log directory [/var/log/ocsinventory-server] ? [hit 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] ? [hit 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] ? [hit 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 optional Perl Modules...                    |
+----------------------------------------------------------+
Checking for SOAP::Lite PERL module...
Found that PERL module SOAP::Lite is available.
Checking for Apache2::SOAP PERL module...
*** Warning: PERL module Apache2::SOAP is not installed !
This module is only required by OCS Inventory NG SOAP Web Service.
Do you wish to continue ([y]/n] ? y
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) ? 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 sucessfully 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), especialy if you use deployement feature.
Do you wish to continue ([y]/n)? y
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] ? [hit Enter]
OK, using directory /usr/share/ocsinventory-reports to install static files ;-)
Where to create writable/cache directories for deployement packages,
administration console logs, IPDiscover and SNMP [/var/lib/ocsinventory-reports] ? [hit 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 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 /opt/OCSNG_UNIX_SERVER-2.1.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 his content !

DON'T FORGET TO RESTART APACHE DAEMON !
Enjoy OCS Inventory NG 😉

# service httpd restart

6. Perform initial OCS config then login to OCS (Note: It automatically create database ocsweb, with login: ocs,password: ocs)


Mysql login: root
Mysql password: yourpass when setup mysql above
Name of Database: ocsweb
Mysql Hostname: localhost

increase post_max_size and upload_max_filesize in /etc/php.ini

post_max_size = 200M
upload_max_filesize = 200M

if you get error:


OCS-NG Inventory Installation

DB configuration not completed. Automatic install launched

ERROR: can't write in directory (on dbconfig.inc.php), please set the required rights in order to install ocsinventory (you should remove the write mode after the installation is successfull)

# Chmod -R 777  dbconfig.inc.php 

Next:



7. Clear up OCS Inventory security warning


- Delete install.php (or can rename it)
# rm /usr/share/ocsinventory-reports/ocsreports/install.php
- Go to http://192.168.15.51/phpmyadmin
Select Users ocs ==> Edit Privileges

Scroll down Change password field
input the password ==> GO



- Change default admin password
setup-ocs-6
setup-ocs-7
8. Change default MySQL ocs password
- Using phpMyAdmin find user ocs then change the password.
- Change MySQL user ocs password in /usr/share/ocsinventory-reports/ocsreports/dbconfig.inc.php
#
vi /usr/share/ocsinventory-reports/ocsreports/dbconfig.inc.php
<?php
define("DB_NAME", "ocsweb");
define("SERVER_READ","localhost");
define("SERVER_WRITE","localhost");
define("COMPTE_BASE","ocs");
define("PSWD_BASE","newpassword");
?>
- Change MySQL user ocs password in /etc/httpd/conf.d/z-ocsinventory-server.conf
..
# 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 (root)
# Password for user
PerlSetVar OCS_DB_PWD newpassword
..
Repair error below
setup-ocs-8
# chmod -R 777 /usr/share/ocsinventory-reports/ocsreports/plugins/main_sections/conf/old_conf/
# chmod -R 777 /usr/share/ocsinventory-reports/ocsreports/plugins/main_sections/conf/sadmin_config.txt
**Upgrade to new version OCS Inventory NG
At first you must backup your mysql database
#mysqldump -u root -p ocsweb > ocs-database-save.sql
or export database through phpmyadmin
Next you must backup the files /etc/httpd/conf.d/ocsinventory-server.conf and /etc/httpd/conf.d/ocsinventory-reports.conf that you will find in the apache config directory.
after, simply run the setup.sh that you will find in the tar.gz you downloaded on http://www.ocsinventory-ng.org. It will overide the currently installed version. After having install it, go on ocsreports and launch the update procedure for the database.
After update, thinks to change your mysql access credentials in ocsreports and in the server. restore your database and 2 files ocsinventory-server.conf  & ocsinventory-reports.conf 
Setting the Timezone OCS inventory for PHP in the php.ini file

Default timezone PHP Version 5.4.45 is UTC
i'm in Asia so i need to change timezone to Asia/Ho_Chi_Minh

1. Go to  
Loaded Configuration File/opt/remi/php54/root/etc/php.ini
# vi /opt/remi/php54/root/etc/php.ini
2. Jump line:
Replace "US/Central" with the timezone from here that corresponds to the time you want to display.
[Date]
; Defines the default timezone used by the date functions
; http://php.net/date.timezone
date.timezone ="Asia/Ho_Chi_Minh"
3. save and quit
DONE!
References:
http://www.toyaseta.com/setup-ocs-inventory-2-1-2-on-centos-6.html
http://wiki.ocsinventory-ng.org/index.php/Documentation:Server
http://phreek.org/guides/install-ocs-inventory-ng-20-on-centos-6
http://www.vr4servers.com/how-to-install-configure-ocsinventory-2-1-server-on-centos-6-5-64bit/
https://www.howtoforge.com/how-to-install-ocs-inventory-ng-server-2-on-centos-5.5
http://wiki.ocsinventory-ng.org/index.php?title=Howtos:Upgrade_OCS_from_1.3.3_to_2.0.x
http://ask.ocsinventory-ng.org/5/how-upgrade-ocs-inventory-ng
http://www.miloszengel.com/ocs-ng-2-2rc1-server-complete-install-and-configuration-with-ldap/
http://wiki.ocsinventory-ng.org/index.php?title=Documentation:Secure

0 comments:

Post a Comment