API not working after install on fresh Buster system

Forum for questions and support relating to the 1.32.x releases only.
jake1164
Posts: 4
Joined: Tue Aug 01, 2017 1:13 pm

API not working after install on fresh Buster system

Post by jake1164 »

I did a fresh Debian 10 (Buster) install following the posted instructions.

Upon restarting apache and before doing anything else ZM is running, logs are green, however when you navigate to :
http://ip/zm/api/host/getVersion.json results in a Not Found page.

The API directory (/usr/share/zoneminder/www/api) has the following files / folders:
app build.properties build.xml composer.json CONTRIBUTING.md index.php lib README.md

Note that the host folder is missing.

Navigating to http://ip/zm/api/ results in the following CakePHP error:
URL rewriting is not properly configured on your server. 1) Help me configure it 2) I don't / can't use URL rewriting

I followed the instructions a second time on a fresh VM and had the same results.

I have found a few fragments of other issues with buster api's but no definitive resolution.
bbunge
Posts: 2923
Joined: Mon Mar 26, 2012 11:40 am
Location: Pennsylvania

Re: API not working after install on fresh Buster system

Post by bbunge »

I must admit that I did not check the API as I seldom use anything other than a web browser. Will try to find time to load up Debian again and see what I can find.
JoshZ17
Posts: 4
Joined: Sun Sep 10, 2017 4:05 am

Re: API not working after install on fresh Buster system

Post by JoshZ17 »

I'm having the same issue. Fresh install of Buster.
bbunge
Posts: 2923
Joined: Mon Mar 26, 2012 11:40 am
Location: Pennsylvania

Re: API not working after install on fresh Buster system

Post by bbunge »

Looks like all the files installed with correct permissions. Cake reports rewrite not working. Looking into Apache config. Seems sim to issues we had with Ubuntu 17.10.
Will continue in the morning...old guys need sleep, too.
girkers
Posts: 17
Joined: Wed Mar 22, 2017 12:08 am

Re: API not working after install on fresh Buster system

Post by girkers »

I spent a day trying buster without success and I ended up using CentOS instead.
--

Girkers
User avatar
logicos94
Posts: 3
Joined: Sun May 09, 2010 10:03 pm

Re: API not working after install on fresh Buster system

Post by logicos94 »

Hi,

Some issues too in https/http support:

I noticed this:

Code: Select all

var monitorUrl = 'https://zm.eez.fr:80/zm/index.php';
My server is behind a "nginx/proxy" with "https" protocol.
But local http Apache server listen on port "80" with "http" protocol.

"SetEnv HTTPS on" is present in my "VirtualHost" configuration.

":80" is irrelevent here.
If I remove this , It's work like expected.

Regards,
bbunge
Posts: 2923
Joined: Mon Mar 26, 2012 11:40 am
Location: Pennsylvania

Re: API not working after install on fresh Buster system

Post by bbunge »

logicos94 wrote: Sat Jul 13, 2019 10:53 am Hi,

Some issues too in https/http support:

I noticed this:

Code: Select all

var monitorUrl = 'https://zm.eez.fr:80/zm/index.php';
My server is behind a "nginx/proxy" with "https" protocol.
But local http Apache server listen on port "80" with "http" protocol.

"SetEnv HTTPS on" is present in my "VirtualHost" configuration.

":80" is irrelevent here.
If I remove this , It's work like expected.

Regards,
But does your api work?
bbunge
Posts: 2923
Joined: Mon Mar 26, 2012 11:40 am
Location: Pennsylvania

Re: API not working after install on fresh Buster system

Post by bbunge »

There are some .htaccess files missing from the /usr/share/zoneminder/api directories. This may be the key to the API not working. May take me some time to figure this out as Saturday chores take preference...
sammyke007
Posts: 9
Joined: Mon Jul 15, 2019 11:18 am

Re: API not working after install on fresh Buster system

Post by sammyke007 »

Same here, fresh Debian 10 (Buster) installation and API's not working.
Chimaera
Posts: 21
Joined: Mon Apr 15, 2019 8:13 pm

Re: API not working after install on fresh Buster system

Post by Chimaera »

bbunge wrote: Sat Jul 13, 2019 1:31 pm There are some .htaccess files missing from the /usr/share/zoneminder/api directories. This may be the key to the API not working. May take me some time to figure this out as Saturday chores take preference...
This is the answer, you need to add the following code to .htaccess in 3 places

/usr/share/zoneminder/www/api
/usr/share/zoneminder/www/api/app
/usr/share/zoneminder/www/api/app/webroot

Code: Select all

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ index.php [L]
    RewriteBase /zm/api
</IfModule>
sammyke007
Posts: 9
Joined: Mon Jul 15, 2019 11:18 am

Re: API not working after install on fresh Buster system

Post by sammyke007 »

Tnx Chimaera! ZMNinja is connected!

Zoneminder + ZMNinja working fine now on an old Dell Optiplex 780 SFF running Debian 10!
jake1164
Posts: 4
Joined: Tue Aug 01, 2017 1:13 pm

Re: API not working after install on fresh Buster system

Post by jake1164 »

Thanks! Now I can get my wife off my back about how I broke the cameras. :)
david1234
Posts: 96
Joined: Wed Jun 26, 2019 12:24 pm

Re: API not working after install on fresh Buster system

Post by david1234 »

I have the same problem using v 1.34
where do I need to add the code part?
do I need to create .htaccess file?
and then write into it the code?

this is what I have in this library

Code: Select all

pi@raspberrypi:~$ ls -lstra /usr/share/zoneminder/www/api/app/webroot/
total 28
4 -rw-r--r--  1 root root 3006 Jun  6 18:07 test.php
4 -rw-r--r--  1 root root 3170 Jun  6 18:07 index.php
4 -rw-r--r--  1 root root  372 Jun  6 18:07 favicon.ico
4 drwxr-xr-x  2 root root 4096 Jun 18 13:38 img
4 drwxr-xr-x  2 root root 4096 Jun 18 13:38 css
4 drwxr-xr-x 10 root root 4096 Jun 18 13:38 ..
4 drwxr-xr-x  4 root root 4096 Jun 18 13:38 .
can you exaplin what did you do ?

Thanks ,
martinjr85
Posts: 1
Joined: Sat Sep 18, 2021 5:27 pm

Re: API not working after install on fresh Buster system

Post by martinjr85 »

Chimaera wrote: Mon Jul 15, 2019 11:28 am
bbunge wrote: Sat Jul 13, 2019 1:31 pm There are some .htaccess files missing from the /usr/share/zoneminder/api directories. This may be the key to the API not working. May take me some time to figure this out as Saturday chores take preference...
This is the answer, you need to add the following code to .htaccess in 3 places

/usr/share/zoneminder/www/api
/usr/share/zoneminder/www/api/app
/usr/share/zoneminder/www/api/app/webroot

Code: Select all

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ index.php [L]
    RewriteBase /zm/api
</IfModule>
Thanks Chimaera! This worked on my Pi 4 running Zoneminder 1.32.3 for Raspbian
david1234
Posts: 96
Joined: Wed Jun 26, 2019 12:24 pm

Re: API not working after install on fresh Buster system

Post by david1234 »

where are the

Code: Select all

.htaccess
files?
I can't see them
when I searc them I get empty response

Code: Select all

pi@raspberrypi:~ $ sudo find /usr/share/zoneminder/ -name .htaccess
pi@raspberrypi:~ $
?
Thanks ,
Post Reply