Difference between revisions of "Zoneminder(HOW TO)"

From SME Server
Jump to navigationJump to search
 
(60 intermediate revisions by 2 users not shown)
Line 1: Line 1:
{{WIP box}}
+
<blockquote style="float: right;">
 +
[[File:zoneminder.png|250px]]
 +
</blockquote>
 +
{{Box
 +
| content = this is the how to in order to install ZM yourself, you might rather save the trouble by installing the contrib : [[Zoneminder]]
 +
}}
  
 
==About==
 
==About==
Welcome to ZoneMinder.com, home of ZoneMinder the top Linux video camera security and surveillance solution. ZoneMinder is intended for use in single or multi-camera video security applications, including commercial or home CCTV, theft prevention and child, family member or home monitoring and other domestic care scenarios such as nanny cam installations. It supports capture, analysis, recording, and monitoring of video data coming from one or more video or network cameras attached to a Linux system. ZoneMinder also support web and semi-automatic control of Pan/Tilt/Zoom cameras using a variety of protocols. It is suitable for use as a DIY home video security system and for commercial or professional video security and surveillance. It can also be integrated into a home automation system via X.10 or other protocols.
+
[http://zoneminder.com ZoneMinder] is intended for use in single or multi-camera video security applications, including commercial or home CCTV, theft prevention and child, family member or home monitoring and other domestic care scenarios such as nanny cam installations. It supports capture, analysis, recording, and monitoring of video data coming from one or more video or network cameras attached to a Linux system. ZoneMinder also support web and semi-automatic control of Pan/Tilt/Zoom cameras using a variety of protocols. It is suitable for use as a DIY home video security system and for commercial or professional video security and surveillance. It can also be integrated into a home automation system via X.10 or other protocols.
  
 +
This how-to is for IP Camera's only.
 +
 +
This how-to can be discussed on the forums [https://forums.contribs.org/index.php/topic,52163.msg267101.html#msg267101| '''here'''].
  
{{Note box|Zoneminder is available as a contribs, but that is a very old one for SME server 7. Today, Zoneminder has it's own easy repository, and hopefully these instructions can be turned into a new updated contrib.}}
 
 
==Installation==
 
==Installation==
 
====Requirements====
 
====Requirements====
Zoneminder is available from the Zoneminder repository. You need to configure the '''[[zmrepo]]''' as explained [[zmrepo| here]].
+
* Koozali SME Server '''9.x 64-bit'''
 +
* '''PHP 5.6''' is required for a fully functional Zoneminder and its API's installation. Since Koozali SME Server 8.x and 9.x come with a lower version of PHP, one must install the '''[[PHP_Software_Collections|PHP Software Collections]]''' first.
 +
* Zoneminder is available from the Zoneminder repository. You need to configure the '''[[zmrepo]]''' as explained [[zmrepo| here]].
  
 
====Install Zoneminder from the zmrepo====
 
====Install Zoneminder from the zmrepo====
 
  yum install zoneminder --enablerepo=zmrepo
 
  yum install zoneminder --enablerepo=zmrepo
Zoneminder's configuration file is located at /etc/zm.conf. Not really known if it is required, but you can change the Apache user in the zm.conf file from apache:apache to www:www, and double check the database credentials in the same file with the ones you have used.
+
Zoneminder's configuration file is located at /etc/zm.conf. You need to change the Apache user in the zm.conf file from apache:apache to www:www, and double check the database credentials in the same file with the ones you have used.
  
 
====MySQL database====
 
====MySQL database====
Line 23: Line 32:
 
  mysql
 
  mysql
 
  create database '''zm''';
 
  create database '''zm''';
  grant all privileges on '''zm'''.* to '''zmuser''' identified by ''''zmpass'''';
+
  grant all privileges on '''zm'''.* to '''zmuser''' identified by '<nowiki/>'''zmpass'''';
 
  flush privileges;
 
  flush privileges;
 
  exit
 
  exit
Line 30: Line 39:
 
The above bold credentials should be replaced by your own information.
 
The above bold credentials should be replaced by your own information.
  
 +
{{Note box|Once somebody starts creating a contrib, the above credentials should be in a db key e.g. zoneminder and DBUser, DBPass, so the configuration files will be templated and auto generated by an event}}
  
 
====Create custom templates====
 
====Create custom templates====
Line 36: Line 46:
 
  rm -f /etc/httpd/conf.d/zoneminder.conf
 
  rm -f /etc/httpd/conf.d/zoneminder.conf
 
  sed -i "18i AddType application/x-httpd-php .php" /etc/e-smith/templates-custom/etc/httpd/conf/httpd.conf/98zoneminder
 
  sed -i "18i AddType application/x-httpd-php .php" /etc/e-smith/templates-custom/etc/httpd/conf/httpd.conf/98zoneminder
 +
sed -i "19i AuthBasicProvider external" /etc/e-smith/templates-custom/etc/httpd/conf/httpd.conf/98zoneminder
 
  sed --in-place '/DELETE/d' /etc/e-smith/templates-custom/etc/httpd/conf/httpd.conf/98zoneminder
 
  sed --in-place '/DELETE/d' /etc/e-smith/templates-custom/etc/httpd/conf/httpd.conf/98zoneminder
 
  expand-template /etc/httpd/conf/httpd.conf
 
  expand-template /etc/httpd/conf/httpd.conf
 
  service httpd-e-smith restart
 
  service httpd-e-smith restart
 +
{{Note box|Please note that the above templates do not implement any authentication on the Koozali SME Server side to access the Zoneminder portal (webinterface). Options could be specific users (e.g. admin) or all valid SME users. Please read the Koozali SME Server documentation on [[Web_Application_RPM#Apache_Authentication|'''Apache authentication''']]}}
  
 
====Start Zoneminder at boot====
 
====Start Zoneminder at boot====
 
  config set zoneminder service status enabled  
 
  config set zoneminder service status enabled  
  ln -s /etc/rc.d/init.d/e-smith-service /etc/rc7.d/S92zoneminder
+
  ln -s /etc/rc.d/init.d/e-smith-service /etc/rc7.d/S98zoneminder
 
+
The mysqlinit (init-default-databases) process (which starts after the zoneminder service) will have MySQL restarted whilst Zoneminder is actively using it. The Zoneminder service will stop/not start due to this. To prevent Zoneminder to start too quickly we delay the Zoneminder service to start a bit later by adding a sleep command in the script /etc/rc.d/init.d/zoneminder.
 +
sed -i '/^start()/{N;s/$/\nsleep 10/}' /etc/rc.d/init.d/zoneminder
 
You can now start Zoneminder manually:
 
You can now start Zoneminder manually:
 
  service zoneminder start
 
  service zoneminder start
  
 
And access the Zoneminder portal at http://yourserver.com/zm, and login as admin admin
 
And access the Zoneminder portal at http://yourserver.com/zm, and login as admin admin
 +
 +
==Acces Zoneminder via sub domain==
 +
Instead of accessing the Zoneminder portal at http://myserver.com/zm, it is possible to change this to e.g. https://cctv.myserver.com. For this the easiest and comfortable way is to use the webapps-common contrib.
 +
 +
{{Note box|This part assumes you have followed the complete above installation procedure.}}
 +
 +
 +
Install the webapps-common contrib according to the [[Webapps-common|'''how-to''']]. Then (as per example for https://cctv.myserver.com) issue the following as root:
 +
db domains set cctv.myserver.com domain Description "CCTV" Content Primary \
 +
Nameservers internet TemplatePath WebAppVirtualHost \
 +
DocumentRoot /usr/share/zoneminder/www RequireSSL enabled
 +
signal-event domain-create cctv.myserver.com
 +
 +
 +
Next you need to adjust the existing (from above) custom template (make a backup copy first):
 +
sed -i '/Alias/d' /etc/e-smith/templates-custom/etc/httpd/conf/httpd.conf/98zoneminder
 +
Followed by:
 +
signal-event webapps-update
 +
to activate all changes. Now you can reach your zoneminder portal at https://cctv.myserver.com
 +
 +
==Uninstall==
 +
To uninstall Zoneminder and all it's dependencies, we will use the yum history to uninstall all dependencies that came with the initial installation, but are no longer required as we remove Zoneminder. Stop Zoneminder:
 +
service zoneminder stop
 +
 +
First we need to check the yum transaction ID that installed Zoneminder. As root issue:
 +
yum history package-info zoneminder
 +
the result is all yum knows about the Zoneminder package. We are interested in the '''Transaction ID'''.
 +
Next we uninstall Zoneminder and all it's dependencies based on the number of the Transaction ID:
 +
yum history undo '''Transaction ID number'''
 +
and confirm the uninstallation of Zoneminder and all dependencies.
 +
{{Note box|The removal of the Zoneminder RPM will fail due to a dependency on SELinux which SME Server does not use. An additional command is required to uninstall the Zoneminder RPM. To ensure proper removal of all dependencies, only the Zoneminder RPM will be removed without executing the uninstall scripts included in the RPM.}}
 +
yum --setopt=tsflags=noscripts remove zoneminder
 +
Then we need to remove the custom template, the symlink that we created to start Zoneminder at boot and the subdomain that we may have created:
 +
rm -f /etc/e-smith/templates-custom/etc/httpd/conf/httpd.conf/98zoneminder
 +
rm -f /etc/rc7.d/S98zoneminder
 +
signal-event domain-delete cctv.myserver.com
 +
signal-event webapps-update
 +
Now to cleanup everything you may want to perform the usual post-upgrade and reboot events. All that is left is the MySQL database '''zm''' and the logfiles. It's up to you what to do with them.
 +
 +
==ZoneMinder clients==
 +
By default, ZoneMinder can be accessed via the webinterface. There are also 3rd party client applications available.
 +
 +
'''[https://pliablepixels.github.io/ zmNinja]''', a beautiful fast and efficient client application (freely available on [https://github.com/pliablepixels/zmNinja Github]) '''[https://www.youtube.com/watch?v=prtA_mv68Ok&feature=youtu.be DEMO]'''
 +
 +
- Android - [https://play.google.com/store/apps/details?id=com.pliablepixels.zmninja_pro&hl=en Play Store]
 +
 +
- iOS - [https://itunes.apple.com/us/app/zmninja-pro/id1067914954?mt=8 iTunes]
 +
 +
- Mac/Windows/Linux [https://github.com/pliablepixels/zmNinja/releases Github]
 +
 +
[[Category:Howto]]

Latest revision as of 05:46, 13 March 2018

Zoneminder.png

this is the how to in order to install ZM yourself, you might rather save the trouble by installing the contrib : Zoneminder

About

ZoneMinder is intended for use in single or multi-camera video security applications, including commercial or home CCTV, theft prevention and child, family member or home monitoring and other domestic care scenarios such as nanny cam installations. It supports capture, analysis, recording, and monitoring of video data coming from one or more video or network cameras attached to a Linux system. ZoneMinder also support web and semi-automatic control of Pan/Tilt/Zoom cameras using a variety of protocols. It is suitable for use as a DIY home video security system and for commercial or professional video security and surveillance. It can also be integrated into a home automation system via X.10 or other protocols.

This how-to is for IP Camera's only.

This how-to can be discussed on the forums here.

Installation

Requirements

  • Koozali SME Server 9.x 64-bit
  • PHP 5.6 is required for a fully functional Zoneminder and its API's installation. Since Koozali SME Server 8.x and 9.x come with a lower version of PHP, one must install the PHP Software Collections first.
  • Zoneminder is available from the Zoneminder repository. You need to configure the zmrepo as explained here.

Install Zoneminder from the zmrepo

yum install zoneminder --enablerepo=zmrepo

Zoneminder's configuration file is located at /etc/zm.conf. You need to change the Apache user in the zm.conf file from apache:apache to www:www, and double check the database credentials in the same file with the ones you have used.

MySQL database

Zoneminder works 'best' with InnodeDB enabled. As root issue:

db configuration setprop mysqld InnoDB enabled
expand-template /etc/my.cnf
sv t /service/mysqld

Zoneminder uses MySQL for the storage of picture data, so we need to create a new database. As root issue:

mysql
create database zm;
grant all privileges on zm.* to zmuser identified by 'zmpass';
flush privileges;
exit

Then we populate the new database:

mysql zm < /usr/share/zoneminder/db/zm_create.sql

The above bold credentials should be replaced by your own information.


Important.png Note:
Once somebody starts creating a contrib, the above credentials should be in a db key e.g. zoneminder and DBUser, DBPass, so the configuration files will be templated and auto generated by an event


Create custom templates

mkdir -p /etc/e-smith/templates-custom/etc/httpd/conf/httpd.conf/
cp /etc/httpd/conf.d/zoneminder.conf /etc/e-smith/templates-custom/etc/httpd/conf/httpd.conf/98zoneminder
rm -f /etc/httpd/conf.d/zoneminder.conf
sed -i "18i AddType application/x-httpd-php .php" /etc/e-smith/templates-custom/etc/httpd/conf/httpd.conf/98zoneminder
sed -i "19i AuthBasicProvider external" /etc/e-smith/templates-custom/etc/httpd/conf/httpd.conf/98zoneminder 
sed --in-place '/DELETE/d' /etc/e-smith/templates-custom/etc/httpd/conf/httpd.conf/98zoneminder
expand-template /etc/httpd/conf/httpd.conf
service httpd-e-smith restart
Important.png Note:
Please note that the above templates do not implement any authentication on the Koozali SME Server side to access the Zoneminder portal (webinterface). Options could be specific users (e.g. admin) or all valid SME users. Please read the Koozali SME Server documentation on Apache authentication


Start Zoneminder at boot

config set zoneminder service status enabled 
ln -s /etc/rc.d/init.d/e-smith-service /etc/rc7.d/S98zoneminder

The mysqlinit (init-default-databases) process (which starts after the zoneminder service) will have MySQL restarted whilst Zoneminder is actively using it. The Zoneminder service will stop/not start due to this. To prevent Zoneminder to start too quickly we delay the Zoneminder service to start a bit later by adding a sleep command in the script /etc/rc.d/init.d/zoneminder.

sed -i '/^start()/{N;s/$/\nsleep 10/}' /etc/rc.d/init.d/zoneminder

You can now start Zoneminder manually:

service zoneminder start

And access the Zoneminder portal at http://yourserver.com/zm, and login as admin admin

Acces Zoneminder via sub domain

Instead of accessing the Zoneminder portal at http://myserver.com/zm, it is possible to change this to e.g. https://cctv.myserver.com. For this the easiest and comfortable way is to use the webapps-common contrib.


Important.png Note:
This part assumes you have followed the complete above installation procedure.



Install the webapps-common contrib according to the how-to. Then (as per example for https://cctv.myserver.com) issue the following as root:

db domains set cctv.myserver.com domain Description "CCTV" Content Primary \
Nameservers internet TemplatePath WebAppVirtualHost \
DocumentRoot /usr/share/zoneminder/www RequireSSL enabled
signal-event domain-create cctv.myserver.com


Next you need to adjust the existing (from above) custom template (make a backup copy first):

sed -i '/Alias/d' /etc/e-smith/templates-custom/etc/httpd/conf/httpd.conf/98zoneminder

Followed by:

signal-event webapps-update

to activate all changes. Now you can reach your zoneminder portal at https://cctv.myserver.com

Uninstall

To uninstall Zoneminder and all it's dependencies, we will use the yum history to uninstall all dependencies that came with the initial installation, but are no longer required as we remove Zoneminder. Stop Zoneminder:

service zoneminder stop

First we need to check the yum transaction ID that installed Zoneminder. As root issue:

yum history package-info zoneminder

the result is all yum knows about the Zoneminder package. We are interested in the Transaction ID. Next we uninstall Zoneminder and all it's dependencies based on the number of the Transaction ID:

yum history undo Transaction ID number

and confirm the uninstallation of Zoneminder and all dependencies.

Important.png Note:
The removal of the Zoneminder RPM will fail due to a dependency on SELinux which SME Server does not use. An additional command is required to uninstall the Zoneminder RPM. To ensure proper removal of all dependencies, only the Zoneminder RPM will be removed without executing the uninstall scripts included in the RPM.


yum --setopt=tsflags=noscripts remove zoneminder

Then we need to remove the custom template, the symlink that we created to start Zoneminder at boot and the subdomain that we may have created:

rm -f /etc/e-smith/templates-custom/etc/httpd/conf/httpd.conf/98zoneminder
rm -f /etc/rc7.d/S98zoneminder
signal-event domain-delete cctv.myserver.com
signal-event webapps-update

Now to cleanup everything you may want to perform the usual post-upgrade and reboot events. All that is left is the MySQL database zm and the logfiles. It's up to you what to do with them.

ZoneMinder clients

By default, ZoneMinder can be accessed via the webinterface. There are also 3rd party client applications available.

zmNinja, a beautiful fast and efficient client application (freely available on Github) DEMO

- Android - Play Store

- iOS - iTunes

- Mac/Windows/Linux Github