Ubuntu - HTTP Error 500 on API

Forum for questions and support relating to the 1.30.x releases only.
Post Reply
Daylights
Posts: 13
Joined: Tue Oct 02, 2018 11:24 am

Ubuntu - HTTP Error 500 on API

Post by Daylights » Tue Oct 02, 2018 3:13 pm

Hello, I've followed the guide to install Zoneminder on Ubuntu 16.04 (Easy way), which all went well. After that, I was encouraged to enable OPT_AUTH, which I could not find. I did find OPT_USE_AUTH, which is now enabled (I assume that's the same). I can successfully login http://server/zm, configure camera's en view them. I have tried the zmview app on the smartphone, works. But znNinja does not, it claims that it cannot find a valid API.
So I started to troubleshoot API, it already goes wrong at http://server/zm/api/host/getVersion.json, which gives me HTTP Error 500. Even when I login first and then open this page, it is giving me the same error. The /api/Config/database.php file is in place and all is running on the same server.

I expect it has something to do with PHP dependencies not being met, but I don't know which one. Right now I am running PHP version 7.2 on Ubuntu 16.04 LTS. I hope someone can help me out :)

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

Re: Ubuntu - HTTP Error 500 on API

Post by bbunge » Wed Oct 03, 2018 1:37 am

Drop back to PHP 7.0. The zoneminder install for Xenial does not support PHP 7.2.
If you are brave I can give you a patch that may work. We had to come up with a fix for Bionic, which uses PHP 7.2, so the fix may work for Xenial.

Daylights
Posts: 13
Joined: Tue Oct 02, 2018 11:24 am

Re: Ubuntu - HTTP Error 500 on API

Post by Daylights » Wed Oct 03, 2018 7:15 am

Hi bbunge, are you referring to the 'Zoneminder API fix'? I did read about that, haven't found it though. What does it do, does it change things to the overall PHP7.2 settings? Or just the Zoneminder (API?) settings? I think I'm brave enough ;)

If it helps, I could share the contents of /tmp/zmlogs/cake_error.log

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

Re: Ubuntu - HTTP Error 500 on API

Post by bbunge » Wed Oct 03, 2018 12:36 pm

Link to the file: https://drive.google.com/open?id=1QjvVe ... vXBASFXnNY

You should be able to use this script to "rescue" your install. Since Ubuntu 18.04 uses PHP 7.2 the procedure should work. You can also upgrade to ZM 1.32.1.

#!/bin/sh
clear
read -p "This script rescues Zoneminder 1.30.4 after an upgrade from Ubuntu 16.04 to Ubuntu 18.04
Press Enter to continue or Ctrl + c to quit" nothing
clear
read -p "You must be logged in as root using sudo su ...
Press Enter to continue or Ctrl + c to quit" nothing
clear


read -p "Next we will download and apply the fixed api package. This may take a minute to connect
Press enter to continue" nothing

wget --no-check-certificate 'https://docs.google.com/uc?export=downl ... vXBASFXnNY' -O /tmp/api.fixed.tar.gz
tar -zxvf /tmp/api.fixed.tar.gz -C /tmp/
mv /usr/share/zoneminder/www/api /usr/share/zoneminder/www/api.org
mv /tmp/api /usr/share/zoneminder/www/api
chown -R www-data:www-data /usr/share/zoneminder/
read -p "Next we will add time zone to PHP config files.
Press enter to continue" nothing
awk '$0="date.timezone = "$0' /etc/timezone >> /etc/php/7.2/apache2/php.ini
clear
read -p "Now we will make sure Apache is configured for Zoneminder and restart it.
Press enter to continue" nothing
adduser www-data video
a2enmod cgi
a2enconf zoneminder
a2enmod rewrite
chown -R www-data:www-data /usr/share/zoneminder/
service apache2 reload
clear
read -p "Zoneminder should now work!.
Press enter to continue" nothing

Daylights
Posts: 13
Joined: Tue Oct 02, 2018 11:24 am

Re: Ubuntu - HTTP Error 500 on API

Post by Daylights » Thu Oct 04, 2018 6:23 am

That worked great! I just did the lines step by step, I already knew I had most of it in place. Right after this, /getVerion.json shows me

{"version":"1.30.4","apiversion":"1.0"}

and now zmNinja works as well :D

Thanks so much! Btw, are there any benefits omg upgrading to 1.32.1 on Xenial? I am planning migrating to a new Bionic install in a couple of months, since I have been dist-upgrading since 12.04 and I guess starting fresh would benefit me more.

Daylights
Posts: 13
Joined: Tue Oct 02, 2018 11:24 am

Re: Ubuntu - HTTP Error 500 on API

Post by Daylights » Thu Oct 04, 2018 9:22 am

1 small issue I found with zmNinja, it seems to loose the connection when I reopen te app. Lost show 401 Not authenticated, when I reconfigure the authentication it works again. So it seems like the auth. token is not being refreshed correctly?

[edit]

This issue seems to have been resolved by itself, perhaps a reboot was key?

Post Reply

Who is online

Users browsing this forum: linuxnutt and 3 guests