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.
The following information applies to NethServer 7.

ZoneMinder on CentOS 6 (and therefore NethServer 6) has reached end of life, and will not receive updates, though packages are still available on zoneminder repository. Installation instructions for NethServer 6 can be found in old revisions of this document.



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

  • 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

Choose one of the following repositories:

  • Official releases (RPM Fusion Free repo may require dependencies from 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

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

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

Create a new file under /etc/zm/conf.d/ containing the database credentials (changing zmuser and zmpass with the user and password set in the previous step):

cat << 'EOF' >> /etc/zm/conf.d/zm-db-user.conf
ZM_DB_USER = zmuser
ZM_DB_PASS = zmpass
EOF

and set file permissions:

chown root:apache /etc/zm/conf.d/zm-db-user.conf
chmod 640 /etc/zm/conf.d/zm-db-user.conf


7) Adjust the php timezone

ZoneMinder makes use of 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());'


8) Web Server configuration

Inspect /etc/zm/www/zoneminder.httpd.conf and verify it meets your needs. Once done, link it to the web server configuration directory:

ln -sf /etc/zm/www/zoneminder.httpd.conf /etc/httpd/conf.d/

and restart the web-server service:

systemctl restart httpd


9) Enable and Start ZoneMinder Service

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

systemctl stop zoneminder


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

systemctl start zoneminder



Open a web browser and navigate to https://server-address/zm, replacing server-address with your server's FQDN or IP address. At the first access, you might be prompted to accept or decline the privacy policy.



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

Enabling Authentication

Once at ZoneMinder's web interface, go to Options > System section. Enable OPT_USE_AUTH (Authenticate user logins to ZoneMinder), set a random AUTH_HASH_SECRET (Secret for encoding hashed authentication information) and [Save] the changes.

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


Changing Administrator Password

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

Setting admin password

  • Go to Options > Users, 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.


CSRF mitigation

An experimental feature to help mitigate Cross-Site Request Forgery can be enabled from Options > System section: ENABLE_CSRF_MAGIC Enable csrf-magic library


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 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 files to the backup:

echo "/etc/zm/" > /etc/backup-config.d/zoneminder.include


  • zmNinja is a client application that runs on iOS, Android, Windows and Linux. Please see the Demo