I have been attempting to install Zoneminder 1.36+ on a system running a fresh install of Ubuntu Server 24.04 LTS.  Unfortunately I have been having significant issues doing this.  Most of my issues have been down to the fact that all of the instructions appear to be incomplete!  In this post I hope to gather a more complete set of instructions.  These instructions are not guaranteed to be complete once any amount of time, or major revision changes happen.

Starting point:

It is generally assumed that you have installed Ubuntu Server 24.04 LTS on your hardware and have run “apt update” and “apt upgrade” (NOTE: Use sudo where appropriate).

If you need help install Ubuntu Server, please see https://ubuntu.com/server/docs

I started by following the tutorial at https://stealthy.io/blog/2024/10/06/how-to-setup-zoneminder.html

Installing Zoneminder

Installing Apache2, Mariadb, and Zoneminder

You will need root access to the server for this entire process. As of November 2024, Ubuntu 24.04 installs Zoneminder 1.36.33. If you need a newer version, please see the Zoneminder documentation.

Run the following command:

$ sudo apt -y install apache2 mariadb-server zoneminder
#### set your system timezone
$ sudo timedatectl set-timezone America/New_York

#### set permissions for the Zoneminder directories
$ sudo chown -R www-data:www-data /usr/share/zoneminder/www/api
$ sudo chown -R root:www-data /etc/zm

Set up the database time zone

Make sure you edit the /etc/mysql/conf.d/mysql.cnf to your correct timezone, for example, mine:

[mysql]
timezone='America/New_York'

Set up the database and Zoneminder database password

#### Fill Zoneminder's database structure
$ sudo mariadb < /usr/share/zoneminder/db/zm_create.sql

### login as root
$ sudo su -
#### login to mariadb
root$ mariadb
#### Select the zm database to edit
mariadb> use zm
#### create a new user zmuser and a custom password for it
mariadb> CREATE USER zmuser@localhost IDENTIFIED BY 'badpassword';
#### grant all privileges
mariadb> GRANT ALL PRIVILEGES ON zm.* TO zmuser@localhost;
mariadb> FLUSH PRIVILEGES;
#### exit
mariadb> exit;

####change the ZM_DB_PASS setting to what you used above.
root$ nano /etc/zm/zm.conf

Set up a second disk for event storage

I plan on running the system on a multi disk server: If you don’t plan on running a multi disk system, skip down to Configuring Apache.

SSD1: OS drive

HDD1-x: video storage (in the case of my server, 6 drives, set up with LVM to mirror/stretch)

My LVM for the event storage is named /video

$ sudo chown www-data:www-data /video

Now you need to edit the file /etc/zm/conf.d/01-system-paths.conf

Change the ZM_DIR_EVENTS variable to match the mount point of your disk.

Configuring Apache

I plan on using a self signed certificate for my site, so I will enable SSL in Apache: (NOTE: self signed certificates will get angry warnings when attempting to view them!)

Create the SSL certificates:

sudo mkdir /etc/apache2/ssl
sudo openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /etc/apache2/ssl/apache.key -out /etc/apache2/ssl/apache.crt

Edit the default-ssl.conf under /etc/apache2/sites-available (NOTE: most comments removed for clarity)

<VirtualHost *:443>
        ServerAdmin webmaster@sitename

        DocumentRoot /var/www/html


        #LogLevel info ssl:warn

        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined


        #   SSL Engine Switch:
        #   Enable/Disable SSL for this virtual host.
        SSLEngine on


        SSLCertificateFile      /etc/apache2/ssl/apache.crt
        SSLCertificateKeyFile   /etc/apache2/ssl/apache.key

        <FilesMatch "\.(?:cgi|shtml|phtml|php)$">
                SSLOptions +StdEnvVars
        </FilesMatch>
        <Directory /usr/lib/cgi-bin>
                SSLOptions +StdEnvVars
        </Directory>
</VirtualHost>

Edit or replace the /etc/apache2/conf-available/zoneminder.conf to read like below:

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"
<Directory "/var/cache/zoneminder">
    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>

# https://wiki.zoneminder.com/API#Example_Configuration_for_%2Fetc%2Fapache2%2Fconf-enabled%2Fzoneminder.conf
# 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>

At this point you should be able to enable the site, and have at least the most basic Zoneminder site working.

#### enable some Apache Modules
$ sudo su
root$ a2ensite default-ssl.conf
root$ a2enmod cgi
root$ a2enmod rewrite
root$ a2enmod expires
root$ a2enmod headers
root$ a2enmod ssl
root$ a2enconf zoneminder
root$ systemctl restart apache2
root$ systemctl enable zoneminder
root$ systemctl restart zoneminder

At this point you should be able to visit the url for the server http://ipaddress/zm

Since Zoneminder has not been configured you should see a page asking you to enable telemetry back to the Zoneminder team. This page is NOT a license agreement. Select AGREE/DISAGREE and save it. You should now be sitting on the console (since there is no authentication enabled by default). This will be useful during initial setup of the cameras and other settings, but I do NOT recommend leaving the system without authentication, especially if you plan on allowing the system to be viewable from the open internet.

Edited Dec 1st to add new findings.

Note: all work on this article were verified by doing to following multiple times:

1). fresh install of Ubuntu 24.04 LTS Server

2). configure Zoneminder

3). fail

4). return to step 1 with new information

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.