VM ZM not loading host's browser localhost/zm/?

Discussions related to the 1.36.x series of ZoneMinder
eiger3970
Posts: 55
Joined: Thu Jun 26, 2014 10:58 pm

VM ZM not loading host's browser localhost/zm/?

Post by eiger3970 »

Hello, I just installed ZM 1.36.x on a Debian 12.0 VM.
I followed all the instructions from the wiki https://wiki.zoneminder.com/Debian_12_B ... der_1.36.x

I open the Host's browser and try connecting to http://localhost/zm/, but error: This page isn't working. localhost is currently unable to handle this request. HTTP ERROR 500

I checked apache2 is running on the VM Debian 12 Bookworm.

Code: Select all

root@debian:~# systemctl status apache2
● apache2.service - The Apache HTTP Server
     Loaded: loaded (/lib/systemd/system/apache2.service; enabled; preset: enab>
     Active: active (running) since Mon 2024-03-11 20:25:19 AEST; 1h 47min ago
       Docs: https://httpd.apache.org/docs/2.4/
    Process: 538 ExecStart=/usr/sbin/apachectl start (code=exited, status=0/SUC>
   Main PID: 647 (apache2)
      Tasks: 6 (limit: 1048)
     Memory: 40.7M
        CPU: 295ms
     CGroup: /system.slice/apache2.service
             ├─647 /usr/sbin/apache2 -k start
             ├─652 /usr/sbin/apache2 -k start
             ├─653 /usr/sbin/apache2 -k start
             ├─654 /usr/sbin/apache2 -k start
             ├─655 /usr/sbin/apache2 -k start
             └─656 /usr/sbin/apache2 -k start

Mar 11 20:25:18 debian systemd[1]: Starting apache2.service - The Apache HTTP S>
Mar 11 20:25:19 debian apachectl[574]: AH00558: apache2: Could not reliably det>
Mar 11 20:25:19 debian systemd[1]: Started apache2.service - The Apache HTTP Se>
I checked the host for port 80:

Code: Select all

linuxmint@linuxmint:~$ sudo netstat -plnt | grep ':80'
[sudo] password for linuxmint:           
tcp6       0      0 :::80                   :::*                    LISTEN      1238/apache2        
tcp6       0      0 :::8080                 :::*                    LISTEN      1098/java  
Host -> Browser -> http://localhost -> does open the Apache2 Default Page. I don't seem to be able to find documentation on the correct URL for zm?
I've searched some ZM docs and searched, but unsure how to fix?
Last edited by eiger3970 on Sun Mar 17, 2024 1:37 am, edited 1 time in total.
dougmccrary
Posts: 1215
Joined: Sat Aug 31, 2019 7:35 am
Location: San Diego

Re: VM ZM not loading host's browser localhost/zm/?

Post by dougmccrary »

The path is localhost/zm.
You don't have apache set up correctly, probably didn't do the stuff right after starting zoneminder. Redoing those won't hurt anything.
Try again. Why didn't you stick with Ubuntu?
eiger3970
Posts: 55
Joined: Thu Jun 26, 2014 10:58 pm

Re: VM ZM not loading host's browser localhost/zm/?

Post by eiger3970 »

I followed the guide and had no errors.
The guide doesn't say what to do after zm is installed, like open a browser and http://localhost/zm.

I chose Debian as I think it might be smaller then Ubuntu server?
aquadot
Posts: 17
Joined: Tue Apr 26, 2022 10:13 pm

Re: VM ZM not loading host's browser localhost/zm/?

Post by aquadot »

What does your apache config look like?

There is absolutely nothing wrong with using Debian OR Ubuntu and Debian is just fine. I've been using Debian for almost a decade after using Ubuntu based distros and slackware before that...
dougmccrary
Posts: 1215
Joined: Sat Aug 31, 2019 7:35 am
Location: San Diego

Re: VM ZM not loading host's browser localhost/zm/?

Post by dougmccrary »

I followed the guide and had no errors.
Failing to complete all the steps will only cause ZM to not work. No errors.
Your status needs some of these:
├─274636 /usr/lib/zoneminder/cgi-bin/nph-zms
├─274637 /usr/lib/zoneminder/cgi-bin/nph-zms
├─274638 /usr/lib/zoneminder/cgi-bin/nph-zms
eiger3970
Posts: 55
Joined: Thu Jun 26, 2014 10:58 pm

Re: VM ZM not loading host's browser localhost/zm/?

Post by eiger3970 »

Configuration files should all be default with whatever the guide's changes suggested, as I walked through the guide with all the commands.

Code: Select all

root@debian:/etc/apache2# cat apache2.conf 
# This is the main Apache server configuration file.  It contains the
# configuration directives that give the server its instructions.
# See http://httpd.apache.org/docs/2.4/ for detailed information about
# the directives and /usr/share/doc/apache2/README.Debian about Debian specific
# hints.
#
#
# Summary of how the Apache 2 configuration works in Debian:
# The Apache 2 web server configuration in Debian is quite different to
# upstream's suggested way to configure the web server. This is because Debian's
# default Apache2 installation attempts to make adding and removing modules,
# virtual hosts, and extra configuration directives as flexible as possible, in
# order to make automating the changes and administering the server as easy as
# possible.

# It is split into several files forming the configuration hierarchy outlined
# below, all located in the /etc/apache2/ directory:
#
#	/etc/apache2/
#	|-- apache2.conf
#	|	`--  ports.conf
#	|-- mods-enabled
#	|	|-- *.load
#	|	`-- *.conf
#	|-- conf-enabled
#	|	`-- *.conf
# 	`-- sites-enabled
#	 	`-- *.conf
#
#
# * apache2.conf is the main configuration file (this file). It puts the pieces
#   together by including all remaining configuration files when starting up the
#   web server.
#
# * ports.conf is always included from the main configuration file. It is
#   supposed to determine listening ports for incoming connections which can be
#   customized anytime.
#
# * Configuration files in the mods-enabled/, conf-enabled/ and sites-enabled/
#   directories contain particular configuration snippets which manage modules,
#   global configuration fragments, or virtual host configurations,
#   respectively.
#
#   They are activated by symlinking available configuration files from their
#   respective *-available/ counterparts. These should be managed by using our
#   helpers a2enmod/a2dismod, a2ensite/a2dissite and a2enconf/a2disconf. See
#   their respective man pages for detailed information.
#
# * The binary is called apache2. Due to the use of environment variables, in
#   the default configuration, apache2 needs to be started/stopped with
#   /etc/init.d/apache2 or apache2ctl. Calling /usr/bin/apache2 directly will not
#   work with the default configuration.


# Global configuration
#

#
# ServerRoot: The top of the directory tree under which the server's
# configuration, error, and log files are kept.
#
# NOTE!  If you intend to place this on an NFS (or otherwise network)
# mounted filesystem then please read the Mutex documentation (available
# at <URL:http://httpd.apache.org/docs/2.4/mod/core.html#mutex>);
# you will save yourself a lot of trouble.
#
# Do NOT add a slash at the end of the directory path.
#
#ServerRoot "/etc/apache2"

#
# The accept serialization lock file MUST BE STORED ON A LOCAL DISK.
#
#Mutex file:${APACHE_LOCK_DIR} default

#
# The directory where shm and other runtime files will be stored.
#

DefaultRuntimeDir ${APACHE_RUN_DIR}

#
# PidFile: The file in which the server should record its process
# identification number when it starts.
# This needs to be set in /etc/apache2/envvars
#
PidFile ${APACHE_PID_FILE}

#
# Timeout: The number of seconds before receives and sends time out.
#
Timeout 300

#
# KeepAlive: Whether or not to allow persistent connections (more than
# one request per connection). Set to "Off" to deactivate.
#
KeepAlive On

#
# MaxKeepAliveRequests: The maximum number of requests to allow
# during a persistent connection. Set to 0 to allow an unlimited amount.
# We recommend you leave this number high, for maximum performance.
#
MaxKeepAliveRequests 100

#
# KeepAliveTimeout: Number of seconds to wait for the next request from the
# same client on the same connection.
#
KeepAliveTimeout 5


# These need to be set in /etc/apache2/envvars
User ${APACHE_RUN_USER}
Group ${APACHE_RUN_GROUP}

#
# HostnameLookups: Log the names of clients or just their IP addresses
# e.g., www.apache.org (on) or 204.62.129.132 (off).
# The default is off because it'd be overall better for the net if people
# had to knowingly turn this feature on, since enabling it means that
# each client request will result in AT LEAST one lookup request to the
# nameserver.
#
HostnameLookups Off

# ErrorLog: The location of the error log file.
# If you do not specify an ErrorLog directive within a <VirtualHost>
# container, error messages relating to that virtual host will be
# logged here.  If you *do* define an error logfile for a <VirtualHost>
# container, that host's errors will be logged there and not here.
#
ErrorLog ${APACHE_LOG_DIR}/error.log

#
# LogLevel: Control the severity of messages logged to the error_log.
# Available values: trace8, ..., trace1, debug, info, notice, warn,
# error, crit, alert, emerg.
# It is also possible to configure the log level for particular modules, e.g.
# "LogLevel info ssl:warn"
#
LogLevel warn

# Include module configuration:
IncludeOptional mods-enabled/*.load
IncludeOptional mods-enabled/*.conf

# Include list of ports to listen on
Include ports.conf


# Sets the default security model of the Apache2 HTTPD server. It does
# not allow access to the root filesystem outside of /usr/share and /var/www.
# The former is used by web applications packaged in Debian,
# the latter may be used for local directories served by the web server. If
# your system is serving content from a sub-directory in /srv you must allow
# access here, or in any related virtual host.
<Directory />
	Options FollowSymLinks
	AllowOverride None
	Require all denied
</Directory>

<Directory /usr/share>
	AllowOverride None
	Require all granted
</Directory>

<Directory /var/www/>
	Options Indexes FollowSymLinks
	AllowOverride None
	Require all granted
</Directory>

#<Directory /srv/>
#	Options Indexes FollowSymLinks
#	AllowOverride None
#	Require all granted
#</Directory>




# AccessFileName: The name of the file to look for in each directory
# for additional configuration directives.  See also the AllowOverride
# directive.
#
AccessFileName .htaccess

#
# The following lines prevent .htaccess and .htpasswd files from being
# viewed by Web clients.
#
<FilesMatch "^\.ht">
	Require all denied
</FilesMatch>


#
# The following directives define some format nicknames for use with
# a CustomLog directive.
#
# These deviate from the Common Log Format definitions in that they use %O
# (the actual bytes sent including headers) instead of %b (the size of the
# requested file), because the latter makes it impossible to detect partial
# requests.
#
# Note that the use of %{X-Forwarded-For}i instead of %h is not recommended.
# Use mod_remoteip instead.
#
LogFormat "%v:%p %h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" vhost_combined
LogFormat "%h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" combined
LogFormat "%h %l %u %t \"%r\" %>s %O" common
LogFormat "%{Referer}i -> %U" referer
LogFormat "%{User-agent}i" agent

# Include of directories ignores editors' and dpkg's backup files,
# see README.Debian for details.

# Include generic snippets of statements
IncludeOptional conf-enabled/*.conf

# Include the virtual host configurations:
IncludeOptional sites-enabled/*.conf
root@debian:/etc/apache2# 

eiger3970
Posts: 55
Joined: Thu Jun 26, 2014 10:58 pm

Re: VM ZM not loading host's browser localhost/zm/?

Post by eiger3970 »

I don't know what this is about, but here's some output I found?
I completed all the steps of the guide.
How do I get the output like your post Wed Mar 13, 2024 12:01 pm?

Code: Select all

root@debian:/usr/lib/zoneminder/cgi-bin# ls -al
total 992
drwxr-xr-x 2 root root    4096 Mar 11 19:48 .
drwxr-xr-x 3 root root    4096 Mar 11 19:48 ..
lrwxrwxrwx 1 root root       3 Feb 24  2023 nph-zms -> zms
-rwxr-xr-x 1 root root 1005528 Feb 24  2023 zms
dougmccrary
Posts: 1215
Joined: Sat Aug 31, 2019 7:35 am
Location: San Diego

Re: VM ZM not loading host's browser localhost/zm/?

Post by dougmccrary »

I now second aquadot's post. What you've found so far seems correct.

Is zoneminder.service running?
aquadot
Posts: 17
Joined: Tue Apr 26, 2022 10:13 pm

Re: VM ZM not loading host's browser localhost/zm/?

Post by aquadot »

Sometimes when I get hung up on configuring something in Debian I find that things in the /usr/share/doc folder can be helpful and in this case /usr/share/doc/zoneminder might have something helpful. Typically something like README.Debian.txt is in a folder like this and will help with any Debian nuances.

Also, did you make sure you have a config for Zoneminder under either /etc/apache2/conf-available or /etc/apache2/sites-available? If you have something under one of those then you'll need to either run a2enconf zoneminder.conf (this is related to the name of the conf under conf-available or a2ensite zoneminder.conf (again, based on the file) respectively. Have you run through that step? If so, what does your zoneminder conf look like from the apache files?
eiger3970
Posts: 55
Joined: Thu Jun 26, 2014 10:58 pm

Re: VM ZM not loading host's browser localhost/zm/?

Post by eiger3970 »

Code: Select all

linuxmint@linuxmint:/usr/share/doc$ a2enconf zoneminder.conf
Conf zoneminder already enabled
linuxmint@linuxmint:/usr/share/doc$ a2ensite zoneminder.conf
ERROR: Site zoneminder does not exist!

Code: Select all

/etc/apache2/conf-available -> charset.conf  javascript-common.conf  localized-error-pages.conf  other-vhosts-access-log.conf  security.conf  serve-cgi-bin.conf  zoneminder.conf

/etc/apache2/sites-available -> 000-default.conf  default-ssl.conf
/usr/share/doc/zoneminder/README.Debian.gz -> Extract -> README.Debian.txt.

Code: Select all

linuxmint@linuxmint:/etc/apache2/conf-available$ cat zoneminder.conf 
# 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"
    <Directory "/var/cache/zoneminder">
        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>

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

Code: Select all

linuxmint@linuxmint:/etc/apache2/conf-available$ sudo a2enmod cgi
[sudo] password for linuxmint:           
Enabling module cgi.
To activate the new configuration, you need to run:
  systemctl restart apache2
linuxmint@linuxmint:/etc/apache2/conf-available$ systemctl restart apache2
linuxmint@linuxmint:/etc/apache2/conf-available$ sudo a2enmod cgi
Module cgi already enabled
User avatar
burger
Posts: 390
Joined: Mon May 11, 2020 4:32 pm

Re: VM ZM not loading host's browser localhost/zm/?

Post by burger »

eiger3970 wrote: Sat Mar 16, 2024 12:59 am

Code: Select all

linuxmint@linuxmint:/etc/apache2/conf-available$ cat zoneminder.conf 
# 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"
    <Directory "/var/cache/zoneminder">
        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>

<Directory /usr/share/zoneminder/www/api>
    AllowOverride All
</Directory>
This doesn't match up with what is on the wiki. There should be some additional api configurations there. Make sure to follow the guide for 1.36 and not 1.37. In your original post, you linked to the 1.37 section.
fastest way to test streams:
ffmpeg -i rtsp://<user>:<pass>@<ipaddress>:554/path ./output.mp4 (if terminal only)
ffplay rtsp://<user>:<pass>@<ipaddress>:554/path (gui)
find paths on ispydb or in zm hcl

If you are new to security software, read:
https://wiki.zoneminder.com/Dummies_Guide
eiger3970
Posts: 55
Joined: Thu Jun 26, 2014 10:58 pm

Re: VM ZM not loading host's browser localhost/zm/?

Post by eiger3970 »

Sorry, I must have picked up the link at the bottom of finishing with the Debian 12 with Zoneminder 1.36.x guide.
Also copied the host's file instead of the VM Debian file.
I followed the 1.36 guide and have corrected the link in post Mon Mar 11, 2024 9:52 pm

I suspect the host -> browser -> http://localhost/ -> output: Apache2 Default Page, may be sourcing from another apache file, not related to the VM ZM Apache file?

Here's the VM Debian's /etc/apache2/conf-available/zoneminder.conf output:

Code: Select all

debian@debian:/etc/apache2/conf-available$ cat zoneminder.conf
# 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"
<Directory "/var/cache/zoneminder">
    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>
Tested as per /usr/share/doc/zoneminder/README.Debian: Host -> 2 different browsers ->
http://localhost/ -> Apache2 Default Page.
http://zoneminder -> This site can’t be reached
http://zoneminder -> Not Found
http://localhost/zm/api/host/getVersion.json -> Not Found
http://localhost/zm/api/monitors.json -> Not Found
http://localhost/zm/api/ -> Not Found
mikb
Posts: 604
Joined: Mon Mar 25, 2013 12:34 pm

Re: VM ZM not loading host's browser localhost/zm/?

Post by mikb »

eiger3970 wrote: Sun Mar 17, 2024 1:38 am I suspect the host -> browser -> http://localhost/ -> output: Apache2 Default Page, may be sourcing from another apache file, not related to the VM ZM Apache file?

Code: Select all

    RewriteBase /zm/api
1) Yes using just "localhost" will get you a default Apache page. Probaby the default "It works!" page -- in my case I get a "403 Forbidden -- you cannot access /" because I probably tightened up some security nuts somewhere ;)

2) Your example URLS

http://localhost/ -> Apache2 Default Page. (As above, expected, not a ZM page but proves you have a web server running!)

http://zoneminder -> This site can’t be reached
http://zoneminder -> Not Found

You're making a connection to a machine called "zoneminder" on your local domain there. If that's the name of your machine, maybe that would serve the default page too. If you don't have a machine called "zoneminder" then that will fail.

All the stuff specific to Zoneminder is imported from the separate apache config file. If you are not getting this read by the Apache server (either because the file is missing, corrupt/errors that cause it to be ignored, or bad permissions so it can't be read) then the ZM user interface and all the URLs specific to ZM will just fail.

It's been a while since I set that up, and no doubt a lot has changed on how that should be done since 1.very.old ;)

I think the quoted line about "Rewrite Base" is what maps a WEB request for "localhost/zm/api/SOMETHING" to your internal file system's content at e.g. /var/www/zoneminder/api/SOMETHING", without that knowledge, the web server won't know what to serve (or will try to serve up content from the wrong place, and find it isn't there anyway ...)
eiger3970
Posts: 55
Joined: Thu Jun 26, 2014 10:58 pm

Re: VM ZM not loading host's browser localhost/zm/?

Post by eiger3970 »

The hypervisor is showing the VM's CPU usage maxing out, while the host's CPU usage is a little over normal.
The other VMs have low VM CPU and Host CPU usage.
I'm confused what's problematic, so might just try another fresh VM install of Debian and then ZM on the VM.
eiger3970
Posts: 55
Joined: Thu Jun 26, 2014 10:58 pm

Re: VM ZM not loading host's browser localhost/zm/?

Post by eiger3970 »

Solved.
I changed the VM Debian server's IP from DHCP to static.
Host Linux Mint 21.3 Virginia Cinnamon 64-bit -> Browser -> 192.168.1.146/zm -> ZoneMinder console. (localhost/zm failed).
Post Reply