Difference between revisions of "Debian 10 Buster with Zoneminder 1.36.x from ZM Repo"

From ZoneMinder Wiki
Jump to navigationJump to search
 
(41 intermediate revisions by 4 users not shown)
Line 1: Line 1:
== Debian 10 Buster with Zoneminder 1.32.3 from the Debian Multimedia Repository ==
__TOC__




Install Debian Buster. I used the net install CD and installed only SSH server and standard system utilities from tasksel.
'''Notice: These procedure are for a new install of Zoneminder 1.36.x on Debian 10 (Buster). If you are doing an upgrade I strongly recommend you check the Zoneminder-1.36 Forum area for recommendations from others.'''


You will need to install LAMP. One good guide to do this can be found here:
Debian, unlike Ubuntu, does not install sudo with the initial setup. While you can log in as root, a user with sudo authority is recommended.


  https://www.digitalocean.com/community/tutorials/how-to-install-linux-apache-mariadb-php-lamp-stack-on-debian-10
To enable sudo:
In a terminal,become root with su. Enter your root password.
Install sudo with:
  apt install sudo
Add the user account to the group sudo with:  
/sbin/adduser username sudo
where username is your user account.
Exit root then log out and then log in with the same user.


Install Zoneminder
Timezone: it is recommended you set your specific timesone with:
sudo timedatectl set-timezone America/New_York
Of course use your timezone in place of America/New_York.
 
Mariadb additional settings
The default values for the database are adequate for initial setup. However, I recommend you make these changes before installing Zoneminder:
Edit the Mariadb config file:
sudo nano /etc/mysql/mariadb.conf.d/50-server.cnf
Add the following in the [mysql] area:
innodb_file_per_table = ON
innodb_buffer_pool_ size = 256M
innodb_log_file_size - 32M
CTRL+o then [Enter] to save
 
CTRL+x to exit
 
Reatart Mariadb:
sudo service mysql restart
 
I recommend you install mysqltuner and run it from time to time and adjust the database settings as the number of saved events grows.
 
 
===Debian 10 Buster with Zoneminder 1.36.x from the ZM Release-1.36 Repo===
 
This install procedure was developed to use the Debian package developed by iconnor. This is from the 1.36 release version of Zoneminder.
 
'''Note: This is an install procedure for new installations! Upgraders are encouraged to search the Zoneminder Forum for upgrade information!'''
 
This procedure will work on a Raspberry Pi 3b+ and possibly other devices.
 
To begin, install Debian 10 (Buster) along with Apache2, PHP and your favorite database (Mariadb recommended). A quick way to do this is:
 
sudo apt install apache2 mariadb-server php libapache2-mod-php php-mysql
 
Then secure Mariadb
 
sudo mysql_secure_installation


Add the Deb Multimedia repository. (instructions at: https://deb-multimedia.org/)
(If you want more detailed instrunctions for a LAMP server see: https://www.digitalocean.com/community/tutorials/how-to-install-linux-apache-mariadb-php-lamp-stack-on-debian-10)


Edit sources.list
Add the repo


  sudo nano /etc/apt/sources.list
  sudo nano /etc/apt/sources.list


Add to the end of the file:
Add the following line to the end of the file
 
deb https://zmrepo.zoneminder.com/debian/release-1.36 buster/


deb http://www.deb-multimedia.org buster main non-free
CTRL+o then [Enter] to save


Ctrl+o Enter to save
CTRL+x to exit


Ctrl+x to exit
Install the following and retrieve the key from the repro


After you have added the necessary line in /etc/apt/sources.list the first package to install is deb-multimedia-keyring.
sudo apt install apt-transport-https gnupg


  wget http://www.deb-multimedia.org/pool/main/d/deb-multimedia-keyring/deb-multimedia-keyring_2016.8.1_all.deb
  wget -O - https://zmrepo.zoneminder.com/debian/archive-keyring.gpg | sudo apt-key add -


sudo dpkg -i deb-multimedia-keyring_2016.8.1_all.deb
'''Important - Make sure the above "wget" process completes without error! If it does not complete you will not get the most recent Zoneminder version this procedure is written for.'''


  sudo apt update
  sudo apt update
Line 34: Line 79:
Install Zoneminder
Install Zoneminder


  sudo apt install zoneminder vlc-plugin-base
  sudo apt install zoneminder
 
Create a new user if you plan to use local (USB or capture card) cameras.
 
sudo adduser www-data video
 
Enable and start Zoneminder
 
sudo systemctl enable zoneminder.service
sudo systemctl start zoneminder
 
Enable Apache Modules
 
sudo a2enconf zoneminder
sudo a2enmod rewrite
Restart Apache
 
sudo service apache2 reload
 
Remember to set your timezone in Zoneminder - Options
 
===Zoneminder 1.36.x on Buster LEMP (NGNIX, Mariadb, PHP)===
 
This procedure will work on a Raspberry Pi 3b+ and possibly other devices.


Thanks to "terdinglage" for the input to get this to work!


Create Zoneminder database in MySQL (Note: this also creates the default Zoneminder user and permissions in MySQL)
Start with a basic Buster install. You can use a server or desktop install. Do not install LAMP!


sudo mysql -uroot -p < /usr/share/zoneminder/db/zm_create.sql
Install Ngnix, Mariadb and PHP components


  sudo mysql -uroot -p -e "grant all on zm.* to 'zmuser'@localhost identified by 'zmpass';"
  sudo apt install nginx mariadb-server php-fpm php-mysql fcgiwrap


sudo mysqladmin -uroot -p reload
Secure the Mariadb server


Set permissions
sudo mysql_secure_installation


sudo chmod 740 /etc/zm/zm.conf
Restart Mariadb


  sudo chown root:www-data /etc/zm/zm.conf
  sudo systemctl restart mysql


sudo chown -R www-data:www-data /usr/share/zoneminder/
Edit the php.ini file


  sudo chown -R www-data:www-data /var/cache/zoneminder/
  sudo nano /etc/php/7.3/fpm/php.ini


Enable Zoneminder service to start at boot
Locate (Ctrl+w) cgi.fix_pathinfo=1 and change to


  sudo systemctl enable zoneminder.service
cgi.fix_pathinfo=0
 
Remember to remove the leading ;
 
Ctrl+o Enter to save
 
CTRL+x to exit
 
Restart php-fpm
 
  sudo systemctl restart php7.3-fpm
 
 
Add the repro
 
sudo nano /etc/apt/sources.list
 
Add the following line to the end of the file
 
deb https://zmrepo.zoneminder.com/debian/release-1.34 buster/


Add www-data to the sudo group (to enable use of local video devices)
CTRL+o then [Enter] to save


sudo adduser www-data video
CTRL+x to exit


Start Zoneminder
Install the following and retrieve the key from the repro


  sudo systemctl start zoneminder.service
  sudo apt install apt-transport-https gnupg


Check to see that Zoneminder is running
wget -O - https://zmrepo.zoneminder.com/debian/archive-keyring.gpg | sudo apt-key add -


sudo systemctl status zoneminder.service
'''Important - Make sure the above "wget" process completes without error! If it does not complete you will not get the most recent Zoneminder version this procedure is written for.'''


Enable CGI and Zoneminder configuration in Apache.
sudo apt update


sudo a2enmod cgi
Install Zoneminder


  sudo a2enmod rewrite
  sudo apt install zoneminder


sudo a2enconf zoneminder
Create a new user if you plan to use local (USB or capture card) cameras.


Add timezone to PHP
sudo adduser www-data video


sudo nano /etc/php/7.3/apache2/php.ini


Search for [Date] (Ctrl + w then type Date and press Enter) and make changes as follows for your time zone
Change the ZM_PATH_ZMS in the 01-system-paths.conf file to /cgi-bin/nph-zms by dropping the /zm/


  [Date]
  sudo nano /etc/zm/conf.d/01-system-paths.conf
; Defines the default timezone used by the date functions
; http://php.net/date.timezone
date.timezone = America/New_York


Ctrl+o Enter to save
Ctrl+o Enter to save
Line 94: Line 179:
CTRL+x to exit  
CTRL+x to exit  


'''Note: 20JUL19 - A fix for the below was submitted to deb-multimedia but the fix has errors in it.'''
Enable and start Zoneminder
 
  sudo systemctl enable zoneminder


You need to Edit zoneminder.conf.
sudo service zoneminder start


First make a copy of zoneminder.conf


sudo cp /etc/apache2/conf-enabled/zoneminder.conf /etc/apache2/conf-enabled/zoneminder.sav
Edit the Ngnix default configuration.  


Next, edit the file
sudo nano /etc/nginx/sites-available/default


sudo nano /etc/apache2/conf-enabled/zoneminder.conf
Locate the line "index index.html index.htm index.nginx-debian.html;" and add index.php


Replace the contents with:
index index.php index.html index.htm index.nginx-debian.html;


# Remember to enable cgi mod (i.e. "a2enmod cgi").
In the "server" section after listen [::] :80 default_Server; add


    # Order matters. This alias must come first.
include /etc/nginx/zoneminder.conf;
    Alias /zm/cache /var/cache/zoneminder
    <Directory /var/cache/zoneminder>
        Options -Indexes +FollowSymLinks
        AllowOverride None
        <IfModule mod_authz_core.c>
          # Apache 2.4
          Require all granted
        </IfModule>
        <IfModule !mod_authz_core.c>
            # Apache 2.2
            Order deny,allow
            Allow from all
        </IfModule>
    </Directory>


    Alias /zm /usr/share/zoneminder/www
Ctrl+o Enter to save
    <Directory /usr/share/zoneminder/www>
        Options -Indexes +FollowSymLinks
        AllowOverride All
        <IfModule mod_authz_core.c>
          # Apache 2.4
          Require all granted
        </IfModule>
        <IfModule !mod_authz_core.c>
            # Apache 2.2
            Order deny,allow
            Allow from all
        </IfModule>
    </Directory>


    ScriptAlias /cgi-bin /usr/lib/zoneminder/cgi-bin
CTRL+x to exit
    <Directory /usr/lib/zoneminder/cgi-bin>
        Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
        AllowOverride All
        <IfModule mod_authz_core.c>
          # Apache 2.4
          Require all granted
        </IfModule>
        <IfModule !mod_authz_core.c>
            # Apache 2.2
            Order deny,allow
            Allow from all
        </IfModule>
    </Directory>


    # For better visibility, the following directives have been migrated from the
Create a Zoneminder conf file
    # default .htaccess files included with the CakePHP project.
    # Parameters not set here are inherited from the parent directive above.
    <Directory /usr/share/zoneminder/www/api>
      RewriteEngine on
      RewriteRule ^$ app/webroot/ [L]
      RewriteRule (.*) app/webroot/$1 [L]
      RewriteBase /zm/api
    </Directory>


    <Directory /usr/share/zoneminder/www/api/app>
sudo nano /etc/nginx/zoneminder.conf
      RewriteEngine on
      RewriteRule ^$ webroot/ [L]
      RewriteRule (.*) webroot/$1 [L]
      RewriteBase /zm/api
    </Directory>


    <Directory /usr/share/zoneminder/www/api/app/webroot>
Enter the following into the zoneminder.conf file (This file was improved by databoy2k)
        RewriteEngine On
        RewriteCond %{REQUEST_FILENAME} !-d
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteRule ^ index.php [L]
        RewriteBase /zm/api
    </Directory>


     # Use the first option to have Apache logs written to the general log
location /cgi-bin {
    # directory, or the second to have them written to the regular Apache
auth_basic off;
    # directory (you may have to change the path to that used on your system)
        alias /usr/lib/zoneminder/cgi-bin;      
    #ErrorLog @ZM_LOGDIR@/apache-error.log
        include fastcgi_params;
    ErrorLog /var/log/apache2/zm-error.log
        fastcgi_param SCRIPT_FILENAME $request_filename;
        fastcgi_param HTTP_PROXY "";
        fastcgi_pass unix:/var/run/fcgiwrap.socket;
}
location /zm/cache {
auth_basic off;
        alias /var/cache/zoneminder/cache;
}
location ~ /zm/api/(css|img|ico) {
auth_basic off;
        rewrite ^/zm/api(.+)$ /api/app/webroot/$1 break;
        try_files $uri $uri/ =404;
}
location /zm {
auth_basic off;
        alias /usr/share/zoneminder/www;
        try_files $uri $uri/ /index.php?$args =404;   
        location /zm/api {
auth_basic off;
                rewrite ^/zm/api(.+)$ /zm/api/app/webroot/index.php?p=$1 last;
          }
                location ~ \.php$ {
                auth_basic off;
                        include fastcgi_params;
                        fastcgi_param SCRIPT_FILENAME $request_filename;
                        fastcgi_param HTTP_PROXY "";
                fastcgi_index index.php;
                        fastcgi_pass unix:/var/run/php/php7.3-fpm.sock;
        }
    }


    # Possible values include: debug, info, notice, warn, error, crit,
Ctrl+o Enter to save
    # alert, emerg.
    LogLevel warn


    # Use the first option to have Apache logs written to the general log
CTRL+x to exit
    # directory, or the second to have them written to the regular Apache
    # directory (you may have to change the path to that used on your system)
    #CustomLog @ZM_LOGDIR@/apache-access.log combined
    CustomLog /var/log/apache2/zm-access.log combined


Restart Ngnix
sudo service nginx restart
Note: If Nginx gives you an error on restart go back one step and re-enter include /etc/ngnix/zoneminder.conf;
If it does not exist create
sudo nano /etc/default/fcgiwrap
and insert (with the number of children -c equal to the number of cameras) Note that you may need to have this value larger than the number if cameras. In my case I run "camera walls" from a custom web page that accesses the Zoneminder monitors. I have needed to increase the -c to include the number of cameras in the camera wall web pages.
DAEMON_OPTS=-c 10


Ctrl+o Enter to save
Ctrl+o Enter to save
Line 202: Line 265:
CTRL+x to exit  
CTRL+x to exit  


Restart Apache
then restart the fcgiwrap service.


  sudo service apache2 restart
  sudo systemctl restart fcgiwrap


All done! Navigate to http://serverip/zm
Open Zoneminder and under Options set your timezone.

Latest revision as of 12:51, 28 September 2021


Notice: These procedure are for a new install of Zoneminder 1.36.x on Debian 10 (Buster). If you are doing an upgrade I strongly recommend you check the Zoneminder-1.36 Forum area for recommendations from others.

Debian, unlike Ubuntu, does not install sudo with the initial setup. While you can log in as root, a user with sudo authority is recommended.

To enable sudo: In a terminal,become root with su. Enter your root password. Install sudo with:

apt install sudo

Add the user account to the group sudo with:

/sbin/adduser username sudo 

where username is your user account. Exit root then log out and then log in with the same user.

Timezone: it is recommended you set your specific timesone with:

sudo timedatectl set-timezone America/New_York

Of course use your timezone in place of America/New_York.

Mariadb additional settings The default values for the database are adequate for initial setup. However, I recommend you make these changes before installing Zoneminder: Edit the Mariadb config file:

sudo nano /etc/mysql/mariadb.conf.d/50-server.cnf

Add the following in the [mysql] area:

innodb_file_per_table = ON
innodb_buffer_pool_ size = 256M
innodb_log_file_size - 32M

CTRL+o then [Enter] to save

CTRL+x to exit

Reatart Mariadb:

sudo service mysql restart

I recommend you install mysqltuner and run it from time to time and adjust the database settings as the number of saved events grows.


Debian 10 Buster with Zoneminder 1.36.x from the ZM Release-1.36 Repo

This install procedure was developed to use the Debian package developed by iconnor. This is from the 1.36 release version of Zoneminder.

Note: This is an install procedure for new installations! Upgraders are encouraged to search the Zoneminder Forum for upgrade information!

This procedure will work on a Raspberry Pi 3b+ and possibly other devices.

To begin, install Debian 10 (Buster) along with Apache2, PHP and your favorite database (Mariadb recommended). A quick way to do this is:

sudo apt install apache2 mariadb-server php libapache2-mod-php php-mysql

Then secure Mariadb

sudo mysql_secure_installation

(If you want more detailed instrunctions for a LAMP server see: https://www.digitalocean.com/community/tutorials/how-to-install-linux-apache-mariadb-php-lamp-stack-on-debian-10)

Add the repo

sudo nano /etc/apt/sources.list

Add the following line to the end of the file

deb https://zmrepo.zoneminder.com/debian/release-1.36 buster/

CTRL+o then [Enter] to save

CTRL+x to exit

Install the following and retrieve the key from the repro

sudo apt install apt-transport-https gnupg
wget -O - https://zmrepo.zoneminder.com/debian/archive-keyring.gpg | sudo apt-key add -

Important - Make sure the above "wget" process completes without error! If it does not complete you will not get the most recent Zoneminder version this procedure is written for.

sudo apt update

Install Zoneminder

sudo apt install zoneminder

Create a new user if you plan to use local (USB or capture card) cameras.

sudo adduser www-data video

Enable and start Zoneminder

sudo systemctl enable zoneminder.service
sudo systemctl start zoneminder 

Enable Apache Modules

sudo a2enconf zoneminder
sudo a2enmod rewrite

Restart Apache

sudo service apache2 reload

Remember to set your timezone in Zoneminder - Options

Zoneminder 1.36.x on Buster LEMP (NGNIX, Mariadb, PHP)

This procedure will work on a Raspberry Pi 3b+ and possibly other devices.

Thanks to "terdinglage" for the input to get this to work!

Start with a basic Buster install. You can use a server or desktop install. Do not install LAMP!

Install Ngnix, Mariadb and PHP components

sudo apt install nginx mariadb-server php-fpm php-mysql fcgiwrap

Secure the Mariadb server

sudo mysql_secure_installation

Restart Mariadb

sudo systemctl restart mysql

Edit the php.ini file

sudo nano /etc/php/7.3/fpm/php.ini

Locate (Ctrl+w) cgi.fix_pathinfo=1 and change to

cgi.fix_pathinfo=0

Remember to remove the leading ;

Ctrl+o Enter to save

CTRL+x to exit

Restart php-fpm

sudo systemctl restart php7.3-fpm


Add the repro

sudo nano /etc/apt/sources.list

Add the following line to the end of the file

deb https://zmrepo.zoneminder.com/debian/release-1.34 buster/

CTRL+o then [Enter] to save

CTRL+x to exit

Install the following and retrieve the key from the repro

sudo apt install apt-transport-https gnupg
wget -O - https://zmrepo.zoneminder.com/debian/archive-keyring.gpg | sudo apt-key add -

Important - Make sure the above "wget" process completes without error! If it does not complete you will not get the most recent Zoneminder version this procedure is written for.

sudo apt update

Install Zoneminder

sudo apt install zoneminder

Create a new user if you plan to use local (USB or capture card) cameras.

sudo adduser www-data video


Change the ZM_PATH_ZMS in the 01-system-paths.conf file to /cgi-bin/nph-zms by dropping the /zm/

sudo nano /etc/zm/conf.d/01-system-paths.conf

Ctrl+o Enter to save

CTRL+x to exit

Enable and start Zoneminder

sudo systemctl enable zoneminder
sudo service zoneminder start


Edit the Ngnix default configuration.

sudo nano /etc/nginx/sites-available/default

Locate the line "index index.html index.htm index.nginx-debian.html;" and add index.php

index index.php index.html index.htm index.nginx-debian.html;

In the "server" section after listen [::] :80 default_Server; add

include /etc/nginx/zoneminder.conf;

Ctrl+o Enter to save

CTRL+x to exit

Create a Zoneminder conf file

sudo nano /etc/nginx/zoneminder.conf

Enter the following into the zoneminder.conf file (This file was improved by databoy2k)

location /cgi-bin {
auth_basic off;
        alias /usr/lib/zoneminder/cgi-bin;     
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $request_filename;
        fastcgi_param HTTP_PROXY "";
        fastcgi_pass unix:/var/run/fcgiwrap.socket;
}
location /zm/cache {
auth_basic off;
        alias /var/cache/zoneminder/cache;
}
location ~ /zm/api/(css|img|ico) {
auth_basic off;
        rewrite ^/zm/api(.+)$ /api/app/webroot/$1 break;
        try_files $uri $uri/ =404;
}
location /zm {
auth_basic off;
        alias /usr/share/zoneminder/www;
        try_files $uri $uri/ /index.php?$args =404;    
        location /zm/api {
auth_basic off;
                rewrite ^/zm/api(.+)$ /zm/api/app/webroot/index.php?p=$1 last;
         }
                location ~ \.php$ {
                auth_basic off;
                        include fastcgi_params;
                        fastcgi_param SCRIPT_FILENAME $request_filename;
                        fastcgi_param HTTP_PROXY "";
                fastcgi_index index.php;
                        fastcgi_pass unix:/var/run/php/php7.3-fpm.sock;
        }
    }

Ctrl+o Enter to save

CTRL+x to exit

Restart Ngnix

sudo service nginx restart

Note: If Nginx gives you an error on restart go back one step and re-enter include /etc/ngnix/zoneminder.conf;

If it does not exist create

sudo nano /etc/default/fcgiwrap

and insert (with the number of children -c equal to the number of cameras) Note that you may need to have this value larger than the number if cameras. In my case I run "camera walls" from a custom web page that accesses the Zoneminder monitors. I have needed to increase the -c to include the number of cameras in the camera wall web pages.

DAEMON_OPTS=-c 10

Ctrl+o Enter to save

CTRL+x to exit

then restart the fcgiwrap service.

sudo systemctl restart fcgiwrap

Open Zoneminder and under Options set your timezone.