NOTE:

This installs the forked NEO version of ZMES MLAPI and PYZM. If you want the original version you can follow most of this up to the point of cloning the ‘baudneo’ repos. Instead follow the original installation docs to install the original ZMES, MLAPI, PYZM.

First, make sure that the timezone is set on your Ubuntu host -> sudo timedatectl set-timezone America/Chicago

* replace America/Chicago with your timezone!

Set up your user to be able to use sudo -u www-data <command> without using a password.

sudoedit /etc/sudoers# Find the line%sudo   ALL=(ALL:ALL) ALL
# Add this below it
%my_group ALL=(www-data:www-data) NOPASSWD: ALL# Change my_group to your users group, if your user is named jeff and the usernames group is pepe ->
%pepe ALL=(www-data:www-data) NOPASSWD: ALL
# All users in group 'pepe' can now run any command as www-data through sudo without using a password.
# If you want your user to never put in passwords for any sudo command as any user ->
%my_group ALL=(ALL:ALL) NOPASSWD: ALL

At the time of writing, the stable branch of ZoneMinder is the 1.36 branch. The current release is 1.36.9 (hirsuite1), to find the repo and add it, do a google search for ‘zoneminder ppa 1.36’. It should bring you to this page which has instructions to add the repo to Ubuntu. You can double-check to make sure or substitute 1.36 for a newer stable branch if you are reading this in the future.

sudo add-apt-repository ppa:iconnor/zoneminder-1.36
sudo apt-get update

Once you add the repo you can install ZoneMinder ->

sudo apt-get install zoneminder

The install does most of the hard work for us, but, there is some setup that needs to be done before ZM will run correctly, if at all. Set up the SQL database and enable some of the apache2 modules before enabling zoneminder as a systems service and starting it.

These commands assume you are using a NON ROOT user that has access to sudo.# This will create the main ZM DBsudo mysql -u root -p ''< /usr/share/zoneminder/db/zm_create.sql 2>/dev/null# Give user: 'zmuser' using password: 'zmpass'  ALL privs
# zmuser MUST HAVE its password set to zmpass
sudo mysql -e "ALTER USER 'zmuser'@localhost IDENTIFIED BY 'zmpass';"sudo mysql -e "GRANT ALL PRIVILEGES ON zm.* TO 'zmuser'@'localhost' WITH GRANT OPTION;"sudo mysql -e "FLUSH PRIVILEGES ;"# Configuring Zonemindersudo chmod 740 /etc/zm/zm.confsudo chown root:www-data /etc/zm/zm.confsudo adduser www-data videosudo a2enmod cgi rewrite headers expires sslsudo a2enconf zonemindersudo systemctl restart apache2.service# Starting Zonemindersudo systemctl enable zonemindersudo systemctl start zoneminder

If for some reason you get an error from apache when you issue sudo a2enconf zoneminder

You can go to the ZoneMinder GitHub and find the apache2 zoneminder.conf file, copy its contents and create a .conf file in /etc/apache2/sites-enabled/

sudo nano /etc/apache2/sites-enabled/zoneminder.conf# These are the contents of the zoneminder.conf file for ZM 1.36.8# Remember to enable cgi mod (i.e. "a2enmod cgi").
ScriptAlias /zm/cgi-bin "/usr/lib/zoneminder/cgi-bin"
<Directory "/usr/lib/zoneminder/cgi-bin">
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
AllowOverride All
Require all granted
</Directory>
# Order matters. This alias must come first.
Alias /zm/cache /var/cache/zoneminder/cache
<Directory /var/cache/zoneminder/cache>
Options -Indexes +FollowSymLinks
AllowOverride None
<IfModule mod_authz_core.c>
# Apache 2.4
Require all granted
</IfModule>
</Directory>
Alias /zm /usr/share/zoneminder/www
<Directory /usr/share/zoneminder/www>
Options -Indexes +FollowSymLinks
<IfModule mod_dir.c>
DirectoryIndex index.php
</IfModule>
</Directory>
# For better visibility, the following directives have been migrated from the
# default .htaccess files included with the CakePHP project.
# Parameters not set here are inherited from the parent directive above.
<Directory "/usr/share/zoneminder/www/api">
RewriteEngine on
RewriteRule ^$ app/webroot/ [L]
RewriteRule (.*) app/webroot/$1 [L]
RewriteBase /zm/api
</Directory>
<Directory "/usr/share/zoneminder/www/api/app">
RewriteEngine on
RewriteRule ^$ webroot/ [L]
RewriteRule (.*) webroot/$1 [L]
RewriteBase /zm/api
</Directory>
<Directory "/usr/share/zoneminder/www/api/app/webroot">
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
RewriteBase /zm/api
</Directory>

Then restart apache -> sudo systemctl restart apache2.service

Then restart ZM just to be safe -> sudo systemctl restart zoneminder.service

Now you should be able to access the ZM web GUI, if you are using a browser on the same system that ZM is installed on you can go to http://localhost/zm

Otherwise goto http://<the ip address of the ZM host system>/zm

If you do not add the /zm to the URL you will only see the default apache page ->

Default apache webpage * Notice the URL is missing the /zm

Alright! ZoneMinder 1.36.x is now installed. There may be a weird bug where the very first page you see when opening HTTP://<ZM IP>/zm keeps re-opening and never letting you get to the ZM web GUI. This page is an analytics page asking if it's alright to collect and transfer some data. If this happens you need to go back to where the ZM MySQL DB tables were created and re-create the tables with an additional command added to the SQL file.

# Open the file /usr/share/zoneminder/db/zm_create.sql
sudo nano /usr/share/zoneminder/db/zm_create.sql
# Search for the following text: CREATE TABLE Sessions
# ctrl+w to search through the file in nano: around line 1089
# On the line above this text, add this line of code: DROP TABLE IF EXISTS Sessions; and save the file. It should look similar to this ->DROP TABLE IF EXISTS Sessions;
CREATE TABLE Sessions (
id char(32) not null,
access INT(10) UNSIGNED DEFAULT NULL,
...................................
# Run the script again, using MySQL:sudo mysql --verbose -uroot -p "" < /usr/share/zoneminder/db/zm_create.sql# Re run these tasks ->
# Give user: 'zmuser' using password: 'zmpass' ALL privs
# zmuser MUST HAVE its password set to zmpass
sudo mysql -e "ALTER USER 'zmuser'@localhost IDENTIFIED BY 'zmpass';"sudo mysql -e "GRANT ALL PRIVILEGES ON zm.* TO 'zmuser'@'localhost' WITH GRANT OPTION;"sudo mysql -e "FLUSH PRIVILEGES ;"sudo systemctl restart zoneminder.service
sudo systemctl restart apache2.service
# Check the web gui now, things should work as expected.

The first things to do here are to set the timezone for the ZM server (MySQL DB timezone) in Options->System.

ZM timezone option

Now we need to prep for the neo-ZMES install (neo-zmeventnotificationserver, neo-mlapi, neo-pyzm). For now, follow the docs from the original install on dependencies. I will walk you through it here now anyway but just in case, here are the original docs.

# First install some build tools
sudo apt-get install make cmake autoconf automake g++ gcc pkg-config python3-dev python3-pip python3 virtualenv libssl-dev libjson-perl libyaml-perl
# This will bring you into the PERL CPAN shell, prompt looks like ->
# cpan[1]>
sudo perl -MCPAN -e shell# Once inside the shell install the PERL packages
install Crypt::MySQL
install LWP::Protocol::https
install Net::MQTT::Simple
install Net::WebSocket::Server
install Time::Piece
# These 2 may already be installed but try anyways
install Config::IniFiles
install Crypt::Eksblowfish::Bcrypt
# Exit the CPAN shell
exit
# If you face issues installing Crypt::MySQL try this instead: (Thanks to aaronl)sudo apt-get install libcrypt-mysql-perlIf you face issues installing Crypt::Eksblowfish::Bcrypt, use this instead:sudo apt-get install libcrypt-eksblowfish-perl

Test OpenCV before moving on to DLib and ALPR. Install neo-ZMES

Now is the time to make sure OpenCV is working for GPU detections. First, git clone the neo repos. I like to have a folder named ‘git’ to hold my git repos, this example will create a ‘git’ folder in the home dir to hold the neo repos. Install neo-pyzm first, then zmeventnotification and finally mlapi (That will come later after compiling face detection with DLib and ALPR)

cd ~
mkdir git
cd git
git clone https://github.com/baudneo/pyzm.git
cd pyzm
sudo ./install.sh
# Follow the prompts, if you have an old version of pyzm installed reply 'y' to the removal question.
# go back to the git folder
cd ..
# clone the neo-zmeventnotification repo and installgit clone https://github.com/baudneo/zmeventnotification.gitcd zmeventnotification# Edit the install.sh file first to enable downloading the coral tpu models.
nano install.sh
# Find -> INSTALL_CORAL_EDGETPU=${INSTALL_CORAL_EDGETPU:-no} and change to
INSTALL_CORAL_EDGETPU=${INSTALL_CORAL_EDGETPU:-yes}
# Save and exit
sudo ./install.sh# For now we do not need to install mlapi. That will be after Dlib and ALPR.# Install the 'shapely' python module dependancies
sudo apt install libgeos-dev

Next, it is time to configure ZM and ZMES to work together. Goto the ZM web GUI and find “options”. In options select ‘users’.

Adding an API user

Add a new user with a password, give the user all ‘Edit’ permissions. This username and password is the user and pass for the objectconfig.ini config file. Next, go back to Options -> System and set up the Unique key and hashed authentication.

Enabling auth

Make sure that AUTH_HASH_IPS is deselected! it causes issues with zmNinja. Change the AUTH_HASH_SECRET to something unique, it is what is used to sign/create JWT tokens for API 2.0+ auth, it is not a password.

--

--