In this tutorial, we will show you how to install ZoneMinder on the Raspberry Pi.
ZoneMinder is free, open-source software that allows you to monitor your CCTV feeds from one location. Best of all, thanks to being open-source software, it has support for most analog or IP cameras.
The Raspberry Pi makes an excellent pick for running ZoneMinder, especially when you don’t have many cameras since it is relatively low-powered and can be left running 24/7.
To make the most of ZoneMinder, you will need to know your cameras’ IPs and how to connect to them. Thanks to ZoneMinders popularity, you can often search for your camera brand name followed by “ZoneMinder” and find connection guides.
Over the following sections, we will cover how to install all of the software required to get ZoneMinder running on a Raspberry Pi.
Equipment
Below is a list of the equipment we used to set up ZoneMinder on the Raspberry Pi.
Recommended
Optional
This tutorial was tested on a Raspberry Pi 400 running the latest version of Raspberry Pi OS Bullseye.
Installing ZoneMinder to the Raspberry Pi
This section will show you how to install and prepare ZoneMinder on the Raspberry Pi. These steps involve us installing and setting up other elements, such as the MySQL server and the Apache web server.
The following sections will be entirely within the command line. If you are using Raspberry Pi OS Desktop, you can open the terminal by pressing CTRL + ALT + T on your keyboard.
Installing Any Required Packages
1. Before installing ZoneMinder and its dependencies on our Raspberry Pi, we need to update the package list cache.
You can update this list cache by using the following command in the terminal.
2. Once the package list update completes, we can move on to installing all of the software we require.
You can install, Apache2, MariaDB, and ZoneMinder by using the following command within the terminal.
3. After installing the database server, you should run the MySQL secure installation script.
This script helps remove weak security settings from the database server.
- When prompted to enter the password for the root user, leave it blank and press the ENTER key.
- Since the root user is configured by default to use “
unix_socket
” authentication. Type in “n
” then press the ENTER key. - You will then be prompted to change the root password. Since “
unix_socket
” is being used, type “n
” then press ENTER. - For the rest of the options you are presented with, type in “
Y
“, then press the ENTER key. The rest of the options will improve the security of your database server.
Setting up the ZoneMinder Database on the Raspberry Pi
4. Our next step is to set up ZoneMinder on our Raspberry Pi’s database server.
To begin this process, you will want to type in the following command.
5. Our first step is to create a database where we will store the ZoneMinder database.
You will want to use the following command to create a database with the name “zm
“.
This database must be called “zm
” due to the way ZoneMinder has written its SQL creation file.
6. With the database created, our next step is to create a SQL user that we will use to interact with it.
To create a user called “zoneminder_usr
“. you will want to use the following command.
Ensure you replace “PASSWORD
” with a secure password of your choosing.
If you want a password manager to generate and keep your passwords secure, we highly recommend checking out NordPass. NordPass is a password manager developer by the same team behind NordVPN. (Affiliate Link)
7. With our user created, we need to grant it all privileges on our “zm
” database.
To do this, you will want to run the following command within the SQL command line.
8. Since we have changed the permissions on our Raspberry Pi’s database server, we will need to flush the privileges.
You can flush the privileges on your database by using the following command.
9. With that done, you can exit out of the SQL command line by typing in the following.
10. Our final step is to import the Zoneminder SQL file to our Raspberry Pi’s database. This SQL file contains a series of commands that will set up all the tables within the database.
We can import this database by using the following command.
Correcting your Raspberry Pi’s Timezone
11. The Zoneminder software requires you to have your Raspberry Pi’s time zone configured. This must be configured for the device itself and PHP.
Let us start by setting the Pi’s timezone using the Raspberry Pi configuration tool. You can open this tool by using the following command.
12. Within the tool, navigate to “Localisation Options
“, then to “Timezone
“, and follow the prompts to set the time zone.
You can navigate this menu using the ARROW keys to move up and down, then the ENTER key to select an option.
13. Our next step is to modify the PHP timezone by adjusting the configuration files.
Since the default version of PHP can change depending on the OS, we can grab the version number by using the following line
14. Now that we have the PHP version stored in an environment variable, we can easily edit the correct configuration file.
Begin modifying PHP’s configuration file by using the following command.
15. Within this file, you will want to find the following line. Since we are using the nano text editor, you can search using CTRL + W.
Once found, you want to set this value to your time zone and remove the semicolon (;
). You can find the correct value for your time zone by using PHP’s list of supported timezones.
For example, we would use the following line to set the time zone to Hobart, Australia.
16. Once done, you can save and quit by pressing CTRL + X, followed by Y, then the ENTER key.
Configuring ZoneMinder on the Raspberry Pi
17. At this point, we finally have everything set up correctly. The only major thing we need to do is modify ZoneMinder’s configuration file.
You can edit the software’s configuration file using the following command.
18. The first value we need to update is the name of the SQL user ZoneMinder will connect using on our Raspberry Pi.
To change this, search for the following line within the file.
Replace the above line with the following.
19. With the user updated, we next need to set the password for this user within this file.
Locate the following line that declares the password for the SQL user.
Replace that line with the following, ensuring you swap “PASSWORD
” out with the one you used when creating the SQL user.
20. With the database username and password set, you can save and quit by pressing CTRL + X, followed by Y, then the ENTER key.
21. Since the user that operates the web server will need to grab the configurations from this file, we will need to grant it ownership of it.
You can use the following chown command to give the “www-data
” user ownership of the ZoneMinder config file.
Enabling the ZoneMinder Apache Configuration
22. We are finally at the point that we can safely enable the ZoneMinder Apache configuration.
ZoneMinder automatically created the correct config files during installation on our Raspberry Pi. We simply need to enable them.
To enable the ZoneMinder Apache configuration, run the command below.
23. Our next task is to restart Apache2, which can be done by simply using the following command.
Starting the ZoneMinder Service on the Raspberry Pi
24. We almost have ZoneMinder entirely up and running on our Raspberry Pi.
Our next few steps will involve enabling the service so that it starts at boot, then finally starting the software itself.
Run the command below to enable ZoneMinder to automatically start when your device boots.
25. Now, use the following command to start the ZoneMinder camera monitor software.
26. At this point, you finally have ZoneMinder running on your Raspberry Pi. It can now be put to use to monitor your various cameras.
Accessing the ZoneMinder Web Interface
With ZoneMinder finally installed on our Raspberry Pi, it is now basically driven entirely through its web interface.
This section will show you how to access its web interface and point you toward adding cameras.
1. To access the web interface, you will need to know the IP address of your Raspberry Pi.
One of the easiest ways of getting the IP address is to utilize the hostname command.
2. Once you know the IP address of your device, you will want to go to the following address in your favourite web browser.
Replace “IPADDRESS
” with the IP address of your Raspberry Pi.
3. When you first visit the ZoneMinder web interface, you will be asked to agree to a privacy policy.
Read through the text, and if you agree, click the “APPLY
” button in the screen’s bottom-left.
4. You will now be greeted by your Raspberry Pi’s ZoneMinder dashboard. This dashboard is where you will see all of your available cameras after adding them to ZoneMinder.
To add a camera to ZoneMinder, you will want to click the “ADD
” button.
5. We won’t be diving into how exactly to add a camera to ZoneMinder we will cover the basic settings you will need to set.
On the first page, you will want to give a name to your camera (1.), so you can easier identify it within the interface.
After that, the other main settings you will want to adjust are within the “Source
” tab (2.).
6. The source tab allows you to set how ZoneMinder will interact with your cameras.
The source path (1.) is where you will specify the path to where ZoneMinder can access your camera. If you are using an IP camera, this is highly likely an RTSP link. You can Google your camera to find out exactly how it works.
The other thing you might need to change is the “Method
” (2.). Select the method that matches the connection type.
Conclusion
At this point in the tutorial, you should now have ZoneMinder running on your Raspberry Pi.
ZoneMinder is a powerful application that can monitor and record footage from numerous cameras. While we haven’t covered adding cameras within the web interface, you can check the official documentation.
Please comment below if you have any issues with installing ZoneMinder on your device.
Be sure to check out our many other Raspberry Pi projects, such as our guide on setting up a webcam server.