API not working with 1.34.21 and CakePHP 2.10.11
Posted: Fri Nov 13, 2020 10:15 pm
Hi,
So basics first. Zoneminder 1.34.21 (Connors PPA), CakePHP 2.10.11 and PHP 7.4. Running on a raspberry pi 4 model B 8GB on Ubuntu 20.10. The normal zoneminder web interface is working fine and I'm not getting any errors in the zoneminder log. I have ZM authentication setup and that's working fine.
I've been struggling with this issue for days, basically and initially, I get the infamous CakePHP error "The requested address '/zm/api/; was not found on this server when I try to access localhost/zm/api.
Oddly enough, I can get the expected correct page if I enable level 2 debugging by editing /usr/share/zoneminder/www/api/app/Config/core.php "Configure::write('debug', 2); which was previously a '0' instead of a '2'.
I then get the expected release notes for CakePHP 2.10.11 followed by the highlighted green bands that say "Your version of PHP is 5.2.8 or higher", "Your tmp directory is writable" (it wasn't at first but that was fixed after I chown'ed www-data:www-data /var/cache/zoneminder/temp which had root:root ownership. "The ApcEngine is being used for core caching", Your database configuration file is present", CakePHP is able to connect to the database" and finally "DebugKit is not installed", which presumably isn't mandatory. So all the above is highlighted in green and so appears ok. Now if you scroll right down to the bottom of the page you should see SQL query information, at least I do on other older installations but not here. There is no SQL query information. Is that a clue?
Also if I try to access http://localhost/zm/api/host/getVersion.json I just get the default apache2 message "Not Found, The requested URL was not found on this server.
Multiple de-installs and re-installs haven't fixed the problem and I'm starting to wonder if it's some issue with the fact I'm using CakePHP 2.10.11 instead of 2.10.8?
The zoneminder installation procedure I used was as follows, taken from the zoneminder installation guide for Ubuntu 18.04 here https://zoneminder.readthedocs.io/en/la ... -04-bionic
add-apt-repository ppa:iconnor/zoneminder-1.34
apt-get update
apt-get upgrade
apt-get dist-upgrade
rm /etc/mysql/my.cnf (this removes the current symbolic link)
cp /etc/mysql/mysql.conf.d/mysqld.cnf /etc/mysql/my.cnf
nano /etc/mysql/my.cnf
In the [mysqld] section add the following
sql_mode = NO_ENGINE_SUBSTITUTION
systemctl restart mysql
apt-get install zoneminder
mysql -uroot -p < /usr/share/zoneminder/db/zm_create.sql
mysql -uroot -p -e "grant lock tables,alter,drop,select,insert,update,delete,create,index,alter routine,create routine, trigger,execute on zm.* to 'zmuser'@localhost identified by 'zmpass';" (The second mysql failed with a authentication issue but by repeating by removing the "identified by 'zmpass'" it then worked.
chmod 740 /etc/zm/zm.conf
chown root:www-data /etc/zm/zm.conf
chown -R www-data:www-data /usr/share/zoneminder/
a2enmod cgi
a2enmod rewrite
a2enconf zoneminder
a2enmod expires
a2enmod headers
systemctl enable zoneminder
systemctl start zoneminder
nano /etc/php/7.4/apache2/php.ini
with date.timezone = Europe/London
systemctl reload apache2
Any clues as to how I can diagnose this problem? It seems to be that CakePHP isn't translating the request for http:/localhost/zm/api/host/getVersion.json to the appropriate route?
As mentioned early, is the fact that the sql query isn't shown at the bottom of the page when you access http://localhost/zm/api/.
From the command line I can log into mysql with the command 'mysql -uzmuser -pzmpass' then 'use zm;' and 'show tables' so I know the mysql login is working ok.
Any help is much appreciated, especially from CakePHP experts.
So basics first. Zoneminder 1.34.21 (Connors PPA), CakePHP 2.10.11 and PHP 7.4. Running on a raspberry pi 4 model B 8GB on Ubuntu 20.10. The normal zoneminder web interface is working fine and I'm not getting any errors in the zoneminder log. I have ZM authentication setup and that's working fine.
I've been struggling with this issue for days, basically and initially, I get the infamous CakePHP error "The requested address '/zm/api/; was not found on this server when I try to access localhost/zm/api.
Oddly enough, I can get the expected correct page if I enable level 2 debugging by editing /usr/share/zoneminder/www/api/app/Config/core.php "Configure::write('debug', 2); which was previously a '0' instead of a '2'.
I then get the expected release notes for CakePHP 2.10.11 followed by the highlighted green bands that say "Your version of PHP is 5.2.8 or higher", "Your tmp directory is writable" (it wasn't at first but that was fixed after I chown'ed www-data:www-data /var/cache/zoneminder/temp which had root:root ownership. "The ApcEngine is being used for core caching", Your database configuration file is present", CakePHP is able to connect to the database" and finally "DebugKit is not installed", which presumably isn't mandatory. So all the above is highlighted in green and so appears ok. Now if you scroll right down to the bottom of the page you should see SQL query information, at least I do on other older installations but not here. There is no SQL query information. Is that a clue?
Also if I try to access http://localhost/zm/api/host/getVersion.json I just get the default apache2 message "Not Found, The requested URL was not found on this server.
Multiple de-installs and re-installs haven't fixed the problem and I'm starting to wonder if it's some issue with the fact I'm using CakePHP 2.10.11 instead of 2.10.8?
The zoneminder installation procedure I used was as follows, taken from the zoneminder installation guide for Ubuntu 18.04 here https://zoneminder.readthedocs.io/en/la ... -04-bionic
add-apt-repository ppa:iconnor/zoneminder-1.34
apt-get update
apt-get upgrade
apt-get dist-upgrade
rm /etc/mysql/my.cnf (this removes the current symbolic link)
cp /etc/mysql/mysql.conf.d/mysqld.cnf /etc/mysql/my.cnf
nano /etc/mysql/my.cnf
In the [mysqld] section add the following
sql_mode = NO_ENGINE_SUBSTITUTION
systemctl restart mysql
apt-get install zoneminder
mysql -uroot -p < /usr/share/zoneminder/db/zm_create.sql
mysql -uroot -p -e "grant lock tables,alter,drop,select,insert,update,delete,create,index,alter routine,create routine, trigger,execute on zm.* to 'zmuser'@localhost identified by 'zmpass';" (The second mysql failed with a authentication issue but by repeating by removing the "identified by 'zmpass'" it then worked.
chmod 740 /etc/zm/zm.conf
chown root:www-data /etc/zm/zm.conf
chown -R www-data:www-data /usr/share/zoneminder/
a2enmod cgi
a2enmod rewrite
a2enconf zoneminder
a2enmod expires
a2enmod headers
systemctl enable zoneminder
systemctl start zoneminder
nano /etc/php/7.4/apache2/php.ini
with date.timezone = Europe/London
systemctl reload apache2
Any clues as to how I can diagnose this problem? It seems to be that CakePHP isn't translating the request for http:/localhost/zm/api/host/getVersion.json to the appropriate route?
As mentioned early, is the fact that the sql query isn't shown at the bottom of the page when you access http://localhost/zm/api/.
From the command line I can log into mysql with the command 'mysql -uzmuser -pzmpass' then 'use zm;' and 'show tables' so I know the mysql login is working ok.
Any help is much appreciated, especially from CakePHP experts.