[SOLVED] Zoneminder API Not Installed?
[SOLVED] Zoneminder API Not Installed?
Hey All:
Just finished setting up Zoneminder (1.30.4) on an Ubuntu Server (17.10). Finally got its console working, and it's happily churning up disk space while I see how much a week's worth of event footage costs me. I should note that the NGINX integration was the most problematic part until I learned about the example configuration that came with ZoneMinder. That really should be added to the setup provisions for those of us who didn't know just how reliant ZM is on Apache.
I'm now trying to get the API working for integration with Home Assistant. I've added the /zm/api link recommended by Pliable Pixels at https://github.com/pliablepixels/zmNinj ... with-nginx. However, I'm getting "Bad Gateway" responses. On checking with my actual files, I discovered that I do not have a /usr/share/zoneminder/api folder.
I see that this was an installer problem in the past. Has that not been fixed, and should I follow past advice to clone the folder from the Git? Or is there a new fix that I just can't find.
Thanks.
Just finished setting up Zoneminder (1.30.4) on an Ubuntu Server (17.10). Finally got its console working, and it's happily churning up disk space while I see how much a week's worth of event footage costs me. I should note that the NGINX integration was the most problematic part until I learned about the example configuration that came with ZoneMinder. That really should be added to the setup provisions for those of us who didn't know just how reliant ZM is on Apache.
I'm now trying to get the API working for integration with Home Assistant. I've added the /zm/api link recommended by Pliable Pixels at https://github.com/pliablepixels/zmNinj ... with-nginx. However, I'm getting "Bad Gateway" responses. On checking with my actual files, I discovered that I do not have a /usr/share/zoneminder/api folder.
I see that this was an installer problem in the past. Has that not been fixed, and should I follow past advice to clone the folder from the Git? Or is there a new fix that I just can't find.
Thanks.
Last edited by databoy2k on Thu Nov 23, 2017 3:35 am, edited 1 time in total.
Re: Zoneminder API Not Installed?
I use 1.30.4 and 1.31.1 with a Hiawatha web server and to get the API to work I needed to add a URL re-write to do what the Apache version does. In Hiawatha's case it is this URLToolkit that makes the API work. So I would suggest looking into the config for Nginx to do these URL re-writes. This simple toolkit was the answer and now the API works and zmNinja works.
Code: Select all
UrlToolkit {
ToolkitID = api_rule
Match ^/zm/api Rewrite /zm/api/app/webroot/index.php$1
}
Re: Zoneminder API Not Installed?
Thanks for your response.
So you as well do not have a /usr/share/zoneminder/api folder actually present on your server? The re-write then must point http://server/zm/api to /usr/share/zoneminder/www/api?
Just trying to figure out what I need to do to get this working.
So you as well do not have a /usr/share/zoneminder/api folder actually present on your server? The re-write then must point http://server/zm/api to /usr/share/zoneminder/www/api?
Just trying to figure out what I need to do to get this working.
Re: Zoneminder API Not Installed?
I do have the folder /usr/share/zoneminder/www/api.....lets use "localhost" as the server name in this case.
I re-write the url that comes in which looks like http://localhost/zm/api and makes it look like http://localhost/zm/api/app/webroot/index.php which is the correct base URL to the /api folder on my system. You are close to getting it to work! This Nginx ZM API issue comes up once in awhile
somewhere in this forum I think someone posted a configuration for Nginx that got the API to work, at least examples how to set up the Nginx config. Maybe I can find the thread again!
I re-write the url that comes in which looks like http://localhost/zm/api and makes it look like http://localhost/zm/api/app/webroot/index.php which is the correct base URL to the /api folder on my system. You are close to getting it to work! This Nginx ZM API issue comes up once in awhile
somewhere in this forum I think someone posted a configuration for Nginx that got the API to work, at least examples how to set up the Nginx config. Maybe I can find the thread again!
Re: Zoneminder API Not Installed?
something like this:
from here : https://github.com/pliablepixels/zmNinj ... with-nginx
check out the location block on the API double check that your path to the API folder is there...as you saw my path was different in Hiawatha.
Code: Select all
location /zm/cgi-bin {
gzip off;
alias /usr/lib/cgi-bin;
include /etc/nginx/fastcgi_params;
fastcgi_param SCRIPT_FILENAME $request_filename;
fastcgi_pass unix:/var/run/fcgiwrap.socket;
}
location /zm {
gzip off;
alias /usr/share/zoneminder;
index index.php;
location ~ \.php$ {
if (!-f $request_filename) { return 404; }
expires epoch;
include /etc/nginx/fastcgi_params;
fastcgi_param SCRIPT_FILENAME $request_filename;
fastcgi_index index.php;
fastcgi_pass unix:/var/run/php5-fpm.sock;
}
location ~ \.(jpg|jpeg|gif|png|ico)$ {
access_log off;
expires 33d;
}
location /zm/api/ {
alias /usr/share/zoneminder/api;
rewrite ^/zm/api(.+)$ /zm/api/index.php?p=$1 last;
}
}
check out the location block on the API double check that your path to the API folder is there...as you saw my path was different in Hiawatha.
Re: Zoneminder API Not Installed?
Thanks for your reply. Yes, we do have a few different paths; it's the last path in your proposal that is giving me grief. As I say, there is nothing in my /usr/share/zoneminder/api folder (it doesn't exist) so that alias is my concern.
The reason that I ask my question is exactly that: is my install missing things?
I just saw the Ubuntu 17.10 API thread; it seems that some of these bugs haven't been ironed out yet at least according to that thread. I think I'll nuke Zoneminder and try again using that thread's instructions to install the 16.04 package; see if that fixes the issue.
Will report back once done.
The reason that I ask my question is exactly that: is my install missing things?
I just saw the Ubuntu 17.10 API thread; it seems that some of these bugs haven't been ironed out yet at least according to that thread. I think I'll nuke Zoneminder and try again using that thread's instructions to install the 16.04 package; see if that fixes the issue.
Will report back once done.
Re: Zoneminder API Not Installed?
Yes it looks like you are missing the entire contents of the /api folder!! So that would be best...I use the 1.30.4 stable with Puppy Linux Tahr (Ubuntu 14.04) and Xenial (Ubuntu 16.04) and it works very well. No API problems at all.
Re: Zoneminder API Not Installed?
did you try copying the /api from the zoneminder github master?
Re: Zoneminder API Not Installed?
Ok so marking this solved, and leaving my comments for the rest of the world to see (and me to find next time I screw this thing up).
To be clear, these are instructions assuming you have some form or fashion of LEMP running (as opposed to LAMP). Make sure that you've got fcgiwrap installed too.
Step 1: Follow the wiki advice at https://wiki.zoneminder.com/Ubuntu_Serv ... e_easy_way. Skip the Apache-friendly portion, and change the php settings at /etc/php/7.1/fpm/php.ini
Step 2: As per here: https://github.com/ZoneMinder/ZoneMinde ... ubuntu1604, do this:
...then, go virtually anywhere in the first "server {" section and insert this:
Save it. Sorry if this is bad form, but I cannot figure out for the life of me how to not just use the example, and if it's good enough for the GIT readme it's good enough for me.
Step 3: Edit that example file by replacing it with what's below. Key changes were to refer to php7.1-fpm.sock and the whole location /zm/api bit at the end. Also, as I wasn't sure of in this thread, the "www" is in fact the correct subfolder for everything.
Step 4: Restart Zoneminder, Nginx. Profit?
Hope this helps someone else, but if nothing else I'll be able to Google this the next time I rage-format the system. Which could be tonight, depending on how my Home-Assistant install goes.
To be clear, these are instructions assuming you have some form or fashion of LEMP running (as opposed to LAMP). Make sure that you've got fcgiwrap installed too.
Step 1: Follow the wiki advice at https://wiki.zoneminder.com/Ubuntu_Serv ... e_easy_way. Skip the Apache-friendly portion, and change the php settings at /etc/php/7.1/fpm/php.ini
Step 2: As per here: https://github.com/ZoneMinder/ZoneMinde ... ubuntu1604, do this:
Code: Select all
sudo nano /etc/nginx/sites-enabled/default
Code: Select all
include /usr/share/doc/zoneminder/examples/nginx.conf;
Step 3: Edit that example file by replacing it with what's below. Key changes were to refer to php7.1-fpm.sock and the whole location /zm/api bit at the end. Also, as I wasn't sure of in this thread, the "www" is in fact the correct subfolder for everything.
Code: Select all
sudo nano /usr/share/doc/zoneminder/examples/nginx.conf
Code: Select all
location /zm/cgi-bin {
gzip off;
alias /usr/lib/zoneminder/cgi-bin;
include /etc/nginx/fastcgi_params;
fastcgi_param SCRIPT_FILENAME $request_filename;
fastcgi_pass unix:/var/run/fcgiwrap.socket;
}
location /zm {
# if ($scheme ~ ^http:){
# rewrite ^(.*)$ https://$host$1 permanent;
# }
gzip off;
alias /usr/share/zoneminder/www;
index index.php;
location ~ \.php$ {
if (!-f $request_filename) { return 404; }
expires epoch;
include /etc/nginx/fastcgi_params;
fastcgi_param SCRIPT_FILENAME $request_filename;
fastcgi_index index.php;
fastcgi_pass unix:/var/run/php/php7.1-fpm.sock;
}
location ~ \.(jpg|jpeg|gif|png|ico)$ {
access_log off;
expires 33d;
}
location /zm/api/ {
alias /usr/share/zoneminder/www/api;
rewrite ^/zm/api(.+)$ /zm/api/index.php?p=$1 last;
}
}
Hope this helps someone else, but if nothing else I'll be able to Google this the next time I rage-format the system. Which could be tonight, depending on how my Home-Assistant install goes.
Re: [SOLVED] Zoneminder API Not Installed?
Good work.
All these solutions help. I have found the info for ways to get hiawatha and ZM to work together sometimes came from looking over the problems and fixes people using Nginx and ZM had. I used this config example to get OpenMediaVault + ZM using the Nginx webserver for both.
All these solutions help. I have found the info for ways to get hiawatha and ZM to work together sometimes came from looking over the problems and fixes people using Nginx and ZM had. I used this config example to get OpenMediaVault + ZM using the Nginx webserver for both.