Installing ZoneMinder on Ubuntu 18.04.1 LTS

Because their documentation sucks

This needs an entire blog post?

Sadly, it does. ZoneMinder has several convenient installation methods, but for some reason Ubuntu 18.04 (bionic) has no prepackaged builds. The Ubuntu PPA has no packages for 18.04, which isn’t apparent until apt reports that it can’t find any suitable packages. The Docker based method to build the packages fails as Ubuntu 18.04 is not in the list of supported distros (although it still attempts to, but fails). So now we have to build the package from the source, uggh.

Building the Package

The following is specifically for Ubuntu 18.04.1 LTS, but in theory this should work on any Debian system. If you are using a different distro the dependencies might be different and the resulting package will be named differently, so be sure to account for that. These instructions are based off the ZoneMinder docs article, which gets most of it right, but is a bit incomplete.

# Download the build script
wget https://raw.githubusercontent.com/ZoneMinder/ZoneMinder/master/utils/do_debian_package.sh

# Make the build script executable
chmod a+x do_debian_package.sh

# Update your package lists
sudo apt-get update

# Install required pacakges
sudo apt install devscripts gdebi-core

# Build the release version
./do_debian_package.sh --snapshot=stable --type=local

Now you can setup ZoneMinder like you would normally. The rest of this article goes over the remaining setup.

Setting up ZoneMinder

# Install Apache, MySQL, and PHP
sudo tasksel install lamp-server

# Remove the previous config file
sudo rm /etc/mysql/my.cnf

# Copy the template config to create our new config file
sudo cp /etc/mysql/mysql.conf.d/mysqld.cnf /etc/mysql/my.cnf

Now we need to edit /etc/mysql/my.cnf with your favorite editor. Add the following to the [mysqld] section:

sql_mode = NO_ENGINE_SUBSTITUTION

Next, we need to restart the MySQL service for our changes to the config to take place, then we can continue the installation:

sudo systemctl restart mysql.service

# Install the newly built package
sudo gdebi zoneminder_1.32.2-bionic_amd64.deb

# Secure the MySQL install
# DO NOT enable the validate password plugin
sudo mysql_secure_installation


# Fix permissions
sudo chmod 740 /etc/zm/zm.conf
sudo chown root:www-data /etc/zm/zm.conf
sudo chown -R www-data:www-data /usr/share/zoneminder/

# Setup Apache2
sudo a2enconf zoneminder
sudo a2enmod rewrite
sudo a2enmod cgi
sudo a2enmod expires
sudo a2enmod headers

# Restart the Apache2 service
sudo systemctl restart apache2.service

# Enable and start the ZoneMinder service
sudo systemctl enable zoneminder.service
sudo systemctl start zoneminder.service

Now we need to edit /etc/php/7.2/apache2/php.ini with your favorite editor. If you have a different version of PHP installed, you may need to change the version number in the path to match. In the [Date] section, uncomment the line that begins with date.timezone by removing the semicolon at the beginning of the line and change the line to reflect your timezone. You can get a list of all the supported time zones from the List of Supported Timezones page.

date.timezone = America/Los_Angeles

Finally, all we have left to do is reload the Apache2 service:

sudo systemctl reload apache2.service

Pop the IP of your server into your browser and you’re ready to use ZoneMinder.