ZoneMinder

ZoneMinder Capture, analyse, record and monitor any cameras attached to your system.

Dependencies

 * Apache 2: www-servers/apache
 * MySQL: dev-db/mariadb
 * PHP: dev-lang/php

USE flags
Enable the following USE flags for and :

Emerge
Install ZoneMinder:

Apache

 * Select correct version of PHP


 * Edit /etc/php/apache2-php5.6/php.ini to reflect:


 * Edit /etc/conf.d/apache2 and add "-D PHP -D PROXY" to APACHE2_OPTS


 * Remove Apache startup warning: "...fully qualified domain name..."

MySQL

 * Create ZoneMinder's database, zm, as a standard user


 * Import the database schema and base data, the .sql script is created by the configure phase above, so make sure you do that first.


 * Create a MySQL user for ZM to use. If you change the user and/or password from the defaults here, then make sure you set those in the source configure phase.

ZoneMinder

 * Edit /etc/zm.conf and add the above MySQL database username and password:

OpenRC
Start the Apache server:

Add Apache to the default runlevel:

Reload the Apache configuration files:

Start PHP server:

Add PHP to the default runlevel:

Start MySQL server:

Add MySQL to the default runlevel:

Start ZoneMinder server:

Add ZoneMinder to the default runlevel:

systemd
Start the Apache server:

Add Apache to startup:

Start the PHP server:

Add PHP to startup:

Start the MySQL server:

Add MySQL to startup:

Start the ZoneMinder server:

Add ZoneMinder to startup:

SELinux
When using SELinux, first create a SELinux policy for the application:

Now it's time to build the modules:

Other
Shared memory: sysctl kernel.shmmax=536870912

Troubleshooting
The symptoms: [Tue Oct 27 10:38:55.754977 2015] [cgi:error] [pid 29986] [client 192.168.0.9:54882] AH02811: script not found or unable to stat: /var/www/localhost/cgi-bin/nph-zms, .. blah blah 192.168.0.9 - - [27/Oct/2015:10:38:55 -0700] "GET /cgi-bin/nph-zms?source=event&mode=jpeg&event=5&frame=1&scale =50&rate=100&maxfps=30&replay=single&connkey=313914&rand=1445967535  HTTP/1.1" 404 274 ERR [socket_sendto( /var/run/zm/zms-264615s.sock ) failed: No such file or directory]
 * Missing live video stream;
 * In apache logs, couldn't find zms or nph_zms;
 * apparent missing socket in the zonemaster logs


 * Amendment:

Edit /etc/apache2/vhosts.d/10_zoneminder.conf to reflect:

in ZoneMinder Web UI change: Options -> Paths -> PATH_ZMS = /zm/cgi-bin/zms

To apply changes need reload Apache:

and restart ZoneMinder: