Page 4 of 4

Re: 1.30.2 upgrade breaks API access

Posted: Tue May 30, 2017 4:29 pm
by blueice89
I tried the above to install apcu, but get errors.

I am trying to get my mobile app to work, it keeps saying invalid API.
API access failed, please make sure APIs configured correctly.

I tested:
zm/api/monitors.json , this works zm/api/events.json, works as well
I can get the version

a) Distro: Ubuntu 14.04
b) ZM : 1.30.4
c) I am using aws machine and to upgrade i just had some notice that said I could upgrade in my UI and said okay.

Re: 1.30.2 upgrade breaks API access

Posted: Sun Jul 09, 2017 4:16 pm
by freff

I am stuck running 1.30.2 because upgrading to 1.30.4 or 1.31.x breaks my API access. I am running Ubuntu 16.04

xxxx@xxxx:/var/log/apache2$ sudo apt-get install php5-apcu
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package php5-apcu

xxxx@xxxx:/var/log/apache2$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 16.04.2 LTS
Release: 16.04
Codename: xenial

From my apache.log file I get this when trying to access API's.
[Sun Jul 09 12:10:56.039929 2017] [:error] [pid 22210] [client] PHP Fatal error: Call to undefined function apc_fetch() in /usr/share/zoneminder/www/api/lib/Cake/Cache/Engine/ApcEngine.php on line 78

Several posts seem to indicate that php5-apcu is what is needed, but I can't figure out how to install that on Ubuntu 16.04. Can anyone help?

Re: 1.30.2 upgrade breaks API access

Posted: Sun Jul 09, 2017 4:37 pm
by rockedge
Make sure that the php5-apcu module is activated! Simply put, check that the apcu.ini is symlinked from /etc/php5/mods-available/apcu.ini to /etc/php5/cgi/conf.d/apcu.ini

you can use a2enmod to do this.
important: restart the Apache server!

then in a browser test the API by logging into ZM and then using the URL -> http://your_zm_server_ip/zm/api/host/getVersion.json
you should see something like this ->

Code: Select all

I hope this helps.

Re: 1.30.2 upgrade breaks API access

Posted: Sun Jul 09, 2017 6:06 pm
by freff
Hi thanks for the advice but unfortunately it appears that I do not have php5-apcu installed. It seems that it is not possible to install that package on Ubuntu 16.04?

Re: 1.30.2 upgrade breaks API access

Posted: Sun Jul 09, 2017 6:16 pm
by rockedge
PHP 7 ships with a built-in opcode cacher for caching and optimizing PHP intermediate code, it has the name 'opcache' and is available in the package php7.0-opcache. It is strongly recommended to have an Opcache installed to speed up your PHP page. Besides opcache, I will install APCu which is a compatibility wrapper for opcache to provide the functions of the APC cache, an often used caching system in php 5.x versions and many CMS systems still use it. ... 6-04-lamp/
what version of PHP is running on your system?

I think you can open a terminal and use for PHP 7 ->

Code: Select all

apt-get -y install php7.0-opcache php-apcu
and then enable the module and restart Apache.

Code: Select all

systemctl restart apache2

Re: 1.30.2 upgrade breaks API access

Posted: Sun Jul 09, 2017 7:33 pm
by freff
thanks for the link. It took multiple steps. I'm not sure what I did, but everything seems to be working now. In case others find this problem, the steps to resolve were something like this.

sudo apt-get -f install
apt-get -y install php7.0-opcache php-apcu
apt-get -y install php7.0 libapache2-mod-php7.0 -f
had to edit some timezone settings in a php.ini config file
sudo apt install libapache2-mod-php
sudo a2dismod php5
sudo a2enmod php7.0
sudo service apache2 restart

thanks again, Rockedge!

Re: 1.30.2 upgrade breaks API access

Posted: Mon Jul 10, 2017 1:55 am
by rockedge