Zoneminder 1.30.4 API not working on FreeBSD
Zoneminder 1.30.4 API not working on FreeBSD
I have installed zoneminder directly into a FreeNAS jail using the following guide and a few tweaks to get almost everything working correctly. Unfortunately one thing is not working, the APIs. To reduce overhead I really want to run zoneminder through the jail on my server rather than in a VM. I have already set it up once on a VM and was not very please with the performance/scalability versus the jail installation.
https://forums.freenas.org/index.php?th ... jail.62135
When testing the APIs, by going to "http://server/api/host/getVersion.json", I receive a 404 Not found error.
https://github.com/pliablepixels/zmNinj ... work-on-ZM
Something to note is that the directory structure of the FreeBSD jail version is different than an Ubuntu VM install. The address of my zoneminder installation does not require the "zm" at the end of the URL. Additionally, the API folder is in a different location "/jails/zm/usr/local/www/zoneminder/api". I have searched everywhere to see if I can find a solution to get the APIs working and have not found a clear cut answer. I am hoping that someone may be able to help me figure out if I am missing a dependency or something that is not allowing the APIs to work. Any help is greatly appreciated.
The closest thing to a solution that I have found is the below thread, but I am not sure what to do to resolve the issue.
viewtopic.php?t=26131
https://forums.freenas.org/index.php?th ... jail.62135
When testing the APIs, by going to "http://server/api/host/getVersion.json", I receive a 404 Not found error.
https://github.com/pliablepixels/zmNinj ... work-on-ZM
Something to note is that the directory structure of the FreeBSD jail version is different than an Ubuntu VM install. The address of my zoneminder installation does not require the "zm" at the end of the URL. Additionally, the API folder is in a different location "/jails/zm/usr/local/www/zoneminder/api". I have searched everywhere to see if I can find a solution to get the APIs working and have not found a clear cut answer. I am hoping that someone may be able to help me figure out if I am missing a dependency or something that is not allowing the APIs to work. Any help is greatly appreciated.
The closest thing to a solution that I have found is the below thread, but I am not sure what to do to resolve the issue.
viewtopic.php?t=26131
Re: Zoneminder 1.30.4 API not working on FreeBSD
the not found error seems to indicate a URL re-write is not occurring as expected. I run ZM with a Hiawatha web server and needed to make a UrlToolkit that does the URL re-writes similar to what happens in Apache. Possibly check the paths that the re-write rule creates for the api access. You can add the pieces needed to rewrite /jails/zm/usr/local/www/zoneminder/api to a workable url.
the Hiawatha rule looks like this:
maybe look in the /usr/share/zoneminder/www/api/.htaccess file:
and change the RewriteBase /zm/api to match your url /jails/zm/usr/local/www/zoneminder/api
see if that does it.
the Hiawatha rule looks like this:
Code: Select all
UrlToolkit {
ToolkitID = api_rule
Match ^/zm/api Rewrite /zm/api/app/webroot/index.php$1
}
Code: Select all
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^$ app/webroot/ [L]
RewriteRule (.*) app/webroot/$1 [L]
RewriteBase /zm/api
</IfModule>
see if that does it.
Re: Zoneminder 1.30.4 API not working on FreeBSD
what version of PHP are you using?
Re: Zoneminder 1.30.4 API not working on FreeBSD
I attempted to change the .htaccess file in the api directory. I rebooted apache and zoneminder then re-tested, but to no avail.rockedge wrote: ↑Wed Apr 18, 2018 3:21 pm maybe look in the /usr/share/zoneminder/www/api/.htaccess file:and change the RewriteBase /zm/api to match your url /jails/zm/usr/local/www/zoneminder/apiCode: Select all
<IfModule mod_rewrite.c> RewriteEngine on RewriteRule ^$ app/webroot/ [L] RewriteRule (.*) app/webroot/$1 [L] RewriteBase /zm/api </IfModule>
see if that does it.
I appear to be missing files and folders in the api directory. To my knowledge, I should have a hosts folder located in the api directory with files in it, but there is no hosts folder.
I should also mention that everything else appears to be working with the web interface, viewing monitors, viewing events, etc.
Respectfully,
Re: Zoneminder 1.30.4 API not working on FreeBSD
After checking the PHP version using
Code: Select all
php -i
Re: Zoneminder 1.30.4 API not working on FreeBSD
no there will be no actual "host" folder. This is a controller name in the API, this controller code has the functions like "getVersion" in it.
There is a case of missing folders that are talked about on this forum but they are cache folders that did not get installed. That could also be a problem and was fixed just by adding the missing folders but I think it is a re-write problem and the API is being found.
what happens when you use this url? http://your-zm-server/zm/api in your case http://your-zm-server/api ?
what is the error?
There is a case of missing folders that are talked about on this forum but they are cache folders that did not get installed. That could also be a problem and was fixed just by adding the missing folders but I think it is a re-write problem and the API is being found.
what happens when you use this url? http://your-zm-server/zm/api in your case http://your-zm-server/api ?
what is the error?
Re: Zoneminder 1.30.4 API not working on FreeBSD
go to /usr/share/zoneminder/www/api/app/Config/core.php and look at line 34
and change the 0 to a 2. this will enable more error reporting and allow the url /zm/api (or equivalent to work)
then try the url http://your-zm-server/zm/api or in your case http://your-zm-server/api
Code: Select all
Configure::write('debug', 0);
then try the url http://your-zm-server/zm/api or in your case http://your-zm-server/api
Re: Zoneminder 1.30.4 API not working on FreeBSD
example of the folder structure of the API:
Re: Zoneminder 1.30.4 API not working on FreeBSD
@rockedge, you are correct, it looks like a rewrite issue. Any thoughts?
Also, I really appreciate you taking the time to help me out on this! Thanks!
Also, I really appreciate you taking the time to help me out on this! Thanks!
Re: Zoneminder 1.30.4 API not working on FreeBSD
I managed to fix the rewrite issue. In my system httpd.conf file, the line was commented out. I removed the proceeding "#" as explained here:
https://book.cakephp.org/2.0/en/install ... iting.html
Additionally, I had to change my .htaccess files in the directories api and api/app to look like this:
I am still having a permission issue with CakePHP as you can see from the below screenshot. I am not sure what permissions I need to change. Any thoughts?
Code: Select all
LoadModule rewrite_module libexec/apache2/mod_rewrite.so
https://book.cakephp.org/2.0/en/install ... iting.html
Additionally, I had to change my .htaccess files in the directories api and api/app to look like this:
Code: Select all
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^$ webroot/ [L]
RewriteRule (.*) webroot/$1 [L]
RewriteBase /api
</IfModule>
I am still having a permission issue with CakePHP as you can see from the below screenshot. I am not sure what permissions I need to change. Any thoughts?
Re: Zoneminder 1.30.4 API not working on FreeBSD
it is starting to look good. the error you are seeing I think, is from cakephp trying to write a log file in a folder someplace that does not have the permissions for www-data to write to it and so it does not exist. check that the directory the log file is writing to has the correct permissions and exists.
what does the URL /zm/api/host/getVersion.json do now?
what does the URL /zm/api/host/getVersion.json do now?
Re: Zoneminder 1.30.4 API not working on FreeBSD
look in /usr/share/zoneminder/www/api/app/Config/bootstrap.php around line 100
maybe one of these paths to the log directory in question,
maybe one of these paths to the log directory in question,
Code: Select all
App::uses('CakeLog', 'Log');
CakeLog::config('debug', array(
'engine' => 'File',
'types' => array('notice', 'info', 'debug'),
'file' => 'cake_debug',
'path' => '/var/log/zm/'
));
CakeLog::config('error', array(
'engine' => 'File',
'types' => array('warning', 'error', 'critical', 'alert', 'emergency'),
'file' => 'cake_error',
'path' => '/var/log/zm/'
));
CakeLog::config('custom_path', array(
'engine' => 'File',
'path' => '/var/log/zm/'
));
Re: Zoneminder 1.30.4 API not working on FreeBSD
When testing the APIs, by going to http://server/api/host/getVersion.json, I am still receiving a 404 Not found error. Again, because this is directly in a FreeNAS Jail, the /zm/ is not needed for the correct path. The path to my server is http://server/ without the added /zm/ directory
Looking at the api/app/Config/bootstrap.php, the paths you mentioned look to be mostly correct. But the file is a little different than what you have:
I tried switching this to reflect yours but it seems to break everything. Switching it back corrected it, but I am still left with the mkdir permissions error from CakePHP. Looking at my Zoneminder installation it looks like the path above "/var/log/zm" is mostly correct, but I do not have a /zm/ directory inside of my "/var/log" directory.
Looking at the api/app/Config/bootstrap.php, the paths you mentioned look to be mostly correct. But the file is a little different than what you have:
Code: Select all
CakeLog::config('debug', array(
'engine' => 'File',
'types' => array('notice', 'info', 'debug'),
'file' => 'cake_debug',
));
CakeLog::config('error', array(
'engine' => 'File',
'types' => array('warning', 'error', 'critical', 'alert', 'emergency'),
'file' => 'cake_error',
));
CakeLog::config('custom_path', array(
'engine' => 'File',
'path' => '/var/log/zm'
));
Re: Zoneminder 1.30.4 API not working on FreeBSD
I am very close on this. The mkdir CakePHP issue is the only thing that looks to be preventing the API from working. I am not sure if this is a permission error or an error in a config file. Any guidance would be greatly appreciated.