A fully detailed guide on how you can install Zoneminder on your own private server running Debian with SSL integration.
Why?
I was doubting between purchasing a Network Video Recorder (NVS) and setting up an old server with ZoneMinder.
Update: Since 2022 I have a DVR to save on power consumption
Server hardware
- Dell PowerEdge R310 1U server (2010 version)
- OS disks (300GB usable)
- 2x 300GB Dell HGST Ultrastar 15K600 (SAS 6Gbps)
- RAID 1
- Write-Through enabled
- 64K stripe size
- Take note that RAID 1 provides mirror and thus 1 disk redundancy, it offers no parity, striping, or spanning
- Storage disks (1.8TB usable)
- 2x 1TB Dell HGST Ultrastar 15K600 (SAS 6Gbps)
- RAID 0 (yes, seriously)
- Write-Back enabled
- 128K stripe size
- Take note that RAID 0 provides no fault tolerance or redundancy
- 24GB DDR3 ECC RAM @ 800MHz
- Intel Xeon X3470 8MB cache, 4 cores, 8 threads, running @2.93GHz
- 2x 1GB Broadcom BCM5716 Network adapters in LACP mode for teaming (bond0)
Camera’s
- 1x HikVision DS-2CD2143G0 with 4MP
- 2x HikVision DS-2CD2385G1 with 4K and 8MP
- 2x HikVision DS-KB8112 doorstation intercoms
Good to know
- Set the NIC type to fixed 100(0)M Full Duplex on both the camera and switch to prevent duplex mismatches
- If using h.264 set the camera settings through the camera app directly e.g. IVM-4200 for HikVision cams
- Bitrate = variable
- Max. Bitrate = 8192 Kbps (bitrate calculation)
- Framerate = 10 FPS (25 is not really needed for a security camera, as 10 will show you all the information you need)
- I-Frame interval = 10 (should match your FPS)
- Video encoding = H.26
- SVC = off
Installation steps
Hardware preparation & Debian installation
- Install all the needed hardware devices
- Set up the RAID configs for the OS and Storage volumes
- For my installation stick of Debian 10 I needed to include the BCM5716 drivers from the Debian packages site
- Download firmware-bnx2
- Extract in your USB installation stick /firmware(s) folder
- Follow the default installation steps
- Under disk configuration you can already provision the Storage drive if you wish. I’ve did this and set it as /storage
- Once installed reboot and login
Basic settings
- Increase the /dev/shm size, the SHM is the SHared Memory:
- Command “
sudo nano /etc/fstab
”- add the following line “
tmpfs /dev/shm tmpfs defaults,size=32G 0 0
“
- add the following line “
- More information about the SHM
- Command “
- OPTIONAL STEP: Set up the LACP bond
- Install “
apt-get install ifenslave
“ - Command “
sudo nano /etc/network/interfaces
“iface bond0 inet static
address x.x.x.x #server IP address
netmask x.x.x.x # e.g. 255.255.255.0
network x.x.x.x # e.g. 192.168.1.0
gateway x.x.x.x # e.g 192.168.1.254
slaves eth1 eth2 #eth1 eth2 could differ for your server
bond-mode 802.3ad
bond-miimon 100
bond-downdelay 200
bond-updelay 200
- Install “
- (If you skipped step 2) Set your network interface(s)
- Command “
sudo nano /etc/network/interfaces
“iface eth0 inet static
address x.x.x.x #server IP address
netmask x.x.x.x # e.g. 255.255.255.0
network x.x.x.x # e.g. 192.168.1.0
gateway x.x.x.x # e.g 192.168.1.254
- Command “
- Set your resolv.conf
- Command “
sudo nano /etc/resolv.conf
“domain domain.com # If you have a domain name!
search domain.com. # If you have a domain name, add the dot '.' on the end
nameserver x.x.x.x #e.g. 8.8.8.8
nameserver x.x.x.x #e.g. 8.8.4.4
- Command “
- Create the storage locations for ZM under your storage disk
- Command “
sudo mkdir /storage/zoneminder /storage/zoneminder/events/ /storage/zoneminder/images/
“
- Command “
- Install Zoneminder by following the steps from their website.
- After step 5 change the folder permissions with the command “
chown -R www-data:www-data /storage/zoneminder/ /storage/zoneminder/events/ /storage/zoneminder/images/
“
How to secure your ZM installation with SSL?
- Enable the SSL option for PHP by running command “
sudo a2enmod ssl
“ - Create the default SSL configuration by running command “sudo a2ensite default-ssl.conf”
- Restart your Apache server with the command “
systemctl restart apache2
“ - Upload your own SSL certificate and private key with something like WinSCP to your server /home/YourUser/Certificates
- Then do a copy command
cp /home/YourUser/Certificates/mycert.domain.com-crt /etc/ssl/certs/
cp /home/YourUser/Certificates/mycert.domain.com-key.pem /etc/ssl/private/ - Change the default-ssl.conf to use your own certifcate
- Command “
sudo nano /etc/apache2/sites-enabled/default-ssl.conf
”- Optional change your port by changing the VirtualHost part
<VirtualHost _default_:443>
change to e.g.<VirtualHost _default_:8080>
- Change your certificate and private key paths
SSLCertificateFile /etc/ssl/certs/mycert.domain.com-crt.pem
SSLCertificateKeyFile /etc/ssl/private/mycert.domain.com-key.pem
- Command “
- Change the 000-default.conf and set redirects
- Command “
sudo nano /etc/apache2/sites-enabled/000-default.conf
“<VirtualHost *:80>
ServerName camera.mydomain.com
Redirect permanent / https://camera.mydomain.com:8080/zm/
</VirtualHost>
<VirtualHost *:443>
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html
# Logs
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
# Redirect
Redirect permanent / https://camera.mydomain.com:8080/zm/
</VirtualHost>
# vim: syntax=apache ts=4 sw=4 sts=4 sr noet
- Command “
- Change your Apache listening ports
- Command “
sudo nano /etc/apache2/ports.conf
“# If you just change the port or add more ports here, you will likely also
# have to change the VirtualHost statement in
# /etc/apache2/sites-enabled/000-default.conf
Listen 80
Listen 8080 <IfModule ssl_module>
Listen 443
</IfModule> <IfModule mod_gnutls.c>
Listen 443
</IfModule> # vim: syntax=apache ts=4 sw=4 sts=4 sr noet
- Command “
- Finally restart Apache (or reboot your server)”
sudo systemctl restart apache2
“ - Now your browser should show a valid HTTPS connection
Finalize your ZM installation
- Go to your ZM webpage https://YourServerIP:8080/zm/ or http://YourServerIP/zm/ if you didn’t followed the certificate installation steps
- From there you can now set your camera’s and server specific config 🙂
- Setting the additional storage location
- Go to Options
- Storage
- Add a new storage
- Name = e.g Storage
- Path = location of your storage e.g. /storage/zoneminder/events
- URL = leave as isAdd new storage
- Server = leave as is
- Type = local
- Scheme = leave as is (changes how ZM creates folders and files under your storage location)
- Do deletes = yes
- Do not remove the Default location (Trust me)
Optional packages
Install network, disk, cpu and memory monitoring packages
- “
sudo apt-get install htop atop iftop libpcap0.8 libpcap0.8-dev libncurses5 libncurses5-dev
“ - To use htop -> command “
sudo htop
“ - To use atop -> command “
sudo atop
“ - To use iftop -> command “
sudo iftop -i bond0
” (-i to specify the network interface)