Difference between revisions of "Debian 12 Bookworm with Zoneminder 1.36.33"

From ZoneMinder Wiki
Jump to navigationJump to search
Line 1: Line 1:
Debian 12 Bookworm is being released with Zoneminder 1.36.33 and as usual for Debian the zm database needs to be created manually.
Debian 12 Bookworm is being released with Zoneminder 1.36.33 and as usual for Debian the zm database needs to be created manually.


'''Note: This is an initial version done with Bookworm RC4. I am able to get a cam to stream and capture but several other things do not work such as the API. I will work more with this after the official release.'''
'''Note: This is an initial version done with Bookworm RC4. I am able to get a cam to stream and capture and have gotten the API's to work. If using ZmNinja you may have to clear the API cache.'''


In Bookworm sudo is installed with the desktop version but you will have to install sudo with the server version and add the user to the sudoers file.  
In Bookworm sudo is installed with the desktop version but you will have to install sudo with the server version and add the user to the sudoers file.  
Become root with  
Become root with  


Line 24: Line 25:
Install Apache2, PHP and your favorite database (Mariadb recommended). A quick way to install LAMP is:  
Install Apache2, PHP and your favorite database (Mariadb recommended). A quick way to install LAMP is:  


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


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


  mysql_secure_installation
  mysql_secure_installation
Add timezone to PHP (This may not be necessary but dies not hurt and will allow the time of events to be displayed correctly)
nano /etc/php/8.2/apache2/php.ini
Search for [Date] (Ctrl + w then type Date and press Enter) and make changes as follows for your time zone
[Date]
; 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+x to exit
Restart Apache
service apache2 restart


Install Zoneminder
Install Zoneminder
Line 34: Line 54:
  apt install zoneminder
  apt install zoneminder


 
Create Zoneminder database in MySQL (Note: this also creates the default Zoneminder user and permissions in MySQL) Use the database password when prompted.
Create Zoneminder database in MySQL (Note: this also creates the default Zoneminder user and permissions in MySQL)


  mysql -uroot -p < /usr/share/zoneminder/db/zm_create.sql
  mysql -uroot -p < /usr/share/zoneminder/db/zm_create.sql
Line 43: Line 62:
  mysqladmin -uroot -p reload
  mysqladmin -uroot -p reload


Set permissions of /etc/zm/zm.conf to root:www-data 740
Set permissions  


  chmod 740 /etc/zm/zm.conf
  chmod 640 /etc/zm/zm.conf
chown root:www-data /etc/zm/zm.conf
chown -R www-data:www-data /var/cache/zoneminder/
chmod 755 /var/cache/zoneminder/


chown root:www-data /etc/zm/zm.conf
Replace zoneminder.conf


  chown -R www-data:www-data /usr/share/zoneminder/
  nano /etc/apache2/conf-available/zoneminder.conf


chown -R www-data:www-data /var/cache/zoneminder/
use the following content


# Remember to enable cgi mod (i.e. "a2enmod cgi").
ScriptAlias /zm/cgi-bin "/usr/lib/zoneminder/cgi-bin"
<Directory "/usr/lib/zoneminder/cgi-bin">
    Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
    AllowOverride All
    Require all granted
</Directory>
# Order matters. This alias must come first.
Alias /zm/cache /var/cache/zoneminder/cache
<Directory /var/cache/zoneminder/cache>
    Options -Indexes +FollowSymLinks
    AllowOverride None
    <IfModule mod_authz_core.c>
        # Apache 2.4
        Require all granted
    </IfModule>
</Directory>
Alias /zm /usr/share/zoneminder/www
<Directory /usr/share/zoneminder/www>
  Options -Indexes +FollowSymLinks
  <IfModule mod_dir.c>
    DirectoryIndex index.php
  </IfModule>
</Directory>
# For better visibility, the following directives have been migrated from the
# 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">
    RewriteEngine on
    RewriteRule ^$ webroot/ [L]
    RewriteRule (.*) webroot/$1 [L]
    RewriteBase /zm/api
</Directory>
<Directory "/usr/share/zoneminder/www/api/app/webroot">
    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ index.php [L]
    RewriteBase /zm/api
</Directory>
Enable Zoneminder service to start at boot
Enable Zoneminder service to start at boot


Line 68: Line 143:


  a2enconf zoneminder
  a2enconf zoneminder
a2enmod cgi
  a2enmod rewrite
  a2enmod rewrite
  a2enmod headers
  a2enmod headers
Line 74: Line 148:
  service apache2 reload
  service apache2 reload


Install complete. Open Zoneminder/Options and set the timezone
Install complete. Open Zoneminder/Options and set the timezone in Options/System. Add cameras.
 
 
API Fix: https://jabriffa.wordpress.com/2022/09/22/fixing-zoneminder-and-zmninja-on-upgrade-to-ubuntu-22-04-lts/

Revision as of 15:27, 9 June 2023

Debian 12 Bookworm is being released with Zoneminder 1.36.33 and as usual for Debian the zm database needs to be created manually.

Note: This is an initial version done with Bookworm RC4. I am able to get a cam to stream and capture and have gotten the API's to work. If using ZmNinja you may have to clear the API cache.

In Bookworm sudo is installed with the desktop version but you will have to install sudo with the server version and add the user to the sudoers file.

Become root with

su

Install sudo

apt install sudo

Then add the user

/sbin/adduser username sudo 

I recommend rebooting at this point

Become root

sudo su

Install Apache2, PHP and your favorite database (Mariadb recommended). A quick way to install LAMP is:

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

Add timezone to PHP (This may not be necessary but dies not hurt and will allow the time of events to be displayed correctly)

nano /etc/php/8.2/apache2/php.ini

Search for [Date] (Ctrl + w then type Date and press Enter) and make changes as follows for your time zone

[Date]
; 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+x to exit

Restart Apache

service apache2 restart

Install Zoneminder

apt install zoneminder

Create Zoneminder database in MySQL (Note: this also creates the default Zoneminder user and permissions in MySQL) Use the database password when prompted.

mysql -uroot -p < /usr/share/zoneminder/db/zm_create.sql
mysql -uroot -p -e "grant all on zm.* to 'zmuser'@localhost identified by 'zmpass';"
mysqladmin -uroot -p reload

Set permissions

chmod 640 /etc/zm/zm.conf
chown root:www-data /etc/zm/zm.conf
chown -R www-data:www-data /var/cache/zoneminder/
chmod 755 /var/cache/zoneminder/

Replace zoneminder.conf

nano /etc/apache2/conf-available/zoneminder.conf

use the following content

# Remember to enable cgi mod (i.e. "a2enmod cgi").
ScriptAlias /zm/cgi-bin "/usr/lib/zoneminder/cgi-bin"
<Directory "/usr/lib/zoneminder/cgi-bin">
    Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
    AllowOverride All
    Require all granted
</Directory>


# Order matters. This alias must come first.
Alias /zm/cache /var/cache/zoneminder/cache
<Directory /var/cache/zoneminder/cache>
    Options -Indexes +FollowSymLinks
    AllowOverride None
    <IfModule mod_authz_core.c>
        # Apache 2.4
        Require all granted
    </IfModule>
</Directory>

Alias /zm /usr/share/zoneminder/www
<Directory /usr/share/zoneminder/www>
  Options -Indexes +FollowSymLinks
  <IfModule mod_dir.c>
    DirectoryIndex index.php
  </IfModule>
</Directory>

# For better visibility, the following directives have been migrated from the
# 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">
   RewriteEngine on
   RewriteRule ^$ webroot/ [L]
   RewriteRule (.*) webroot/$1 [L]
   RewriteBase /zm/api
</Directory>

<Directory "/usr/share/zoneminder/www/api/app/webroot">
    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ index.php [L]
    RewriteBase /zm/api
</Directory>

Enable Zoneminder service to start at boot

systemctl enable zoneminder.service

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

adduser www-data video

Start Zoneminder

systemctl start zoneminder.service

Enable Zoneminder configuration in Apache.

a2enconf zoneminder
a2enmod rewrite
a2enmod headers
a2enmod expires
service apache2 reload

Install complete. Open Zoneminder/Options and set the timezone in Options/System. Add cameras.