Page 1 of 2

API not working after install on fresh Buster system

Posted: Fri Jul 12, 2019 11:37 am
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.

Re: API not working after install on fresh Buster system

Posted: Fri Jul 12, 2019 8:39 pm
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.

Re: API not working after install on fresh Buster system

Posted: Sat Jul 13, 2019 2:07 am
by JoshZ17
I'm having the same issue. Fresh install of Buster.

Re: API not working after install on fresh Buster system

Posted: Sat Jul 13, 2019 2:26 am
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.

Re: API not working after install on fresh Buster system

Posted: Sat Jul 13, 2019 10:01 am
by girkers
I spent a day trying buster without success and I ended up using CentOS instead.

Re: API not working after install on fresh Buster system

Posted: Sat Jul 13, 2019 10:53 am
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,

Re: API not working after install on fresh Buster system

Posted: Sat Jul 13, 2019 12:21 pm
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?

Re: API not working after install on fresh Buster system

Posted: Sat Jul 13, 2019 1:31 pm
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...

Re: API not working after install on fresh Buster system

Posted: Mon Jul 15, 2019 11:19 am
by sammyke007
Same here, fresh Debian 10 (Buster) installation and API's not working.

Re: API not working after install on fresh Buster system

Posted: Mon Jul 15, 2019 11:28 am
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>

Re: API not working after install on fresh Buster system

Posted: Mon Jul 15, 2019 11:37 am
by sammyke007
Tnx Chimaera! ZMNinja is connected!

Zoneminder + ZMNinja working fine now on an old Dell Optiplex 780 SFF running Debian 10!

Re: API not working after install on fresh Buster system

Posted: Tue Jul 16, 2019 11:13 pm
by jake1164
Thanks! Now I can get my wife off my back about how I broke the cameras. :)

Re: API not working after install on fresh Buster system

Posted: Wed Jul 22, 2020 2:43 pm
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 ,

Re: API not working after install on fresh Buster system

Posted: Sat Sep 18, 2021 5:29 pm
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

Re: API not working after install on fresh Buster system

Posted: Sun Dec 19, 2021 8:07 am
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 ,