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.

Installation

Install the zoneminder package from AUR. The development branch is also available with zoneminder-git. Other AUR packages (usually less supported) include zoneminder-svn[broken link: package not found], zoneminder-xinetd and zoneminder64.

Once configuration below is completed and the system service started, the web interface will be accessible via http://localhost/zoneminder. It is very important that httpd and php are configured in order for ZoneMinder to work (especially with local cameras!).

Configuration

Apache HTTPd

httpd.conf

Edit /etc/httpd/conf/httpd.conf.

Add the line:

Include /etc/httpd/conf/extra/httpd-zoneminder.conf

Also, ensure you have mod_cgi enabled:

LoadModule cgi_module modules/mod_cgi.so

PHP

Apache httpd.conf

Edit Apache's configuration file /etc/httpd/conf/httpd.conf.

Comment out LoadModule mpm_event_module modules/mod_mpm_event.so and add LoadModule mpm_prefork_module modules/mod_mpm_prefork.so

 # mpm_event_module modules/mod_mpm_event.so
 LoadModule mpm_prefork_module modules/mod_mpm_prefork.so

php.ini

Edit /etc/php/php.ini.

Ensure the following extensions are enabled:

extension=pdo_mysql.so
extension=gd.so
extension=gettext.so
extension=mcrypt.so

extension=sockets.so
extension=openssl.so
extension=ftp.so

Ensure open_basedir has the following directories added/included:

* /tmp
* /var/cache/zoneminder
* /srv/zoneminder
* /etc

For example:

open_basedir = /srv/http/:/home/:/tmp/:/usr/share/pear/:/usr/share/webapps/:/dev/:/etc:/srv/http/zoneminder:/srv/zoneminder/:/var/cache/zoneminder/

Set your timezone, for example:

date.timezone = Australia/Sydney

Optional Packages

Install netpbm from the official repositories for thumbnail generation (used rarely).

Enable System Services

For 'always on' and on boot:

ZoneMinder:

$ systemctl enable zoneminder

Also ensure Apache HTTPd is enabled:

$ systemctl enable httpd

Service Management

Starting the ZoneMinder service:

$ systemctl start zoneminder

Restarting the ZoneMinder service:

$ systemctl restart zoneminder

Stopping the ZoneMinder service:

$ systemctl stop zoneminder

Its also possible to do this via the web interface.

Flushing Application Data

This is useful for developers or users that need to wipe all ZoneMinder and start fresh.

Dropping the database

Drop the ZoneMinder MySQL database.

MySQL root user with a password:

$ echo 'delete from user where User="zoneminder";' | mysql --defaults-file=/etc/mysql/my.cnf -p mysql
$ echo 'delete from db where User="zoneminder";' | mysql --defaults-file=/etc/mysql/my.cnf -p mysql
$ mysqladmin --defaults-file=/etc/mysql/my.cnf -p -f drop zoneminder

Or, root without password:

$ echo 'delete from user where User="zoneminder";' | mysql --defaults-file=/etc/mysql/my.cnf mysql
$ echo 'delete from db where User="zoneminder";' | mysql --defaults-file=/etc/mysql/my.cnf mysql
$ mysqladmin --defaults-file=/etc/mysql/my.cnf -f drop zm

Reset the database and permissions

MySQL root user with a password:

$ mysqladmin --defaults-file=/etc/mysql/my.cnf -p -f reload
$ cat /usr/share/zoneminder/db/zm_create.sql | mysql --defaults-file=/etc/mysql/my.cnf -p
$ echo 'grant lock tables, alter,select,insert,update,delete on zm.* to 'zmuser'@localhost identified by "zoneminder";' | mysql --defaults-file=/etc/mysql/my.cnf -p mysql

Or, root without passsword:

$ mysqladmin --defaults-file=/etc/mysql/my.cnf -f reload
$ cat /usr/share/zoneminder/db/zm_create.sql | mysql --defaults-file=/etc/mysql/my.cnf
$ echo 'grant lock tables, alter,select,insert,update,delete on zm.* to 'zmuser'@localhost identified by "zoneminder";' | mysql --defaults-file=/etc/mysql/my.cnf mysql

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/* 

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.

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