Lost config with distro and zm version upgrade

Discussions related to the 1.36.x series of ZoneMinder
cookiemonster
Posts: 52
Joined: Sat Aug 15, 2015 1:46 pm

Re: Lost config with distro and zm version upgrade

Post by cookiemonster »

The small thumbnails in the console have only a placeholder. The browser's dev tools show is due to http 404

Code: Select all

http://192.168.5.176/zm/cgi-bin/nph-zms?scale=33&mode=jpeg&maxfps=30&buffer=4&monitor=1&rand=1745531031&connkey=219686
But the link is valid, so I must still have a config to fix.

Code: Select all

penguin@venus:/$ ls -alh /usr/lib/zoneminder/cgi-bin/nph-zms
lrwxrwxrwx 1 root root 3 Oct 22  2024 /usr/lib/zoneminder/cgi-bin/nph-zms -> zms
zoneminder.conf (snip):

Code: Select all

    # Remember to enable cgi mod (i.e. "a2enmod cgi").
    ScriptAlias /cgi-bin "/usr/lib/zoneminder/cgi-bin"
    <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>
From https://zoneminder.readthedocs.io/en/la ... window-etc
my /etc/zm/conf.d/01-system-paths.conf has:

Code: Select all

# ZoneMinder url path to the zms streaming server
ZM_PATH_ZMS=/zm/cgi-bin/nph-zms
I have then edited the zoneminder.conf to

Code: Select all

ZM_PATH_ZMS=/usr/lib/zoneminder/cgi-bin/nph-zms
, restarted apache but still the same 404.
Any ideas what to try now please?
cookiemonster
Posts: 52
Joined: Sat Aug 15, 2015 1:46 pm

Re: Lost config with distro and zm version upgrade

Post by cookiemonster »

My last remaining problem is the "No live view, no thumbnails" . How many times we've seen this and still baffles me :)
Just like viewtopic.php?t=33907 and tried the suggestion to create a soft link

Code: Select all

ln -s /var/cache/zoneminder/ /var/cache/zoneminder/cache
but still the same, didn't solve it.
I've been reading Apache man pages to understand the settings that I think the 404 is because I think the path to cgi is fine but to the cache perhaps isn't.
Please help me spot the flaw.

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

Code: Select all

# Full path to the folder events are recorded to.
# The web account user must have full read/write permission to this folder.
ZM_DIR_EVENTS=/var/cache/zoneminder/events

# ZoneMinder url path to the zms streaming server
#ZM_PATH_ZMS=/zm/cgi-bin/nph-zms
ZM_PATH_ZMS=/usr/lib/zoneminder/cgi-bin/nph-zms
/etc/apache2/sites-available/zoneminder.conf

Code: Select all

    DocumentRoot "/usr/share/zoneminder/www"

    # 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>
        <IfModule !mod_authz_core.c>
            # Apache 2.2
            Order deny,allow
            Allow from all
        </IfModule>
    </Directory>
I have also before creating the link, in apache's zoneminder.conf I tried instead with:

Code: Select all

    DocumentRoot "/usr/share/zoneminder/www"

    # Order matters. This alias must come first.
    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>
because in my installation the directory /var/cache/zoneminder/ is where events subdir is ie /var/cache/zoneminder/events , see:

Code: Select all

penguin@venus:~$ tree -d /var/cache/zoneminder
/var/cache/zoneminder
├── cache
│   └── zoneminder -> /var/cache/zoneminder/
├── events
│   ├── 1
│   ├── 2
│   ├── Back -> 2
│   └── Front -> 1
├── images
└── temp
adam.robertson
Posts: 17
Joined: Tue Mar 25, 2025 2:19 pm

Re: Lost config with distro and zm version upgrade

Post by adam.robertson »

In my config I have:

Code: Select all

   Alias /cache/zoneminder "@ZM_CACHEDIR@"
    <Directory "/var/cache/zoneminder/cache">
        Options -Indexes +FollowSymLinks
        AllowOverride All
        <IfModule mod_authz_core.c>
           Require all granted
        </IfModule>
    </Directory>
I think the "@ZM_CACHEDIR@" is a variable for the cache directory, but it also works for me if I change it to /var/cache/zoneminder like you have in your config. However, you might give it a try to see if it makes any difference.

Also, I suspect you already know this since you have been dinkering around with linux, but after each change try:

sudo service apache2 restart
sudo service zoneminder restart

..then on your browser you are using clear the cache by holding down the shift button while refreshing the page.


You can also View Source of the page and find one of the links for css or js that has /cache in the link and then click on that to see if it opens for you...if it does, then your cache path is most likely working
User avatar
iconnor
Posts: 3339
Joined: Fri Oct 29, 2010 1:43 am
Location: Toronto
Contact:

Re: Lost config with distro and zm version upgrade

Post by iconnor »

@ZM_CACHEDIR@ is a build-time replacement. Apache will do nothing with it.

It should be for debian based distros:
Alias /zm/cache "/var/cache/zoneminder/cache"
<Directory "/var/cache/zoneminder/cache">
Options -Indexes +FollowSymLinks
AllowOverride All
<IfModule mod_authz_core.c>
Require all granted
</IfModule>
</Directory>
User avatar
iconnor
Posts: 3339
Joined: Fri Oct 29, 2010 1:43 am
Location: Toronto
Contact:

Re: Lost config with distro and zm version upgrade

Post by iconnor »

ZM_PATH_ZMS is confusing, as it is ACTUALLY the path part of a URL. It should be /zm/cgi-bin/nph-zms

The ScriptAlias links that to the real path. It should be:
ScriptAlias /zm/cgi-bin /usr/lib/zoneminder/cgi-bin/
cookiemonster
Posts: 52
Joined: Sat Aug 15, 2015 1:46 pm

Re: Lost config with distro and zm version upgrade

Post by cookiemonster »

adam.robertson wrote: Fri Apr 25, 2025 1:33 pm In my config I have:

Code: Select all

   Alias /cache/zoneminder "@ZM_CACHEDIR@"
    <Directory "/var/cache/zoneminder/cache">
        Options -Indexes +FollowSymLinks
        AllowOverride All
        <IfModule mod_authz_core.c>
           Require all granted
        </IfModule>
    </Directory>
I think the "@ZM_CACHEDIR@" is a variable for the cache directory, but it also works for me if I change it to /var/cache/zoneminder like you have in your config. However, you might give it a try to see if it makes any difference.

Also, I suspect you already know this since you have been dinkering around with linux, but after each change try:

sudo service apache2 restart
sudo service zoneminder restart

..then on your browser you are using clear the cache by holding down the shift button while refreshing the page.


You can also View Source of the page and find one of the links for css or js that has /cache in the link and then click on that to see if it opens for you...if it does, then your cache path is most likely working
Thanking you whilst reading Isaac's posts reg the @ZM_CACHEDIR@ variable. Thanks though and yes of course restarting services & fresh browser .
cookiemonster
Posts: 52
Joined: Sat Aug 15, 2015 1:46 pm

Re: Lost config with distro and zm version upgrade

Post by cookiemonster »

iconnor wrote: Fri Apr 25, 2025 1:42 pm @ZM_CACHEDIR@ is a build-time replacement. Apache will do nothing with it.

It should be for debian based distros:
Alias /zm/cache "/var/cache/zoneminder/cache"
<Directory "/var/cache/zoneminder/cache">
Options -Indexes +FollowSymLinks
AllowOverride All
<IfModule mod_authz_core.c>
Require all granted
</IfModule>
</Directory>
Ok this part matches.
cookiemonster
Posts: 52
Joined: Sat Aug 15, 2015 1:46 pm

Re: Lost config with distro and zm version upgrade

Post by cookiemonster »

iconnor wrote: Fri Apr 25, 2025 1:46 pm ZM_PATH_ZMS is confusing, as it is ACTUALLY the path part of a URL. It should be /zm/cgi-bin/nph-zms

The ScriptAlias links that to the real path. It should be:
ScriptAlias /zm/cgi-bin /usr/lib/zoneminder/cgi-bin/
Aha. This part does not match. I have on each:

Code: Select all

# ZoneMinder url path to the zms streaming server
ZM_PATH_ZMS=/zm/cgi-bin/nph-zms
#ZM_PATH_ZMS=/usr/lib/zoneminder/cgi-bin/nph-zms  <--a change in my debugging that I reversed, now back to the original above

Code: Select all

    # Remember to enable cgi mod (i.e. "a2enmod cgi").
    ScriptAlias /cgi-bin "/usr/lib/zoneminder/cgi-bin"
    <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>
Now changing the ScriptAlias in a sec.
cookiemonster
Posts: 52
Joined: Sat Aug 15, 2015 1:46 pm

Re: Lost config with distro and zm version upgrade

Post by cookiemonster »

Nein. Still being a pain, sorry.
I now have:
/etc/zm/conf.d/01-system-paths.conf

Code: Select all

# ZoneMinder url path to the zms streaming server
ZM_PATH_ZMS=/zm/cgi-bin/nph-zms
#ZM_PATH_ZMS=/usr/lib/zoneminder/cgi-bin/nph-zms
and /etc/apache2/sites-available/zoneminder.conf

Code: Select all

    # Remember to enable cgi mod (i.e. "a2enmod cgi").
#    ScriptAlias /cgi-bin "/usr/lib/zoneminder/cgi-bin"
    ScriptAlias /zm/cgi-bin "/usr/lib/zoneminder/cgi-bin"
    <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>
Of course restart apache and zoneminder after each change.
Please note that I tried with and without the trailing slash in the ALIAS:
ScriptAlias /zm/cgi-bin /usr/lib/zoneminder/cgi-bin/
anb
ScriptAlias /zm/cgi-bin/ /usr/lib/zoneminder/cgi-bin/

Could I be looking in the wrong place at things? Thanks for the assistance so far though.
Attachments
browser capture
browser capture
ZM-1.png (240.9 KiB) Viewed 2185 times
cookiemonster
Posts: 52
Joined: Sat Aug 15, 2015 1:46 pm

Re: Lost config with distro and zm version upgrade

Post by cookiemonster »

iconnor wrote: Fri Apr 25, 2025 1:42 pm @ZM_CACHEDIR@ is a build-time replacement. Apache will do nothing with it.

It should be for debian based distros:
Alias /zm/cache "/var/cache/zoneminder/cache"
<Directory "/var/cache/zoneminder/cache">
Options -Indexes +FollowSymLinks
AllowOverride All
<IfModule mod_authz_core.c>
Require all granted
</IfModule>
</Directory>
Spotted after staring at blocks of settings long enough that I had (please note these differences are not me fiddling):

# 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>
<IfModule !mod_authz_core.c>
# Apache 2.2
Order deny,allow
Allow from all
</IfModule>
</Directory>

Changed that but still no go.
I am going maaaad.

@iconnor - could it be the this part instead of the script alias?. Would you mind having a look too?
adam.robertson
Posts: 17
Joined: Tue Mar 25, 2025 2:19 pm

Re: Lost config with distro and zm version upgrade

Post by adam.robertson »

In my notes for setting up ZM I have this:

finally, run:

Code: Select all

sudo zmupdate.pl -f
and (changing username and password to match my setup)

Code: Select all

sudo zmupdate.pl --user=MYSQLUSER --pass="MYSQLPASSWORD"
cookiemonster
Posts: 52
Joined: Sat Aug 15, 2015 1:46 pm

Re: Lost config with distro and zm version upgrade

Post by cookiemonster »

Thanks @adam.robertson I appreciate the hint.
Just a glance at the perl script and is for updating the database from what I can gather. It wouldn't do anything:

mysql> select * from Config where Name = 'ZM_DYN_DB_VERSION';

Code: Select all

+-----+-------------------+---------+--------+--------------+--------+-------------+--------+----------------------------------------------------+------+----------+----------+---------+--------+----------+
| Id  | Name              | Value   | Type   | DefaultValue | Hint   | Pattern     | Format | Prompt                                             | Help | Category | Readonly | Private | System | Requires |
+-----+-------------------+---------+--------+--------------+--------+-------------+--------+----------------------------------------------------+------+----------+----------+---------+--------+----------+
| 216 | ZM_DYN_DB_VERSION | 1.36.35 | string | 1.36.35      | string | (?^:^(.+)$) |  $1    | What the version of the database is, from zmupdate |      | dynamic  |        1 |       0 |      0 | NULL     |
+-----+-------------------+---------+--------+--------------+--------+-------------+--------+----------------------------------------------------+------+----------+----------+---------+--------+----------+
1 row in set (0.00 sec)
and https://update.zoneminder.com/version.txt is 1.36.35 .
I'm comparing what the update script would do. Compare the value in the url with the version of the db and as we can see, it's up to date.
So I rather not run it. But I appreciate it.

Any more hints anyone please?
cookiemonster
Posts: 52
Joined: Sat Aug 15, 2015 1:46 pm

Re: Lost config with distro and zm version upgrade

Post by cookiemonster »

Thinking even more about it. Reinstallation of ZM but my storage for events is on an a separate disk. Could it be that which needs adjusting the configs? Maybe I'm just thinking aloud and posting in the hope I can cast my eyes on it and spot my idiocy.
I still have (reinstallation didn't purge it) in /etc/zm/conf.d/ a file 03-storage.conf that contains the entry:

Code: Select all

ZM_DIR_EVENTS=/mnt/Surveillance/zoneminder/events
Currently there is no data in there in the disk. This events directory is empty. The parent is where they're going.
However in the disk they are in /mnt/Surveillance/zoneminder/

Code: Select all

/mnt/Surveillance/zoneminder/
├── 1
│   ├── 23
│   │   ├── 06
│   │   │   ├── 16
│   │   │   │   └── 16
│   │   │   │       └── 38
│   │   │   │           └── 27
│   │   │   │               ├── 00001-capture.jpg
│   │   │   │               ├── 00002-capture.jpg

Code: Select all

penguin@venus:~$ ls -alh /mnt/Surveillance/zoneminder/1/
total 20K
drwxr-xr-x 5 www-data www-data 4.0K Mar  2 00:00 .
drwxr-xr-x 5 www-data www-data 4.0K May 28  2023 ..
drwxr-xr-x 6 www-data www-data 4.0K Apr 23 11:16 23
drwxr-xr-x 8 www-data www-data 4.0K Jan  1 01:27 24
drwxr-xr-x 3 www-data www-data 4.0K Apr  1 01:15 25

So it seems zm is writing currently to /mnt/Surveillance/zoneminder/ so I need to figure out how to get the webUI to see the events in that location.
So I have two thoughts:
1- why if there is an .conf in zm conf.d/ pointing to /path/to/events they are written to /path/to/
2- do I need to update apache to look there, is it

Code: Select all

Alias /zm/cache "/var/cache/zoneminder/cache"
that needs updating?
adam.robertson
Posts: 17
Joined: Tue Mar 25, 2025 2:19 pm

Re: Lost config with distro and zm version upgrade

Post by adam.robertson »

I am guessing you have been doing this already, but just in case:

Are your permissions all correct? Have you given www-data permissions on your storage and such?

I suggested this to one guy, but he insisted this broke his database, which is a funny thing to say.
Here is from my notes (which I kept copiously as I installed ZM for the first time)

Code: Select all

##6  SET PERMISSIONS FOR VARIOUS THINGS:

(zm runs under www-data)

sudo chown -R www-data:www-data /etc/zm/zm.conf

sudo chown -R www-data:www-data /etc/zm/conf.d/db-user.conf

sudo chown -R www-data:www-data /usr/share/zoneminder/www

sudo chown -R www-data:www-data /usr/lib/zoneminder

sudo chmod -R 0774   /usr/share/zoneminder/www

###and my storage drive#####
sudo chown -R www-data:www-data /mnt/zm
adam.robertson
Posts: 17
Joined: Tue Mar 25, 2025 2:19 pm

Re: Lost config with distro and zm version upgrade

Post by adam.robertson »

Another thing I did that I just found in my notes was to disable the ZM apache config located in:
/etc/apache2/conf-enabled/zoneminder.conf

This is a symlink to /etc/apache2/conf-available/zoneminder.conf so you can delete it, restart apache...if it helps then keep it deleted, otherwise just create the symlink again.

Code: Select all

sudo ln -s /etc/apache2/conf-available/zoneminder.conf    /etc/apache2/conf-enabled

I deleted the ZM config because I just use the apache sites-enabled with my config file there:

###MY sites-enabled config file...keep in my mind I have my ZM on the root path rather than using http://mysite/zm/
## so my ScriptAlias are going to NOT have /zm/ in front.

Code: Select all

<VirtualHost *:80>
	ServerAdmin myzm@adminemail.com
	ServerName myzm.domain.name
#        
        DocumentRoot /usr/share/zoneminder/www
#
#     
 ScriptAlias /cgi-bin "/usr/lib/zoneminder/cgi-bin"
<Directory "/usr/lib/zoneminder/cgi-bin">
   Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
   AllowOverride All
   Require all granted
</Directory>
#
   Alias /cache "/var/cache/zoneminder/cache"

    <Directory "/var/cache/zoneminder/cache">
        Options -Indexes +FollowSymLinks
        AllowOverride All
        <IfModule mod_authz_core.c>
           Require all granted
        </IfModule>
    </Directory>
#
 <Directory /usr/share/zoneminder/www>
   Options -Indexes +FollowSymLinks
   <IfModule mod_dir.c>
     DirectoryIndex index.php
   </IfModule>
 </Directory>
# 
<Directory "/usr/share/zoneminder/www/api">
  RewriteEngine on
  RewriteRule ^$ app/webroot/ [L]
  RewriteRule (.*) app/webroot/$1 [L]
  RewriteBase /api
</Directory>
#
<Directory "/usr/share/zoneminder/www/api/app">
  RewriteEngine on
  RewriteRule ^$ webroot/ [L]
  RewriteRule (.*) webroot/$1 [L]
  RewriteBase /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 /api
</Directory>
#
 ErrorLog ${APACHE_LOG_DIR}/zm.domain.com_error.log
 CustomLog ${APACHE_LOG_DIR}/zm.domain.com_access.log combined
#
</VirtualHost>
Post Reply