Page 1 of 2

Make ZoneMinder accessible at "zm.mydomain.com"?

Posted: Wed Jun 12, 2019 1:54 pm
by IncompleteString
Hi,

I'm trying to make it so that ZoneMinder is accessible from "zm.mydomain.com" instead of "zm.mydomain.com/zm".

Can anyone tell me how to accomplish this?

I'm running 1.32.3 on Ubuntu 16.04, I installed via the PPA.

I tried altering the document root in my virtual hosts file to

Code: Select all

DocumentRoot /usr/share/zoneminder/www
, but ZoneMinder pages do not load completely when I do that.

I searched the forums, and saw recommendations to make an alias in the virtual hosts file, but I don't understand how to make an alias point to "zm.mydomain.com" only to other locations after "zm.mydomain.com", for example "zm.mydomain.com/foo".

I tried creating an alias like the following, but I still got the "Apache2 Ubuntu Default Page" after I restarted apache2:

Code: Select all

Alias "/"  "/usr/share/zoneminder/www"

Should I delete the files currently located at

Code: Select all

/var/www/html
and create a symbolic link from

Code: Select all

/usr/share/zoneminder/www
to

Code: Select all

/var/www/html
?

Re: Make ZoneMinder accessible at "zm.mydomain.com"?

Posted: Wed Jun 12, 2019 2:44 pm
by IncompleteString
Altering the document root to

Code: Select all

DocumentRoot /usr/share/zoneminder/www
makes the zoneminder page look like this
Untitled.jpeg
Untitled.jpeg (59.66 KiB) Viewed 2109 times

instead of this
Untitled1.jpeg
Untitled1.jpeg (50.46 KiB) Viewed 2109 times

Re: Make ZoneMinder accessible at "zm.mydomain.com"?

Posted: Wed Jun 12, 2019 3:02 pm
by rockedge
this is the stock zoneminder.conf in /etc/apache2/conf-avialble
change the

Code: Select all

Alias /zm /usr/share/zoneminder/www
to this:

Code: Select all

Alias /  /usr/share/zoneminder/www

Code: Select all

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

Alias /zm /usr/share/zoneminder/www         [color=#FF0000][b] change this!![/b][/color]
<Directory /usr/share/zoneminder/www>
  php_flag register_globals off
  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>
Remember after making the changes to restart Apache and that the conf is enabled with
the command a2enconf zoneminder

Re: Make ZoneMinder accessible at "zm.mydomain.com"?

Posted: Wed Jun 12, 2019 10:08 pm
by IncompleteString
when I make the changes you suggest this is what I get when attempting to access zm.mydomain.com
Untitled.jpeg
Untitled.jpeg (11.19 KiB) Viewed 2097 times

Re: Make ZoneMinder accessible at "zm.mydomain.com"?

Posted: Thu Jun 13, 2019 1:54 am
by rockedge
my mistake!

this works so far

change in /etc/apache2/conf-avialable/zoneminder.conf this

Code: Select all

Alias /zm /usr/share/zoneminder/www
to this ->

Code: Select all

ScriptAlias /* /usr/share/zoneminder/www
then comment out the line (around line 10)
#Alias /zm/cache /var/cache/zoneminder/cache
then create a symlink with the target /var/cache/zoneminder/cache with the link /usr/share/zoneminder/www/cache
so open a terminal ->

Code: Select all

ln -s /var/cache/zoneminder/cache  /usr/share/zoneminder/www/cache
RESTART APACHE
clear the browser cache and reload the ZM web console

Re: Make ZoneMinder accessible at "zm.mydomain.com"?

Posted: Thu Jun 13, 2019 2:45 am
by IncompleteString
Ok that didnt work.

here is my /etc/apache2/conf-available/zoneminder.conf file

Code: Select all

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

#Alias /zm /usr/share/zoneminder/www
ScriptAlias /* /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>


That config still gives me the "Apache2 Ubuntu Default Page" at zm.mydomain.com and I get a "Not Found" at zm.mydomain.com

Re: Make ZoneMinder accessible at "zm.mydomain.com"?

Posted: Thu Jun 13, 2019 4:48 am
by rockedge
sorry the symlink command had a mistake. This is the correct one.

Code: Select all

ln -s /var/cache/zoneminder/cache  /usr/share/zoneminder/www/cache
did you restart apache? clear the browser's cache also?

Re: Make ZoneMinder accessible at "zm.mydomain.com"?

Posted: Thu Jun 13, 2019 11:22 am
by IncompleteString
That doesn't work either.

I edited my /etc/apache2/conf-available/zoneminder.conf file to look like this:

Code: Select all

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

#Alias /zm /usr/share/zoneminder/www
ScriptAlias /* /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>

Then ran

Code: Select all

ln -s /var/cache/zoneminder/cache  /usr/share/zoneminder/www/cache
Then ran

Code: Select all

systemctl restart apache2
then cleared my browser cache in both safari and chrome. I still get the "Ubuntu Default Page" on both browsers.


Do I need to edit the "/etc/apache2/sites-enabled/000-default-le-ssl.conf" file or "/etc/apache2/sites-available/000-default-le-ssl.conf" any other apache2 files to get this to work?

Re: Make ZoneMinder accessible at "zm.mydomain.com"?

Posted: Thu Jun 13, 2019 11:39 am
by IncompleteString
Also since I commented out

Code: Select all

#Alias /zm/cache /var/cache/zoneminder/cache
Do I need to create a new cache alias to point to where you had me create the symlink?

Re: Make ZoneMinder accessible at "zm.mydomain.com"?

Posted: Thu Jun 13, 2019 12:12 pm
by IncompleteString
If I edit my /etc/apache2/conf-available/zoneminder.conf so it looks like this:

Code: Select all

# Order matters. This alias must come first.
#Alias /zm/cache /var/cache/zoneminder/cache
Alias /zm/cache /usr/share/zoneminder/www/cache
#<Directory /var/cache/zoneminder/cache>
<Directory /usr/share/zoneminder/www/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>

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


And edit my /etc/apache2/sites-available/000-default-le-ssl.conf so it looks like this ( I should probably state that I'm using multi-port as should be evident in the following):

Code: Select all

<IfModule mod_ssl.c>
<VirtualHost *:443 *:30001 *:30002 *:30003 *:30004 *:30005 *:30006 *:30007 *:30$
        # The ServerName directive sets the request scheme, hostname and port t$
        # the server uses to identify itself. This is used when creating
        # redirection URLs. In the context of virtual hosts, the ServerName
        # specifies what hostname must appear in the request's Host: header to
        # match this virtual host. For the default virtual host (this file) this
        # value is not decisive as it is used as a last resort host regardless.
        # However, you must set it for any further virtual host explicitly.
        #ServerName www.example.com

        ServerAdmin webmaster@localhost
        #DocumentRoot /var/www/html
        DocumentRoot /usr/share/zoneminder/www

        # Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
        # error, crit, alert, emerg.
        # It is also possible to configure the loglevel for particular
        # modules, e.g.
        #LogLevel info ssl:warn

        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined

        # For most configuration files from conf-available/, which are
        # enabled or disabled at a global level, it is possible to
        # include a line for only one particular virtual host. For example the
        # following line enables the CGI configuration for this host only
        # after it has been globally disabled with "a2disconf".
        #Include conf-available/serve-cgi-bin.conf
ServerName zm.mydomain.com
SSLCertificateFile /etc/letsencrypt/live/zm.mydomain.com/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/zm.mydomain.com/privkey.pem
Include /etc/letsencrypt/options-ssl-apache.conf
</VirtualHost>
</IfModule>
Then run

Code: Select all

ln -s /var/cache/zoneminder/cache /usr/share/zoneminder/www/cache
restart apache2 and clear the browser cache.

Thank kind of works. Everything except the playback of events seems to be working, but playing back events is important.

This is what I get when I try and play back an event:
Untitled.jpeg
Untitled.jpeg (152.97 KiB) Viewed 2050 times

I got a similar playback error when I was trying to configure multi-port, so maybe this is something similar / related.

Re: Make ZoneMinder accessible at "zm.mydomain.com"?

Posted: Thu Jun 13, 2019 1:57 pm
by rockedge
getting closer! and it is very important to be able to play back recorded events.
This line ->
ln -s /var/cache/zoneminder/cache /usr/share/zoneminder/www/cache
does create a symlink for the /var/cache/zoneminder/cache and replaces the commented out Alias line, and only needs to be done once.

The multiport set up is something I did not test out...but the lack of play back seems more of a missing library problem. Can you see Stills?

So ZM seems to working and is recording events and creating .mp4 files? Although playback is not working but the live stream is?

what is recorded in the logs as far as errors go?

Re: Make ZoneMinder accessible at "zm.mydomain.com"?

Posted: Thu Jun 13, 2019 6:14 pm
by Bluemax
If that's an option it would be much easier and 100% compatible if you'd just create a 'rewrite' so you can enter 'http://zm.mydomain.com' and it will redirect you automatically to 'http://zm.mydomain.com/zm/'. On nginx it would look like this:

Code: Select all

	location / {
		rewrite ^/$ /zm/ permanent;
	}

Re: Make ZoneMinder accessible at "zm.mydomain.com"?

Posted: Sat Jun 15, 2019 3:13 am
by rockedge
with multiport the url rewrite needs to take into account the port. The apache setup seems easier to alter the alias than use url rewrites
I will test it out and see how it runs on these versions of ZM...a single rewrite would be the easiest I think

Re: Make ZoneMinder accessible at "zm.mydomain.com"?

Posted: Sat Jun 15, 2019 4:11 pm
by IncompleteString
I'm using h264 passthrough, and I've got JPEGs disabled, so there are no stills to look at, unless I'm missing something.

Yes the montage and live view work.

Logs look normal. I'm only getting INF messages with debugging switched on.

Re: Make ZoneMinder accessible at "zm.mydomain.com"?

Posted: Sat Jun 15, 2019 10:27 pm
by kitkat
This works for me with Apache 2.4.6 and ZM 1.32.2 on CentOS 7, without changing any configuration files...

Code: Select all

mount --bind /usr/share/zoneminder/www /var/www/html
ln -s /var/cache/zoneminder /var/www/html/cache
e2a: Once the link to the cache has been created with ln you can put this in fstab so the directory gets bound automatically at boot time...

Code: Select all

/usr/share/zoneminder/www /var/www/html auto bind,defaults 0 0
If you're serving zm.mydomain.com from a document root other than /var/www/html, substitute it in the above commands.