How to Install ZoneMinder on the Raspberry Pi

Ben
Ben
@benjislab

ZoneMinder is a powerful, open-source video surveillance software that allows you to monitor and record from multiple cameras. Installing ZoneMinder on your Raspberry Pi can turn it into a cost-effective, flexible security system for your home or office. This guide will walk you through the steps to install and configure ZoneMinder on your Raspberry Pi.

Equipment Needed

  • Raspberry Pi (preferably Raspberry Pi 4 for better performance)
  • Raspberry Pi OS (preferably Raspberry Pi OS Lite for a lightweight setup)
  • Internet connection
  • Access to the command line
  • Camera(s) compatible with ZoneMinder

Update Your System

Start by updating your Raspberry Pi to ensure all packages are up-to-date.

sudo apt update
sudo apt upgrade

Install Required Dependencies

ZoneMinder requires several dependencies to function correctly. Install these using the following commands:

sudo apt install -y apache2 mariadb-server php libapache2-mod-php php-mysql \
php-gd php-xml php-mbstring php-zip php-json php-intl libdate-manip-perl \
libarchive-zip-perl libphp-serialization-perl libnet-sftp-foreign-perl \
libdevice-serialport-perl libmime-lite-perl libsys-mmap-perl libav-tools \
ffmpeg libdbd-mysql-perl libdata-uuid-perl make cmake g++ libv4l-dev \
libvlc-dev libmysqlclient-dev libcurl4-openssl-dev libssl-dev yasm \
libpcre3-dev libbz2-dev libjpeg-dev libavcodec-dev libavformat-dev \
libswscale-dev libavdevice-dev libavfilter-dev libpostproc-dev \
libfontconfig1-dev libv4l2rds-dev libv4l2rds0 libvlc-bin libvlc5 \
libvlccore9 libvlccore-dev libvlc-dev vlc-bin vlc-data vlc-l10n \
vlc-plugin-access-extra vlc-plugin-base vlc-plugin-video-output \
libvlc-bin libvlc5 libvlccore9 libvlccore-dev vlc-plugin-qt vlc-plugin-skins2 \
vlc-plugin-video-splitter vlc-plugin-visualization

Configure MySQL Database

  1. Secure the MySQL installation:
sudo mysql_secure_installation

Follow the prompts to set up the root password and secure your installation.

  1. Create the ZoneMinder database:
sudo mysql -u root -p

Enter your root password, then run the following commands in the MySQL prompt:

CREATE DATABASE zm;
CREATE USER 'zmuser'@'localhost' IDENTIFIED BY 'zmpass';
GRANT ALL PRIVILEGES ON zm.* TO 'zmuser'@'localhost' WITH GRANT OPTION;
FLUSH PRIVILEGES;
EXIT;

Install ZoneMinder

  1. Download ZoneMinder:

Download the latest version of ZoneMinder from GitHub:

cd /usr/src
sudo git clone https://github.com/ZoneMinder/zoneminder.git
cd zoneminder
  1. Build ZoneMinder:
sudo cmake .
sudo make
sudo make install
sudo ldconfig
  1. Configure Apache:

Copy the ZoneMinder Apache configuration file:

sudo cp /usr/src/zoneminder/distros/ubuntu1804/apache.conf /etc/apache2/conf-available/zoneminder.conf
sudo a2enconf zoneminder
sudo a2enmod cgi
sudo a2enmod rewrite
sudo systemctl restart apache2
  1. Set Up ZoneMinder Database:

Import the ZoneMinder database schema:

sudo mysql -u root -p zm < /usr/src/zoneminder/db/zm_create.sql
  1. Configure ZoneMinder:

Edit the ZoneMinder configuration file:

sudo nano /etc/zm/zm.conf

Ensure the database settings match the following:

ZM_DB_HOST=localhost
ZM_DB_NAME=zm
ZM_DB_USER=zmuser
ZM_DB_PASS=zmpass

Save and close the file.

  1. Set Permissions and Start ZoneMinder:
sudo chown -R www-data:www-data /usr/src/zoneminder
sudo systemctl enable zoneminder
sudo systemctl start zoneminder

Access ZoneMinder Web Interface

ZoneMinder should now be running. You can access the ZoneMinder web interface by navigating to http://<your_pi_ip>/zm in your web browser. Replace <your_pi_ip> with the IP address of your Raspberry Pi.

Add Cameras to ZoneMinder

  1. Log in to the ZoneMinder web interface.
  2. Go to the "Console".
  3. Click "Add New Monitor".
  4. Configure the camera settings according to your camera's specifications.

Conclusion

By following these steps, you have successfully installed and configured ZoneMinder on your Raspberry Pi. ZoneMinder provides a robust and flexible solution for video surveillance, allowing you to monitor and record from multiple cameras. Whether for home security or office monitoring, your Raspberry Pi with ZoneMinder offers a powerful and cost-effective surveillance system.