API not working after install on fresh Buster system

Forum for questions and support relating to the 1.32.x releases only.
User avatar
kitkat
Posts: 193
Joined: Sun Jan 27, 2019 5:17 pm

Re: API not working after install on fresh Buster system

Post by kitkat »

david1234 wrote: Sun Dec 19, 2021 8:07 am 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 ,
There aren't any in the default distribution so they'll need to be created manually with nano or vim or something.
david1234
Posts: 96
Joined: Wed Jun 26, 2019 12:24 pm

Re: API not working after install on fresh Buster system

Post by david1234 »

OK
this is what I have done:

1. created 3 file caled ".htaccess" in all 3 places

Code: Select all

/usr/share/zoneminder/www/api
/usr/share/zoneminder/www/api/app
/usr/share/zoneminder/www/api/app/webroot
2. In all of them I wrote this configuration?

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>
3. reboot apache2 and zonminder service

4. zoneminder is working (get video and monitor is running)

but this is what I get

Code: Select all

pi@raspberrypi:~ $ sudo curl -X POST http://10.0.0.113/zm/api/getVersion.json
{
    "code": 404,
    "name": "Controller class GetVersionController could not be found.",
    "message": "Controller class GetVersionController could not be found.",
    "url": "\/zm\/api\/getVersion.json"
}pi@raspberrypi:~ $ sudo curl -X POST http://10.0.0.113/zm/host/api/getVersion.json
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>404 Not Found</title>
</head><body>
<h1>Not Found</h1>
<p>The requested URL was not found on this server.</p>
<hr>
<address>Apache/2.4.38 (Raspbian) Server at 10.0.0.113 Port 80</address>
</body></html>
do I need to change anything else? another file?

Thanks ,
david1234
Posts: 96
Joined: Wed Jun 26, 2019 12:24 pm

Re: API not working after install on fresh Buster system

Post by david1234 »

anyone know?
User avatar
kitkat
Posts: 193
Joined: Sun Jan 27, 2019 5:17 pm

Re: API not working after install on fresh Buster system

Post by kitkat »

Make sure that overrides are enabled in the httpd/Apache config file - They aren't by default in my copy here on CentOS.

Make a backup of the current conf:

Code: Select all

cp -p /etc/zm/www/zoneminder.conf /etc/zm/www/zoneminder.conf~
Open the original in a text editor and look for this block:

Code: Select all

Alias /zm "/usr/share/zoneminder/www"
<Directory "/usr/share/zoneminder/www">
    # explicitly set index.php as the only directoryindex
    DirectoryIndex disabled
    DirectoryIndex index.php
    SSLRequireSSL
    Options -Indexes +MultiViews +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>
Change the line that says AllowOverride None to AllowOverride All and then save the file and restart Apache.
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 don't have this file
how could it be ?

Code: Select all

cp -p /etc/zm/www/zoneminder.conf /etc/zm/www/zoneminder.conf~   
cp: cannot stat '/etc/zm/www/zoneminder.conf': No such file or directory
this is what I have:

Code: Select all

pi@raspberrypi:~ $ ls -lstrah /etc/zm/
total 40K
4.0K -rwxr-----   1 root www-data 1.8K Feb 11  2019 zm.conf
4.0K drwxr-xr-x   2 root root     4.0K Nov  1 12:40 conf.d
 16K -rw-r--r--   1 root root      15K Nov  1 12:40 core.php
4.0K drwxr-xr-x   3 root root     4.0K Nov  1 12:40 .
 12K drwxr-xr-x 126 root root      12K Nov  1 13:29 ..
do you mean to change the zm.conf?
Post Reply