ZoneMinder video camera security and surveillance: Difference between revisions

From Alpine Linux
No edit summary
mNo edit summary
(22 intermediate revisions by 4 users not shown)
Line 1: Line 1:
Currently zoneminder has to be installed from edge, make sure you have edge as pinned repo when you use stable.
[https://www.zoneminder.com/ ZoneMinder] usually runs with [[Apache]], but in this short how-to we use [[Lighttpd]].


ZoneMinder usually runs with apache, but in this short howto we use lighttpd.
First, add the needed packages to our system


First add the needed packages to our system
apk add zoneminder mysql mysql-client lighttpd php5-fpm php5-pdo php5-pdo_mysql


apk add zoneminder@edge mysql mysql-client lighttpd php-fpm # add phpmyadmin if you like to manage mysql from web interface
Initialize [https://www.mysql.com/ MySQL] database


Initialize mysql database
/etc/init.d/mariadb setup


/etc/init.d/mysql setup
Set root password for MySQL as instructed by MySQL setup


set root password for mysql as instructed by mysql setup
/usr/bin/mysqladmin -u root password 'your_secure_root_mysql_password'


Create a zoneminder MySQL database and user
Create a ZoneMinder MySQL database and user


  mysql> create database zm;
  mysql> create database zm;
Line 19: Line 19:
  mysql> CREATE USER zm@localhost IDENTIFIED BY 'your_zm_password_as_set_in_config';
  mysql> CREATE USER zm@localhost IDENTIFIED BY 'your_zm_password_as_set_in_config';


  mysql> grant CREATE, INSERT, SELECT, DELETE, UPDATE on zm.* to zm@localhost;
  mysql> grant CREATE, INSERT, SELECT, DELETE, UPDATE, DROP on zm.* to zm@localhost;


We are running lighttpd so lets run php-fpm as lightppd user/group
We are running <code>lighttpd</code>, so let's run <code>php-fpm</code> as lighttpd user/group


  vim /etc/php/php-fpm.conf
  vim /etc/php5/php-fpm.conf


uncomment the php cgi fpm config in lighttpd.conf
Which should look like:
 
; Unix user/group of processes
; Note: The user is mandatory. If the group is not set, the default user's group
;      will be used.
;user = nobody
;group = nobody
user = lighttpd
group = lighttpd
 
Enable the php cgi fpm config in <code>lighttpd.conf</code>


  vim /etc/lighttpd/lighttpd.conf
  vim /etc/lighttpd/lighttpd.conf


start php-fmp
Go down to the includes section, it should look like:
# {{{ includes
include "mime-types.conf"
# uncomment for cgi support
    include "mod_cgi.conf"
# uncomment for php/fastcgi support
#  include "mod_fastcgi.conf"
# uncomment for php/fastcgi fpm support
    include "mod_fastcgi_fpm.conf"
# }}}
 
Edit lighttpd cgi config and add old style cgi support by adding to cgi.assign
 
vim /etc/lighttpd/mod_cgi.conf
 
which should look like
 
cgi.assign = (
    ""      =>      "",
    ".pl"  =>      "/usr/bin/perl",
    ".cgi"  =>      "/usr/bin/perl"
)
 
Start php-fpm


  /etc/init.d/php-fpm start
  /etc/init.d/php-fpm start


start lighttpd
Start lighttpd


  /etc/init.d/lighttpd start
  /etc/init.d/lighttpd start


Set the MySQL hostname, username, password.
Set the MySQL hostname, username, password.
And change the ZoneMinder user (ZM_WEB_USER) and group (ZM_WEB_GROUP) to lighttpd
 
Change the ZoneMinder user (<code>ZM_WEB_USER</code>) and group (<code>ZM_WEB_GROUP</code>) to lighttpd
 
And set <code>ZM_SERVER_HOST</code> to your ZoneMinder hostname/ipaddress


  vim /etc/zm.conf
  vim /etc/zm.conf
Which should look like:
# Username and group that web daemon (httpd/apache) runs as
ZM_WEB_USER=lighttpd
ZM_WEB_GROUP=lighttpd
# ZoneMinder database type: so far only mysql is supported
ZM_DB_TYPE=mysql
# ZoneMinder database hostname or ip address
ZM_DB_HOST=localhost
# ZoneMinder database name
ZM_DB_NAME=zm
# ZoneMinder database user
ZM_DB_USER=zm
# ZoneMinder database password
ZM_DB_PASS=your_zm_password_as_set_in_config
# Host of this machine
ZM_SERVER_HOST=yourserver
Change ownership of <code>zm.conf</code> to <code>lighttpd</code>
chown lighttpd.lighttpd /etc/zm.conf
Initialize the ZoneMinder database
/etc/init.d/zoneminder setup
Start ZoneMinder
/etc/init.d/zoneminder start
Profit!
To access ZoneMinder, browse to http://yourserver/zm/
To make it start automatically on boot:
rc-update add lighttpd default
rc-update add mariadb default
rc-update add php-fpm default
rc-update add zoneminder default
[[Category:Software]]
[[Category:Security]]

Revision as of 14:55, 2 March 2018

ZoneMinder usually runs with Apache, but in this short how-to we use Lighttpd.

First, add the needed packages to our system

apk add zoneminder mysql mysql-client lighttpd php5-fpm php5-pdo php5-pdo_mysql

Initialize MySQL database

/etc/init.d/mariadb setup

Set root password for MySQL as instructed by MySQL setup

/usr/bin/mysqladmin -u root password 'your_secure_root_mysql_password'

Create a ZoneMinder MySQL database and user

mysql> create database zm;
mysql> CREATE USER zm@localhost IDENTIFIED BY 'your_zm_password_as_set_in_config';
mysql> grant CREATE, INSERT, SELECT, DELETE, UPDATE, DROP on zm.* to zm@localhost;

We are running lighttpd, so let's run php-fpm as lighttpd user/group

vim /etc/php5/php-fpm.conf

Which should look like:

; Unix user/group of processes
; Note: The user is mandatory. If the group is not set, the default user's group
;       will be used.
;user = nobody
;group = nobody
user = lighttpd
group = lighttpd

Enable the php cgi fpm config in lighttpd.conf

vim /etc/lighttpd/lighttpd.conf

Go down to the includes section, it should look like:

# {{{ includes
include "mime-types.conf"
# uncomment for cgi support
   include "mod_cgi.conf"
# uncomment for php/fastcgi support
#   include "mod_fastcgi.conf"
# uncomment for php/fastcgi fpm support
   include "mod_fastcgi_fpm.conf"

# }}}

Edit lighttpd cgi config and add old style cgi support by adding to cgi.assign

vim /etc/lighttpd/mod_cgi.conf

which should look like

cgi.assign = (
    ""      =>      "",
    ".pl"   =>      "/usr/bin/perl",
    ".cgi"  =>      "/usr/bin/perl"
)

Start php-fpm

/etc/init.d/php-fpm start

Start lighttpd

/etc/init.d/lighttpd start

Set the MySQL hostname, username, password.

Change the ZoneMinder user (ZM_WEB_USER) and group (ZM_WEB_GROUP) to lighttpd

And set ZM_SERVER_HOST to your ZoneMinder hostname/ipaddress

vim /etc/zm.conf

Which should look like:

# Username and group that web daemon (httpd/apache) runs as
ZM_WEB_USER=lighttpd
ZM_WEB_GROUP=lighttpd
# ZoneMinder database type: so far only mysql is supported
ZM_DB_TYPE=mysql

# ZoneMinder database hostname or ip address
ZM_DB_HOST=localhost

# ZoneMinder database name
ZM_DB_NAME=zm

# ZoneMinder database user
ZM_DB_USER=zm

# ZoneMinder database password
ZM_DB_PASS=your_zm_password_as_set_in_config

# Host of this machine
ZM_SERVER_HOST=yourserver

Change ownership of zm.conf to lighttpd

chown lighttpd.lighttpd /etc/zm.conf

Initialize the ZoneMinder database

/etc/init.d/zoneminder setup

Start ZoneMinder

/etc/init.d/zoneminder start

Profit!

To access ZoneMinder, browse to http://yourserver/zm/

To make it start automatically on boot:

rc-update add lighttpd default
rc-update add mariadb default
rc-update add php-fpm default
rc-update add zoneminder default