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 zoneminderAUR package from AUR. The development branch is also available with zoneminder-gitAUR. Other AUR packages (usually less supported) include zoneminder-xinetdAUR and zoneminder64AUR.

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 Configuration

Edit /etc/httpd/conf/httpd.conf

Enable PHP

1. Comment out LoadModule mpm_event_module modules/mod_mpm_event.so:

 #LoadModule mpm_event_module modules/mod_mpm_event.so

2. Uncomment LoadModule mpm_prefork_module modules/mod_mpm_prefork.so:

 LoadModule mpm_prefork_module modules/mod_mpm_prefork.so

3. Load mod_php at or near line 183:

 LoadModule php5_module modules/libphp5.so

4. Place this at or near the end of the file:

 Include conf/extra/php5_module.conf
Enable mod_cgi

Uncomment the following line at or near line 170:

LoadModule cgi_module modules/mod_cgi.so
Load the httpd-zoneminder configuration file

Add 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=openssl.so
 extension=pdo_mysql.so
 extension=sockets.so
 extension=zip.so
Set your timezone

For example:

date.timezone = "Australia/Sydney"

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

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