Difference between revisions of "Debian 11 Bullseye with Zoneminder 1.36.x"

From ZoneMinder Wiki
Jump to navigationJump to search
 
(33 intermediate revisions by 4 users not shown)
Line 1: Line 1:
Updated 23AUG16 for Debian 8.5
Updated 19MAR23


This easy install is for Debian 8 (Jessie) with Zoneminder 1.29.0 from the back ports install.
__TOC__


I installed Debian from the netinst CD with only web server, SSH server and standard system utilities. Tasksel does not install LAMP under Debian so I installed MySQL and PHP after reboot.
==Debian 11 with Zoneminder 1.36.x==
Debian 11 Bullseye is being released with Zoneminder 1.34.23 and as usual for Debian the zm database needs to be created manually. This is not user friendly and 1.34 is considered old and unsupported.  So we will be using the packages provided by the ZoneMinder development team hosted at zmrepo.zoneminder.com.  


Log in as your user
Note: We currently only package for amd64 and armhf so if your are running something else this won't work. 


Then become root
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.


  sudo root
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 PHP, and MySQL server. You will be prompted to set a MySQL password
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.


apt-get install php5 mysql-server php-pear php5-mysql php5-gd
1. Install Debian 11 (Bullseye), desktop or server version, along with Apache2, PHP and your favorite database (Mariadb recommended). A quick way to install LAMP is:


Note: you may want to set MySQL to use innodb_file_per_table. Here is a procedure for Ubuntu that should also work for Debian: https://wiki.zoneminder.com/Common_Issues_with_Zoneminder_Installation_on_Ubuntu#Enable_and_convert_MySQL_to_innodb_file_per_table_for_Zoneminder
  sudo apt install apache2 mariadb-server php libapache2-mod-php php-mysql lsb-release gnupg2


Add the Jessie backports
Secure MySQL or Mariadb, create root password et. al.


  nano /etc/apt/sources.list
  mysql_secure_installation


Add to the bottom of the list:
Mariadb additional settings The default values for the database are adequate for initial setup. However, I recommend you make these changes before installing Zoneminder. Note: If you have sufficient memory double the values below. Edit the Mariadb config file:


  deb http://ftp.debian.org/debian jessie-backports main
  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 = 64M
 
CTRL+o then [Enter] to save


Ctrl+o Enter to save
CTRL+x to exit
CTRL+x to exit


Update Sources
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.
_________________________________________________________________________________________________________________________________________
 
New install process with a shell script!
 
Become root with sudo su before running this!
 
Shell script file contents:
 
#!/bin/sh
clear
read -p "This script installs ZoneMinder 1.36.x on Debian 11 with LAMP (MySQL or Mariadb) installed...
This script must be run as root!
Press Enter to continue or Ctrl + c to quit" nothing
clear
apt install -y lsb-release gnupg2
echo "deb https://zmrepo.zoneminder.com/debian/release-1.36 "`lsb_release  -c -s`"/" | sudo tee /etc/apt/sources.list.d/zoneminder.list
wget -O - https://zmrepo.zoneminder.com/debian/archive-keyring.gpg | sudo apt-key add -
read -p "Warning! Check above to insure the line says OK. If not the GPG signing key was not installed and you will need to figure out why before continuing.
Press enter to continue" nothing
apt update
clear
apt install -y zoneminder
systemctl enable zoneminder
service zoneminder start
adduser www-data video
a2enconf zoneminder
a2enmod rewrite
a2enmod headers
a2enmod expires
service apache2 reload
clear
read -p "Install complete. Open Zoneminder/Options and set the timezone. Press enter to continue" nothing
clear
 
 
Copy the contents of the script, open a terminal and run:
 
nano zm-install
 
Paste the contents of the script into Nano
 
Then:
 
Ctrl + o Ctrl + x
 
Next run:
 
chmod 755 zm-install
 
Start the script by entering:
 
./zm-install
 
Follow the prompts. Things are pretty simple. The timezone is now set in Zoneminder/Options.
 
Good Luck!
 
__________________________________________________________________________________________________________________________________________
 
Old procedure retained for reference
 
2. Add Zoneminder's repo to your APT configuration:
 
echo "deb https://zmrepo.zoneminder.com/debian/release-1.36 "`lsb_release  -c -s`"/" | sudo tee /etc/apt/sources.list.d/zoneminder.list
 
3. Add Zoneminder's GPG signing key:
 
wget -O - https://zmrepo.zoneminder.com/debian/archive-keyring.gpg | sudo apt-key add -
 
4. Update package indexes and install the package
 
sudo apt update
 
sudo apt install zoneminder=1.36.31-bullseye1
 
5. Enable the systemd service and apache configuration


  apt-get update
  sudo systemctl enable zoneminder.service
sudo systemctl start zoneminder
sudo a2enconf zoneminder
sudo a2enmod rewrite headers expires
sudo service apache2 reload


Check to be sure everything is up to date
6. Open Zoneminder http://(IP-Address)/zm


apt-get upgrade
7. Change the Timezone in Options-Timezone
---------------------------------------------------------------------------------------------
==Debian 11 with NGINX and Zoneminder 1.36.x==


apt-get dist-upgrade
Start with a basic Debian 11 install. You can use a server or desktop install. Do not install LAMP!


Install Zoneminder
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.
Become root
 
sudo su
 
Install Ngnix, Mariadb and PHP components
 
apt install nginx mariadb-server php-fpm php-mysql fcgiwrap
 
Secure the Mariadb server
 
mysql_secure_installation


apt-get install zoneminder
Restart Mariadb


or (if the above does not work)
systemctl restart mysql


apt-get -t jessie-backports install zoneminder
Edit the php.ini file (Change the PHP version as needed)


nano /etc/php/7.4/fpm/php.ini


Create Zoneminder database in MySQL (Note: this also creates the default Zoneminder user and permissions in MySQL)
Locate (Ctrl+w) cgi.fix_pathinfo=1 and change to


  mysql -uroot -p < /usr/share/zoneminder/db/zm_create.sql
  cgi.fix_pathinfo=0


mysql -uroot -p -e "grant all on zm.* to 'zmuser'@localhost identified by 'zmpass';"
Remember to remove the leading ;


mysqladmin -uroot -p reload
Ctrl+o Enter to save


Set permissions of /etc/zm/zm.conf to root:www-data 740
CTRL+x to exit


chmod 740 /etc/zm/zm.conf
Restart php-fpm
chown root:www-data /etc/zm/zm.conf


Enable Zoneminder service to start at boot
systemctl restart php7.4-fpm


systemctl enable zoneminder.service


Add www-data to the sudo group (to enable use of local video devices)
Add Repository


  adduser www-data video
  apt install -y lsb-release gnupg2


Start Zoneminder
echo "deb https://zmrepo.zoneminder.com/debian/release-1.36 "`lsb_release  -c -s`"/" | sudo tee /etc/apt/sources.list.d/zoneminder.list


  systemctl start zoneminder.service
  wget -O - https://zmrepo.zoneminder.com/debian/archive-keyring.gpg | sudo apt-key add -


Check to see that Zoneminder is running
"Warning! Check above to insure the line says OK. If not the GPG signing key was not installed and you will need to figure out why before continuing.


  systemctl status zoneminder.service
  apt update


Enable CGI and Zoneminder configuration in Apache.
Install Zoneminder
a2enmod cgi


  a2enmod rewrite
  apt install zoneminder
a2enconf zoneminder


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


  nano /etc/php5/apache2/php.ini
  adduser www-data video


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]
  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


CTRL+x to exit  
CTRL+x to exit
 
Enable and start Zoneminder
 
systemctl enable zoneminder


27FEB16 A problem has been cited that requires the following to allow the API to work properly:
service zoneminder start


Change permissions in /usr/share/zoneminder/


chown -R www-data:www-data /usr/share/zoneminder/
Edit the Ngnix default configuration.


Edit /etc/apache2/conf-enabled/zoneminder.conf
nano /etc/nginx/sites-available/default


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


Add at the bottom:
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;


<Directory /usr/share/zoneminder/www/api>
    AllowOverride All
</Directory>


Ctrl+o Enter to save
Ctrl+o Enter to save


CTRL+x to exit  
CTRL+x to exit
 
Create a Zoneminder conf file
 
nano /etc/nginx/zoneminder.conf


Note that if you are using the API and If you alter the ZM mysql db password from the default then you must specify the new password. This file is located at
Enter the following into the zoneminder.conf file (This file was improved by databoy2k) Change "php7.4-fpm.sock" to as neeeded.
/usr/share/zoneminder/www/api/app/Config/database.php per [https://forums.zoneminder.com/viewtopic.php?f=32&t=23665 this post]


Restart Apache
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.4-fpm.sock;
        }
    }


service apache2 restart
Ctrl+o Enter to save


Optional: Install Cambozola (needed if you use old versions of Internet Explorer)
CTRL+x to exit
Note: Cambozola requires Java Runtime Environement which many consider a security risk.


cd /usr/src && wget http://www.andywilcock.com/code/cambozola/cambozola-latest.tar.gz
Restart Ngnix


  tar -xzvf cambozola-latest.tar.gz
  service nginx restart


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


cp cambozola-0.936/dist/cambozola.jar /usr/share/zoneminder
Create or edit the fcgiwrap:


You should now be able to access the web server using http://servername
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.


Open Zoneminder in web browser
DAEMON_OPTS=-c 10


http://serverip/zm
Ctrl+o Enter to save


Optional:Click Options, check Is the (optional) cambozola java streaming client installed (?) Click Save
CTRL+x to exit


Your Zoneminder install is now ready to add cameras!
then restart the fcgiwrap service.


For a slight performance boost use 32 bit colour in camera settings.
systemctl restart fcgiwrap

Latest revision as of 18:58, 19 March 2023

Updated 19MAR23

Debian 11 with Zoneminder 1.36.x

Debian 11 Bullseye is being released with Zoneminder 1.34.23 and as usual for Debian the zm database needs to be created manually. This is not user friendly and 1.34 is considered old and unsupported. So we will be using the packages provided by the ZoneMinder development team hosted at zmrepo.zoneminder.com.

Note: We currently only package for amd64 and armhf so if your are running something else this won't work.

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.

1. Install Debian 11 (Bullseye), desktop or server version, along with Apache2, PHP and your favorite database (Mariadb recommended). A quick way to install LAMP is:

sudo apt install apache2 mariadb-server php libapache2-mod-php php-mysql lsb-release gnupg2

Secure MySQL or Mariadb, create root password et. al.

mysql_secure_installation

Mariadb additional settings The default values for the database are adequate for initial setup. However, I recommend you make these changes before installing Zoneminder. Note: If you have sufficient memory double the values below. 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 = 64M

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. _________________________________________________________________________________________________________________________________________

New install process with a shell script!

Become root with sudo su before running this!

Shell script file contents:

#!/bin/sh
clear
read -p "This script installs ZoneMinder 1.36.x on Debian 11 with LAMP (MySQL or Mariadb) installed...
This script must be run as root!
Press Enter to continue or Ctrl + c to quit" nothing
clear
apt install -y lsb-release gnupg2
echo "deb https://zmrepo.zoneminder.com/debian/release-1.36 "`lsb_release  -c -s`"/" | sudo tee /etc/apt/sources.list.d/zoneminder.list
wget -O - https://zmrepo.zoneminder.com/debian/archive-keyring.gpg | sudo apt-key add -
read -p "Warning! Check above to insure the line says OK. If not the GPG signing key was not installed and you will need to figure out why before continuing. 
Press enter to continue" nothing
apt update
clear
apt install -y zoneminder
systemctl enable zoneminder
service zoneminder start
adduser www-data video
a2enconf zoneminder
a2enmod rewrite
a2enmod headers
a2enmod expires
service apache2 reload
clear
read -p "Install complete. Open Zoneminder/Options and set the timezone. Press enter to continue" nothing
clear


Copy the contents of the script, open a terminal and run:

nano zm-install

Paste the contents of the script into Nano

Then:

Ctrl + o Ctrl + x

Next run:

chmod 755 zm-install

Start the script by entering:

./zm-install

Follow the prompts. Things are pretty simple. The timezone is now set in Zoneminder/Options.

Good Luck!

__________________________________________________________________________________________________________________________________________

Old procedure retained for reference

2. Add Zoneminder's repo to your APT configuration:

echo "deb https://zmrepo.zoneminder.com/debian/release-1.36 "`lsb_release  -c -s`"/" | sudo tee /etc/apt/sources.list.d/zoneminder.list

3. Add Zoneminder's GPG signing key:

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

4. Update package indexes and install the package

sudo apt update 
sudo apt install zoneminder=1.36.31-bullseye1

5. Enable the systemd service and apache configuration

sudo systemctl enable zoneminder.service
sudo systemctl start zoneminder
sudo a2enconf zoneminder
sudo a2enmod rewrite headers expires
sudo service apache2 reload

6. Open Zoneminder http://(IP-Address)/zm

7. Change the Timezone in Options-Timezone


Debian 11 with NGINX and Zoneminder 1.36.x

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

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. Become root

sudo su

Install Ngnix, Mariadb and PHP components

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

Secure the Mariadb server

mysql_secure_installation

Restart Mariadb

systemctl restart mysql

Edit the php.ini file (Change the PHP version as needed)

nano /etc/php/7.4/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

systemctl restart php7.4-fpm


Add Repository

apt install -y lsb-release gnupg2
echo "deb https://zmrepo.zoneminder.com/debian/release-1.36 "`lsb_release  -c -s`"/" | sudo tee /etc/apt/sources.list.d/zoneminder.list
wget -O - https://zmrepo.zoneminder.com/debian/archive-keyring.gpg | sudo apt-key add -

"Warning! Check above to insure the line says OK. If not the GPG signing key was not installed and you will need to figure out why before continuing.

apt update

Install Zoneminder

apt install zoneminder

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

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/

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

Ctrl+o Enter to save

CTRL+x to exit

Enable and start Zoneminder

systemctl enable zoneminder
service zoneminder start


Edit the Ngnix default configuration.

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

nano /etc/nginx/zoneminder.conf

Enter the following into the zoneminder.conf file (This file was improved by databoy2k) Change "php7.4-fpm.sock" to as neeeded.

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.4-fpm.sock;
        }
    }

Ctrl+o Enter to save

CTRL+x to exit

Restart Ngnix

service nginx restart

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

Create or edit the fcgiwrap:

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.

systemctl restart fcgiwrap