ZoneMinder

ZoneMinder is an integrated set of applications which provide a complete surveillance solution allowing capture, analysis, recording and monitoring of any CCTV or security cameras.

Notice that according to ZoneMinder documentation it may not play well on a system that is running Asterisk.
Please be advised that ZoneMinder developers do not recommend using CentOS 6 for new ZoneMinder installations. Remember, NethServer 6 is based on CentOS 6.



1) Install Prerequisites
The prerequisites can be installed from NethServer Software Center, or from the command line.

  • For NethServer 6
    • MySQL server module
    • Web server module
  • For NethServer 7
    • MariaDB (MySQL) server module
    • nethserver-httpd (installed already)

To install them from the command line:

yum install nethserver-mysql nethserver-httpd


2) Repository for ZoneMinder

Note the package version for zmrepo may change over time. Check https://zmrepo.zoneminder.com/ for the latest.

  • For NethServer 6
yum install http://zmrepo.zoneminder.com/el/6/x86_64/zmrepo-6-7.el6.noarch.rpm
  • For NethServer 7

Choose one of the following repositories:

  • Official releases (RPM Fusion Free repo, depends on EPEL repo):
yum install https://download1.rpmfusion.org/free/el/rpmfusion-free-release-7.noarch.rpm
  • Nightly builds (zmrepo):
yum install http://zmrepo.zoneminder.com/el/7/x86_64/zmrepo-7-9.el7.centos.noarch.rpm

Changing from zmrepo to RPM Fusion (NethServer 7)
ZoneMinder moved official releases to RPM Fusion, letting zmrepo for nightly builds. To change from zmrepo to RPM Fusion, issue the following command after enabling RPM Fusion repository:

yum remove zmrepo


3) Install ZoneMinder

yum install zoneminder


4) Disable Repository for ZoneMinder (Optional)
There are multiple methods to accomplish this, here is one of them:

yum install yum-utils    # provides the yum-config-manager utility
yum-config-manager --disable zmrepo
yum-config-manager --disable rpmfusion-free-updates

In the future, to update ZoneMinder upon request:

yum update --enablerepo=zmrepo
yum update --enablerepo=rpmfusion-free-updates

If you need to upgrade ZoneMinder, first read its documentation.


5) Create and Configure ZoneMinder Database
Replace zmuser and zmpass with the desired credentials for the database account.

mysql < /usr/share/zoneminder/db/zm_create.sql
mysql -e "grant all on zm.* to 'zmuser'@localhost identified by 'zmpass';"
mysqladmin reload


6) Edit ZoneMinder Configuration File

  • For NethServer 6
    Edit /etc/zm.conf changing ZM_DB_USER and ZM_DB_PASS with the user and password set in the previous step.
  • For NethServer 7
    Edit /etc/zm/zm.conf changing ZM_DB_USER and ZM_DB_PASS with the user and password set in the previous step.


7) Adjust the php timezone

ZoneMinder uses internally the timezone set in php (for instance to show the date of logged events). To check the current php timezone set by NethServer use the command:

config getprop php DateTimezone

If the returned value differs from your timezone, you can adjust it to your needs (see List of supported timezones):

config setprop php DateTimezone Europe/Rome
signal-event nethserver-php-update

Where Europe/Rome should be replaced with your timezone.

To verify the new timezone is seen by php:

php -r 'print_r(date_default_timezone_get());'

Restart the web-server service for the php changes to be recognized:

service httpd restart	# for NethServer 6
systemctl restart httpd	# for NethServer 7

Note you may obviate the web-server restart if already required by a later step.


8) Enable and Start ZoneMinder Service

  • For NethServer 6
service zoneminder start
service httpd restart
  • For NethServer 7
systemctl enable --now zoneminder


FIXME If ZoneMinder service fails to start (due to mariadb.service dependency), reboot the system. For more information and possible workarounds check:



FIXME

Recordings can take lots of disk space. To prevent them from filling up the disk ZoneMinder has a PurgeWhenFull filter.
Do note that ZoneMinder events and images can be moved, for instance, to a dedicated hard drive or partition by using bind mounts.

Check the References section for additional information and options.

Example:

  • Current location: /var/lib/zoneminder/
  • New desired location: /home/zoneminder (where /home is an existing partition and is already mounted)

The steps to accomplish this are as follows:

Stop ZoneMinder

service zoneminder stop    #For NethServer 6
systemctl stop zoneminder  #For NethServer 7


Prepare the new location

mkdir -p /home/zoneminder/{events,images}


Preserve data
If you wish to preserve your recorded events and images, move them to the new location:

mv /var/lib/zoneminder/events/* /home/zoneminder/events/
mv /var/lib/zoneminder/images/* /home/zoneminder/images/


Correct permissions
Ensure ZoneMinder can write to the new location by setting the right permissions:

chown -R apache:apache /home/zoneminder/


Create the bind mounts
Add the new bind mounts to /etc/fstab so they are automatically remounted at boot time:

/home/zoneminder/events /var/lib/zoneminder/events none defaults,bind 0 2
/home/zoneminder/images /var/lib/zoneminder/images none defaults,bind 0 2

Use mount -a command to apply the mount-points without rebooting.


Start ZoneMinder

service zoneminder start    #For NethServer 6
systemctl start zoneminder  #For NethServer 7



Open a web browser and navigate to https://server-address/zm, replacing server-address with your server's FQDN or IP address.



Here are some basic security considerations, by no means complete.

Enabling Authentication

Once at ZoneMinder's web interface, consider enabling authentication right away.

  • Click on the Options link on the top right corner
  • Access the System tab
  • Enable OPT_USE_AUTH (Authenticate user logins to ZoneMinder)
  • Set a random AUTH_HASH_SECRET (Secret for encoding hashed authentication information)
  • [Save] the changes

    Zoneminder Authentication Options

The next time you access ZoneMinder you will be presented a login screen. Use admin as default user and password.


Changing Admininstrator Password

The default username and password is admin. It is recommended to set a new password as soon as possible.

Setting admin password

  • Click on the Options link on the top right corner
  • On the Users tab, click on the admin username, set a password and [Save] the changes.

If you want to delete the default admin user, make sure you have created another fully privileged user to take over the same role.


Telemetry data

You can enable/disable collection of usage information of the local system to be shared with ZoneMinder development team.

To do so, access Options > System, and set TELEMETRY_DATA value at will.



Changing the default look of the web interface

  • Go to Options > System and set CSS_DEFAULT to flat, for instance. You may have to clear browser cache for the changes to be displayed.

Changing default language

  • Go to Options > System and set LANG_DEFAULT

For additional configuration options refer to ZoneMinder documentation.

If you will be using NethServer's Backup module, consider including ZoneMinder configuration file to the backup:

  • For NethServer 6
echo "/etc/zm.conf" > /etc/backup-config.d/zoneminder.include
  • For NethServer 7
echo "/etc/zm/zm.conf" > /etc/backup-config.d/zoneminder.include