Common Issues with Zoneminder Installation on Ubuntu
04OCT15
With some changes “in-the-works” for Ubuntu installs by the hard working volunteers who keep Zoneminder up-to-date, it was recommended
that we post fixes/instructions for some issues that continue to surface. One difference will be that the Zoneminder install will no
longer automatically install the zm database in MySQL. This document will likely grow over time but may become obsolete as procedures
become better documented.
Zoneminder Database
Versions of Zoneminder up to and including 1.28.1 in Ubuntu would automatically add the zm database to MySQL. Beginning about August
2015 the development version from the iconnor-master PPA omitted this step becoming like the Debian install process. Manually adding the database to MySQL will be To install the zm database (after doing apt-get install zoneminder) Create Zoneminder database in MySQL (Note: this also creates the default Zoneminder user and permissions in MySQL)
This next step creates a file which contained the MySQL user and password. Otherwise you will have to enter the user and password on the
command line which is not secure!
Go to the root directory
cd ~
Create a hidden password file
nano .my.cnf
Enter this content (but use your MySQL root password!)
[client] user=root password=(mysqlpass)
Ctrl+o Enter to save
CTRL+x to exit
Create database (press ENTER after each command)
mysql < /usr/share/zoneminder/db/zm_create.sql
mysql
grant select,insert,update,delete on zm.* to 'zmuser'@localhost identified by 'zmpass';
\q (enter) (to quit)
Note for upgrade from prior version of Zoneminder: The latest version from the PPA Master contains a new table. If you try to run zmupdate.pl to upgrade the database you will ge an error. You need to run the entry:
grant select,insert,update,delete,create on zm.* to 'zmuser'@localhost identified by 'zmpass';
Remove password file
rm .my.cnf
Continue with the Zoneminder installation
Getting the API to work
WARNING! If your Zoneminder is exposed to the internet make sure you have OPT_USE_AUTH enabled.
The API is needed to get Zoneminder to work with zmNinja (under development as of 1OCT15) and possibly household automation software.
The "official" documentation is here:https://github.com/pliablepixels/zmNinja/wiki/Configuring-ZoneMinder-with-API But can be done in two steps.
Enable rewrite
a2enmod rewrite
Change owner of /usr/share/zoneminder/www sub directories and files to: www-data:www-data
chown -R www-data:www-data /usr/share/zoneminder/www
Restart Apache
Testing. if you have OPT_USE_AUTH turned on make sure you are logged into Zoneminder before you try the following tests or turn off OPT_USE_AUTH.
Test to see if cake is working: http://localhost/zm/api/
Test API using: http://localhost/zm/api/host/getVersion.json Should return something like:
{ "version": "1.28.107", "apiversion": "1.28.107.1" }
Upgrades
Ubuntu 14.04 - ZM 1.26.5 to 1.28.1
Become root
sudo su
Add Repository
add-apt-repository ppa:iconnor/zoneminder
apt-get update
Stop Zoneminder
service zoneminder stop
Upgrade the installation
apt-get upgrade (may return nothing to upgrade)
apt-get dist-upgrade
You will be asked if you want to replace /etc/init.d/zoneminder. Choose "Y"
The database should update but to be sure run:
/usr/bin/zmupdate.pl
Add back the delay to allow MySQL to start before Zoneminder
nano /etc/init.d/zoneminder
Add sleep 15 as shown:
start() { sleep 15 echo -n "Starting $prog: "
Ctrl+o Enter to save
CTRL+x to exit
Start Zoneminder
service zoneminder restart
Reload Apache
service apache2 reload
Ubuntu 14.04 - ZM 1.26.5 to 1.28.107 or the latest PPA Master version
Become root
sudo su
Add Repository
add-apt-repository ppa:iconnor/zoneminder-master
apt-get update
Stop Zoneminder
service zoneminder stop
Upgrade the installation
apt-get upgrade (may return nothing to upgrade)
apt-get dist-upgrade
You will be asked if you want to replace /etc/init.d/zoneminder. Choose "Y"
The database will not automatically update. Replace "abc123" with your MySQL root password.
Change permissions in your "ZM database to allow the creation of a table
mysql -uroot -pabc123 -e "grant select,insert,update,delete,create on zm.* to 'zmuser'@localhost identified by 'zmpass';"
Run the database upgrade
/usr/bin/zmupdate.pl --version=1.26.5
Reset database permissions
mysql -uroot -pabc123 -e "grant select,insert,update,delete on zm.* to 'zmuser'@localhost identified by 'zmpass';"
Add back the delay to allow MySQL to start before Zoneminder
nano /etc/init.d/zoneminder
Add sleep 15 as shown:
start() { sleep 15 echo -n "Starting $prog: "
Ctrl+o Enter to save
CTRL+x to exit
Enable rewrite for API function
a2enmod rewrite
Start Zoneminder
service zoneminder start
Restart Apache
service apache2 restart
Open Zoneminder. Click on Options - Paths
Change PATH_ZMS to /zm/cgi-bin/nph-zms
Ubuntu 15.04 - ZM 1.26.5 to 1.28.1
Become root
sudo su
Add Repository
add-apt-repository ppa:iconnor/zoneminder
apt-get update
Stop Zoneminder
service zoneminder stop
Upgrade the installation
apt-get upgrade (may return nothing to upgrade)
apt-get dist-upgrade
You will be asked if you want to replace /etc/init.d/zoneminder. Choose "Y"
The database should update but to be sure run:
/usr/bin/zmupdate.pl
Start Zoneminder
service zoneminder start
Restart Apache
service apache restart
Ubuntu 15.04 - ZM 1.26.5 to 1.28.107 or the latest PPA Master version
Thanks to "asker" for this procedure. Original posted at: https://github.com/pliablepixels/zmNinja/wiki/Easy-Way:-Upgrading-from-non-API-package-to-API-package
Become root
sudo su
Remove old repository if you used it
add-apt-repository -r ppa:iconnor/zoneminder
Add Repository
add-apt-repository ppa:iconnor/zoneminder-master
apt-get update
Stop Zoneminder
systemctl stop zoneminder.service
Upgrade the installation
apt-get install zoneminder
The database will not automatically update. Replace "abc123" with your MySQL root password.
Change permissions in your "ZM database to allow the creation of a table
mysql -uroot -pabc123 -e "grant create,select,insert,update,delete on zm.* to 'zmuser'@localhost identified by 'zmpass';"
Run the database upgrade
/usr/bin/zmupdate.pl
Configure Apache
rm /etc/apache2/conf-enabled/zoneminder.conf
a2enmod rewrite
a2enmod cgi
a2enconf zoneminder
Fix Permissions
chown -R www-data:www-data /usr/share/zoneminder/
Restart Services
service apache2 reload
systemctl start zoneminder.service
Open Zoneminder in a browser. Click on Options - Paths
Change PATH_ZMS to /zm/cgi-bin/nph-zms
If Zoneminder does not start when you boot your server, run these commands:
systemctl stop zoneminder.service
systemctl disable zoneminder.service
systemctl enable zoneminder.service
systemctl start zoneminder.service
Reboot your server and check that Zoneminder started.