ZoneMinder
ZoneMinder is an integrated set of applications which provide a complete surveillance solution allowing capture, analysis, recording and monitoring of any CCTV or security cameras attached to a Linux based machine. It is designed to run on distributions which support the Video For Linux (V4L) interface and has been tested with video cameras attached to BTTV cards, various USB cameras and also supports most IP network cameras.
Contents
Installation
Install the zoneminderAUR package. The development branch is also available with zoneminder-gitAUR.
Set up sql mode, otherwise strange sql-related errors will occur when saving various parts of configuration
/etc/mysql/my.cnf.d/zoneminder.cnf
[mysqld] sql_mode=NO_ENGINE_SUBSTITUTION
Once configuration below is completed and the system service started, the web interface will be accessible via http://localhost:8095
Manual installation
Once configuration below is completed and the system service started, the web interface will be accessible via http://localhost/zoneminder/.
Apache
Enable PHP as described in Apache HTTP Server#PHP.
Uncomment the following line in /etc/httpd/conf/httpd.conf
:
LoadModule cgi_module modules/mod_cgi.so
Include the httpd-zoneminder
configuration file, by adding this line at or near the end of httpd.conf
:
Include conf/extra/httpd-zoneminder.conf
PHP
Edit /etc/php/php.ini
. Ensure the following extensions are enabled by uncommenting these lines:
extension=apcu extension=ftp extension=gd extension=gettext extension=pdo_mysql extension=sockets extension=zip
Also set your timezone, for example:
date.timezone = "Australia/Sydney"
See http://php.net/manual/en/timezones.php for a list of timezones.
Sometimes, the /etc/php/conf.d/zoneminder.ini file may appear:
extension = apcu extension = ftp extension = gd extension = gettext extension = pdo_mysql extension = sockets extension = zip
date.timezone = PLACEHOLDER
if the zone is not logged, run:
sed -i 's | PLACEHOLDER |' `timedatectl | grep "Time zone" | tr -s | cut -f4 -d `'| g' /etc/php/conf.d/zoneminder.ini
MySQL
Create the zm database and user with appropriate permissions and password :
$ mysql -u root -p
CREATE DATABASE zm; CREATE USER 'zmuser'@'localhost' IDENTIFIED BY 'zmpass'; GRANT ALL ON zm.* TO 'zmuser'@'localhost'; exit
Import the preconfigured tables into your newly created zm database:
$ mysql -u root -p zm < /usr/share/zoneminder/db/zm_create.sql
Update the ZoneMinder config with your new parameters:
/etc/zm.conf
ZM_DB_HOST=localhost ZM_DB_NAME=zm ZM_DB_USER=zmuser ZM_DB_PASS=zmpass
Set up sql mode, otherwise strange sql-related errors will occur when saving various parts of configuration
/etc/mysql/my.cnf.d/zoneminder.cnf
[mysqld] sql_mode=NO_ENGINE_SUBSTITUTION
Security
To increase security, you need to set a password for the root user:
/usr/bin/mysqladmin' -u root password 'new-password' /usr/bin/mysqladmin' -u root -h lilya-x64 password 'new-password'
In addition, you can run:
/usr/bin/mysql_secure_installation
Starting
Start/enable httpd.service
, zoneminder.service
, fcgiwrap-multiwatch.service
and php-fpm.service
.
Troubleshooting
Logs by default are kept in /var/log/zoneminder
. You can also inspect the log within the web interface.
See the upstream wiki page: Troubleshooting.
Flushing application data
This is useful for developers or users that need to wipe all ZoneMinder and start fresh.
Recreate the database
Drop the ZoneMinder MySQL database and delete the MySQL user:
$ mysql -u root -p
DROP DATABASE zm; DROP USER 'zmuser'@'localhost';
Recreate the database and user:
$ mysql -u root -p
CREATE DATABASE zm; CREATE USER 'zmuser'@'localhost' IDENTIFIED BY 'zmpass'; GRANT CREATE, INSERT, SELECT, DELETE, UPDATE ON zm.* TO 'zmuser'@'localhost'; exit
Import the preconfigured tables into your newly created zm database:
$ mysql -u root -p zm < /usr/share/zoneminder/db/zm_create.sql
Flush the cache folders
$ rm -Rf /var/cache/zoneminder/events/* /var/cache/zoneminder/images/* /var/cache/zoneminder/temp/*
Local video devices
It is important that the user running httpd (usually http) can access your cameras, for example:
$ groups http
video http
$ ls -l /dev/video0
crw-rw----+ 1 root video 81, 0 Oct 28 21:54 /dev/video0
That is, add the http user to the video group.
To add a user to the group run the command:
usermod -aG video http
Multiple local USB cameras
If you observe an error like, libv4l2: error turning on stream: No space left on device when using multiple USB video devices (such as multiple webcams), you may need to increase the bandwidth on the bus.
Test first by stopping zoneminder.service
, then:
$ rmmod uvcvideo $ modprobe uvcvideo quirks=128
Start zoneminder.service
and if the issue is resolved, persist the change by adding the module option to /etc/modprobe.d/uvcvideo.conf
. For example:
options uvcvideo nodrop=1 quirks=128
See also
- https://wiki.zoneminder.com/index.php/Arch_Linux — Upstream project page.