Install OCS Inventory-NG 2.0 on CentOS 6
This guide is based on a fresh install of CentOS 6.2 from the Minimal ISO. It assumes you have already performed basic system configuration steps such as setting up networking, time synchronisation, etc.
-
Install the EPEL repo for some pre-requisites
rpm -ivH http://download.fedoraproject.org/pub/epel/6/i386/epel-release-6-5.noarch.rpm
- Edit '/etc/yum.repos.d/epel.repo' and inside the [epel] stanza, set enabled=0
-
Update the base system
yum update -y
-
Install pre-requisite packages
yum install -y make wget httpd mysql mysql-server php php-gd php-mysql php-mbstring mod_perl perl-XML-Simple perl-Net-IP perl-SOAP-Lite perl-DBI perl-DBD-MySQL yum install -y --enablerepo=epel perl-Apache-DBI perl-Apache2-SOAP perl-XML-Entities
-
Perform the initial MySQL setup
mysql_install_db chkconfig --level 345 mysqld on service mysqld start mysql_secure_installation
- Press Enter for current password
- Type a password for the 'root' user
- Re-enter your new 'root' password
- Y to remove anonymous user
- Y to disallow remote logon
- Y to remove the test database
- Y to reload the privilege tables
- Create the database for OCS. Replace <somepassword> with your own password (Hint: Don't use 'ocs')
mysql -u root -p
CREATE DATABASE ocs; GRANT ALL PRIVILEGES ON ocs.* to ocs@localhost IDENTIFIED BY '<somepassword>'; FLUSH PRIVILEGES; QUIT
-
Install OCS (Based on OCS 2.0.4)
cd ~ wget http://launchpad.net/ocsinventory-server/stable-2.0/2.0.4/+download/OCSNG_UNIX_SERVER-2.0.4.tar.gz tar -xvzf OCSNG_UNIX_SERVER*.tar.gz cd OCSNG_UNIX_SERVER* sh ./setup.sh
- Y to continue
- Enter to accept 'localhost' as MySQL server
- Enter to accept '3306' as MySQL port
- Enter to accept '/usr/sbin/httpd' as Apache binary
- Enter to accept '/etc/httpd/conf/httpd.conf' as Apache config file
- Enter to accept 'apache' as Apache user
- Enter to accept 'apache' as Apache group
- Enter to accept '/etc/httpd/conf.d/' as Apache include directory
- Enter to accept '/usr/bin/perl' as Perl interpreter
- Y to install Communication server
- Enter to accept '/var/log/ocsinventory-server' as log directory
- Y to continue with installation
- Y to rename OCS server config to 'z-ocsinventory-server.conf'
- Y to installation Administration server
- Y to continue
- Enter '/var/www' as location for Administration Server static files location
- Enter '/var/www' as location for Download location
-
Update database settings for OCS Server
- Edit '/etc/httpd/conf.d/z-ocsinventory-server.conf'
- Change line 26 (OCS_DB_NAME) from 'ocsweb' to 'ocs'
- Change line 27 (OCS_DB_LOCAL) from 'ocsweb' to 'ocs'
- Change line 31 (OCS_DB_PWD) from 'ocs' to whatever you chose for your MySQL 'ocs' user password
- Edit '/etc/httpd/conf.d/z-ocsinventory-server.conf'
-
Update IPTables config to allow HTTP on port 80
- Edit '/etc/sysconfig/iptables'
- At line 11 (or just before the final 3 lines) insert
-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT
- At line 11 (or just before the final 3 lines) insert
- Save the file and exit then run
service iptables restart
- Edit '/etc/sysconfig/iptables'
-
Start Apache
chkconfig --level 345 httpd on service httpd start
-
Perform initial OCS config
- Visit http://yourserver/ocsreports
- You will be shown the database configuration page
- Database: ocs
- Username: ocs
- Password: <somepassword>
- Hostname: localhost
- Click submit and wait a few seconds while the database is setup by the installation script
- You will get a page which should show that everything was successful. You will be prompted to enter a string to show an agent the first time it contacts the OCS server. I leave it blank and click submit.
- You will get a page informing you that installation is complete.
- Delete the installation script
rm -f /var/www/ocsreports/install.php
- Visit http://yourserver/ocsreports to login
- Username: admin
- Password: admin
- You should change your 'admin' password after logging in.
- OCS Server installation is complete. You can now begin deploying your agents.
Comments
Zubair
2015-11-12
Its working fine; with some changes made by my self, thanks
Petter
2015-08-13
I had installed the OCS Inventory NG with your article. But when i restarted httpd, it prompt the error at below:
[Thu Aug 13 09:14:22.735283 2015] [perl:error] [pid 31549] Can't locate Apache/Ocsinventory/Plugins.pm in @INC (@INC contains: /usr/local/lib64/perl5 /usr/local/share/perl5 /usr/lib64/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib64/perl5 /usr/share/perl5 . /etc/httpd) at (eval 13) line 2.\n
[Thu Aug 13 09:14:22.735820 2015] [perl:error] [pid 31549] Can't load Perl module Apache::Ocsinventory::Plugins for server localhost:80, exiting...
System Info:
Oper System: CentOS7
Apache: httpd-2.4.6-31.el7
php:php-5.4.16-36.el7_1
Can you help me to solve it?
Thx!
Ilton
2015-07-07
Hi. I´m need help. I instaled OCS in a server CentOs 7 on a Zero based, and this a problem:
+----------------------------------------------------------+
| Checking for required Perl Modules... |
+----------------------------------------------------------+
Checking for DBI PERL module...
Found that PERL module DBI is available.
Checking for Apache::DBI PERL module...
*** ERROR: PERL module Apache::DBI is not installed !
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...
*** ERROR: PERL module Net::IP is not installed !
*** ERROR: There is one or more required PERL modules missing on your computer !
Please, install missing PERL modules first.
OCS setup.sh can install perl module from packages for you
The script will use the native package from your operating system like apt or rpm
Do you wish to continue (y/[n])?y
RedHat based automatic installation
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: centos.brnet.net.br
* centosplus: centos.brnet.net.br
* epel: epel.gtdinternet.com
* extras: centos.brnet.net.br
* rpmforge: apt.sw.be
* updates: centos.brnet.net.br
No packages marked for update
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: centos.brnet.net.br
* centosplus: centos.brnet.net.br
* epel: epel.gtdinternet.com
* extras: centos.brnet.net.br
* rpmforge: apt.sw.be
* updates: centos.brnet.net.br
No package perl-Net-IP available.
Resolving Dependencies
--> Running transaction check
---> Package perl-Apache-DBI.noarch 0:1.09-1.el6 will be installed
--> Processing Dependency: perl(Digest::SHA1) for package: perl-Apache-DBI-1.09-1.el6.noarch
--> Processing Dependency: perl(:MODULE_COMPAT_5.10.1) for package: perl-Apache-DBI-1.09-1.el6.noarch
--> Running transaction check
---> Package perl-Apache-DBI.noarch 0:1.09-1.el6 will be installed
--> Processing Dependency: perl(:MODULE_COMPAT_5.10.1) for package: perl-Apache-DBI-1.09-1.el6.noarch
---> Package perl-Digest-SHA1.x86_64 0:2.13-9.el7 will be installed
--> Finished Dependency Resolution
Error: Package: perl-Apache-DBI-1.09-1.el6.noarch (epel)
Requires: perl(:MODULE_COMPAT_5.10.1)
You could try using --skip-broken to work around the problem
You could try running: rpm -Va --nofiles --nodigest
Installation aborted !
Installation script encounter problems to install packages !
root@localhost:/opt/OCSNG_UNIX_SERVER-2.1.2#
Thank you in advance.
Geoff Hodder
2014-10-14
Try "setenforce 0". Sounds like an SELinux issue which is disabled by that command. If that fixes it run:
sed -i 's/SELINUX=enforcing/SELINUX=permissive/' /etc/sysconfig/selinux
That will disable it permanently. Could also be that Apache is looking in the wrong spot for the OCS web data. From those steps you'll also want to enable the Apache and MariaDB services permanently with:
systemctl enable httpd
systemctl enable mariadb.service
George
2014-10-10
Still pretty accurate.. I'm stuck with the problem that I get a 403 - forbidden on the http://yourserver/ocsreports.
For centos 7:
cd /tmp
wget https://dl.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-2.noarch.rpm
yum install epel-release-7-2.noarch.rpm
yum install mariadb-server mariadb
systemctl start mariadb
mysql_secure_installation
systemctl enable mariadb.service
firewall-cmd --permanent --zone=public --add-port=3306/tcp
firewall-cmd --reload
mysql -u root -p
CREATE DATABASE ocs;
GRANT ALL PRIVILEGES ON ocs.* to ocs@localhost IDENTIFIED BY 'Your-Password';
FLUSH PRIVILEGES;
QUIT
yum install httpd php php-gd php-mysql php-mbstring mod_perl perl-XML-Simple perl-Net-IP perl-SOAP-Lite perl-DBI perl-DBD-MySQL
cd ~
wget https://launchpad.net/ocsinventory-server/stable-2.1/2.1.2/+download/OCSNG_UNIX_SERVER-2.1.2.tar.gz
tar -xvzf OCSNG_UNIX_SERVER-2.1.2.tar.gz
cd OCSNG_UNIX_SERVER-2.1.2
sh ./setup.sh
firewall-cmd --permanent --zone=public --add-service=http
firewall-cmd --reload
systemctl start httpd
Go to website: http://yourserver/ocsreports
Geoff Hodder
2014-08-11
When I get a chance I'll have a look into that error. OCS is now up to 2.1.2 and CentOS is up to 7.0 so I'm expecting some changes are required to the instructions since this guide was written over 2yrs ago.
Aimo
2014-08-09
DB configuration not completed. Automatic install launched
Suejet
2014-05-31
DB configuration not completed. Automatic install launched error
Valentin
2014-04-05
Excelent! Thank you!
ERROR: can't write in directory (on dbconfig.inc.php) DISABLE SELINUX
Nenharma
2014-03-03
Hi,
I change permission of dbconfig.inc.php and disabled selinux too and not work, the message keeps coming:
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)
Marcel
2013-11-17
Hi! Nice guide! I had to disable selinux to finish the installation.
Jose123456
2013-07-29
guiame para configurar ese error amigo , no entiendo esa parte por favor
Geoff Hodder
2013-07-25
See my previous comment about setting the correct permissions on the dbconfig.inc.php file so that the setup script can modify it.
Once you have completed setup, you also need to change the permissions back so that the file can not be modified again.
Jose123456
2013-07-24
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)
ayudacon esto por favor
Anubhav Chauhan
2013-07-11
wow
You are the best guide. Its working perfectly.
Thank you sir
Geoff Hodder
2013-02-02
It sounds like the user your web server runs under is not the same as the owner of your website files.
Based on my example, you would run "chmod 0777 /var/www/ocsreports/dbconfig.inc.php" then go through the setup.
Once you have completed the setup, you should run "chmod 0755 /var/www/ocsreports/dbconfig.inc.php".
Miguel
2013-02-02
hi, please helpme, this problem:
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)
Cleiton Souza
2013-01-22
Thank you! this working fine.
Hyrum A Renderos
2012-06-01
Excellent! your work is the best in all the internet. I don't speak english, then your tutorial is the best in all the languages. It helped me a lot, I was looking everywhere and olny this work perfect.
Thank you very much!
Rene
2012-04-29
Excellent! Thank you very much! I spent two days trying to figure out how to do this using several manuals. Yours is accurate, easy and complete!
Kassiano
2012-03-16
Great! with some changes to my environment worked perfectly.