ZoneMinder

From ArchWiki
Jump to: navigation, search

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.

Installation

Note: It is very important that a LAMP stack is installed and properly configured in order for ZoneMinder to work.

Install the zoneminderAUR package. The development branch is also available with zoneminder-gitAUR.

For thumbnail generation (used rarely), install the netpbm package.

Once configuration below is completed and the system service started, the web interface will be accessible via http://localhost/zoneminder/.

Configuration

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=ftp.so
 extension=gd.so
 extension=gettext.so
 extension=mcrypt.so
 extension=pdo_mysql.so
 extension=sockets.so
 extension=zip.so

Also set your timezone, for example:

date.timezone = "Australia/Sydney"

See http://php.net/manual/en/timezones.php for a list of timezones.

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 'choose_password';
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=chosen_password

Starting

Start/enable httpd.service and zoneminder.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 'choose_password';
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

Note: this removes all images and events!

$ 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.

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 the zoneminder service, then:

$ rmmod uvcvideo
$ modprobe uvcvideo quirks=128

Start the zoneminder service and if the issue is resolved, perist the change by adding the module option to /etc/modprobe.d/uvcvideo.conf. for example:

options uvcvideo nodrop=1 quirks=128

(reference)

See also