[SOLVED] Lost config with distro and zm version upgrade

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

Re: Lost config with distro and zm version upgrade

Post by cookiemonster »

Permissions are all correct with www-data as owner (this is Ubuntu) with the exception of /usr/lib/zoneminder/cgi-bin/ that is owned by root. That is OK though, the zms binary inside is working for creating the recordings.
The link from conf-available to conf-enabled is normal. What happens is that you create your websites in available and then can use a2ensite utility from apache that creates the link to enabled. Ubuntu seems to use sites-available & sites-enabled but the way to enable them is the same.

Now back to the problem, I'm convinced it is a problem I have in apache, note the screenshot says the 404s are when trying to show http://192.168.5.176/zm/cgi-bin/nph-zms ... 1745590306. The last digit seems a random number and the rest is apache trying the script alias i.e. nph-zms that is a symlink to zms. BUT I can see the recordings in the UI (perms are OK therefore).
I'll see what else I can spot in the apache config differences but remembering I'm ubuntu you're debian I think, and what iconnor has said what it should be.
This is mine:

Code: Select all

<VirtualHost *:80>
    ServerAdmin webmaster@localhost

    DocumentRoot "/usr/share/zoneminder/www"

    # Order matters. This alias must come first.
    Alias /zm/cache "/var/cache/zoneminder/cache"
#    Alias /zm/cache "/var/cache/zoneminder"
#    Alias /zm/cache "/mnt/Surveillance/zoneminder"
    <Directory "/var/cache/zoneminder/cache">
#    <Directory "/var/cache/zoneminder">
#    <Directory "/mnt/Surveillance/zoneminder">
        Options -Indexes +FollowSymLinks
#        AllowOverride None
        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>

    Alias /zm "/usr/share/zoneminder/www"
    <Directory "/usr/share/zoneminder/www">
        Options -Indexes +FollowSymLinks
        AllowOverride All
        Require all granted
        <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>

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

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

    # Use the first option to have Apache logs written to the general log
    # 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)
    ErrorLog /var/log/zm/apache-error.log
    #ErrorLog /var/log/httpd/zm-error.log

    # Possible values include: debug, info, notice, warn, error, crit,
    # alert, emerg.
    LogLevel warn

    # Use the first option to have Apache logs written to the general log
    # 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 /var/log/zm/apache-access.log combined
    #CustomLog /var/log/httpd/zm-access.log combined

</VirtualHost>
Really appreciate the help. The head scratching continues.
cookiemonster
Posts: 54
Joined: Sat Aug 15, 2015 1:46 pm

[SOLVED] Lost config with distro and zm version upgrade

Post by cookiemonster »

adam.robertson wrote: Sat Apr 26, 2025 2:41 pm 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. <== THIS GAVE ME An IDEA

As well as your config where the ScriptAlias is before the paths Aliases

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>
And then read apache's modalias documentation for order of processing.
So from the config I have where they are:
1- # Order matters. This alias must come first.
Alias /zm/cache "/var/cache/zoneminder/cache"
2- Alias /zm "/usr/share/zoneminder/www"
3- ScriptAlias /zm/cgi-bin "/usr/lib/zoneminder/cgi-bin/"
It made me think that #3 /zm/ci-bin will never be reached as it has been redirected by #2 /zm before it. So I put #3 at the top.
Hunch was correct. Now all is good.
I'll mark it as solved.
Thank you very much for the help. I'm leaving this for those that come to search for it later.

p.s. - I did not put them in the wrong order. I took the apache example in /usr/share/doc/zoneminder/examples/apache.conf
adam.robertson
Posts: 18
Joined: Tue Mar 25, 2025 2:19 pm

Re: [SOLVED] Lost config with distro and zm version upgrade

Post by adam.robertson »

Very cool. Your persistence is admirable. It took me about a week to get ZM fully working, then another week to figure out how to get zones working.
Post Reply