Difference between revisions of "Ubuntu Server 14.04 64-bit with Zoneminder 1.28.1 the easy way"

From ZoneMinder Wiki
Jump to navigationJump to search
Line 1: Line 1:
Zoneminder 1.28.107 on Ubuntu 14.04-3
Zoneminder 1.28.1 on Ubuntu 14.04. Should also works on Ubuntu 14.10 running init.


'''This procedure has been updated as of 15OCT15 to use the most recent version of Zoneminder, 1.28.107, which includes the API.'''
22OCT15 Returned this to original version as 1.28.1 has been returned to the iconnor PPA


I did this install on a 64 BIT server but it should work on 32 BIT. As of 20FEB15 I have tested this with a local USB camera and a remote h.264 camera with Ffmpeg and Libvlc.
I did this install on a 64 BIT server but it should work on 32 BIT. As of 20FEB15 I have tested this with a local USB camera and a remote h.264 camera with Ffmpeg and Libvlc.
Line 11: Line 11:
Log in then become root:
Log in then become root:


sudo su
sudo su


If you used the server install CD
If you used the server install CD
apt-get update
 
apt-get upgrade
apt-get update
apt-get dist-upgrade
apt-get upgrade
apt-get dist-upgrade


Optional: Set static IP address
Optional: Set static IP address


nano /etc/network/interfaces
nano /etc/network/interfaces


Make changes similar to this:
Make changes similar to this:


auto eth0
auto eth0
iface eth0 inet static
iface eth0 inet static
  address 192.168.1.10
  address 192.168.1.10
  netmask 255.255.255.0
  netmask 255.255.255.0
  gateway 192.168.1.1
  gateway 192.168.1.1
  dns-nameservers 192.168.1.1
  dns-nameservers 192.168.1.1


Note: for Ubuntu 14.04 the resolv.conf is dynamically assigned. The "dns-servers" entry in the interfaces file will set the DNS Multiple DNS server entries can be used.
Note: for Ubuntu 14.04 the resolv.conf is dynamically assigned. The "dns-servers" entry in the interfaces file will set the DNS Multiple DNS server entries can be used.
Line 35: Line 36:
Reboot server
Reboot server


Log in and become root  
Log in and become root


sudo su
sudo su


Suggested changes to MySQL
Suggested changes to MySQL


For most of you Zoneminder will run just fine with the default MySQL settings. There are a couple of settings that may, in time, provide beneficial especially if you have a number of cameras and many events with a lot of files. One setting I recommend is the "innodb_file_per_table" This will be a default setting in MySQL 5.6 but should be added in MySQL 5.5 which comes with Ubuntu 14.04. A description can be found here: http://dev.mysql.com/doc/refman/5.5/en/innodb-multiple-tablespaces.html  
For most of you Zoneminder will run just fine with the default MySQL settings. There are a couple of settings that may, in time, provide beneficial especially if you have a number of cameras and many events with a lot of files. One setting I recommend is the "innodb_file_per_table" This will be a default setting in MySQL 5.6 but should be added in MySQL 5.5 which comes with Ubuntu 14.04. A description can be found here: http://dev.mysql.com/doc/refman/5.5/en/innodb-multiple-tablespaces.html


To add "innodb_file_per_table" edit the my.cnf file:
To add "innodb_file_per_table" edit the my.cnf file:


nano /etc/mysql/my.cnf
nano /etc/mysql/my.cnf


Under [mysqld] add
Under [mysqld] add


innodb_file_per_table
innodb_file_per_table


Ctrl+o Enter to save
Ctrl+o Enter to save
Line 57: Line 58:
Restart MySQL
Restart MySQL


service mysql restart
service mysql restart


As you add cameras to your system and the events build up you may need to increase the size of the "innodb_buffer_pool_size" when this setting runs out of space your system may act like it is out of disk space. One way to check this is to install mysqltuner and run it from the command line. When the results are shown you can edit the my.cnf file and change the buffer size. The default "innodb_buffer_pool_size" is 128M. In the ZM forum I have found a recommended setting of 256M. My production server required a setting greater than 410M. Install and run mysqltuner to determine the recommended size for your system. Be sure to restart MySQL after making changes.
As you add cameras to your system and the events build up you may need to increase the size of the "innodb_buffer_pool_size" when this setting runs out of space your system may act like it is out of disk space. One way to check this is to install mysqltuner and run it from the command line. When the results are shown you can edit the my.cnf file and change the buffer size. The default "innodb_buffer_pool_size" is 128M. In the ZM forum I have found a recommended setting of 256M. My production server required a setting greater than 410M. Install and run mysqltuner to determine the recommended size for your system. Be sure to restart MySQL after making changes.
Line 63: Line 64:
Add Repository
Add Repository


add-apt-repository ppa:iconnor/zoneminder
add-apt-repository ppa:iconnor/zoneminder


apt-get update
apt-get update


Install Zoneminder
Install Zoneminder


apt-get install zoneminder
apt-get install zoneminder


Create Zoneminder database in MySQL (Note: this also creates the default Zoneminder user and permissions in MySQL)
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  
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!
command line which is not secure!
Line 79: Line 80:
Go to the root dir
Go to the root dir


cd ~
cd ~


Create a hidden password file
Create a hidden password file


nano .my.cnf
nano .my.cnf


Enter this content but use your MySQL password instead of mysqlpass
Enter this content


[client]
[client]
user=root
user=root
password=mysqlpass
password=(mysqlpass)


Ctrl+o Enter to save
Ctrl+o Enter to save
Line 97: Line 98:
Create database
Create database


mysql < /usr/share/zoneminder/db/zm_create.sql  
mysql < /usr/share/zoneminder/db/zm_create.sql  
 
mysql
 
grant select,insert,update,delete on zm.* to 'zmuser'@localhost identified by 'zmpass';


mysql -e "grant select,insert,update,delete,create on zm.* to 'zmuser'@localhost identified by 'zmpass';"
\q (enter) (to quit)


Remove password file
Remove password file


rm .my.cnf
rm .my.cnf


Set permissions of /etc/zm/zm.conf to root:www-data 740
Set permissions of /etc/zm/zm.conf to root:www-data 740


chmod 740 /etc/zm/zm.conf
chmod 740 /etc/zm/zm.conf


chown root:www-data /etc/zm/zm.conf
chown root:www-data /etc/zm/zm.conf


Add delay to allow MySQL to start before Zoneminder
Add delay to allow MySQL to start before Zoneminder


nano /etc/init.d/zoneminder
nano /etc/init.d/zoneminder


Add sleep 15 as shown:
Add sleep 15 as shown:


start() {
start() {
      sleep 15
    sleep 15
      echo -n "Starting $prog: "
    echo -n "Starting $prog: "


Ctrl+o Enter to save
Ctrl+o Enter to save


CTRL+x to exit  
CTRL+x to exit




Create a new user
Create a new user


adduser www-data video
adduser www-data video


Enable CGI Zoneminder and Rewrite configuration in Apache.
Enable CGI and Zoneminder configuration in Apache.


a2enmod cgi
a2enmod cgi


a2enconf zoneminder
a2enconf zoneminder


a2enmod rewrite
a2enmod rewrite


Start Zoneminder
Start Zoneminder


service zoneminder start
service zoneminder start


Add timezone to PHP
Add timezone to PHP


nano /etc/php5/apache2/php.ini
nano /etc/php5/apache2/php.ini


Search for [Date] and make changes as follows for your time zone (Check http://php.net/date.timezone for the correct format to use)
Search for [Date] and make changes as follows for your time zone


[Date]
[Date]
; Defines the default timezone used by the date functions
; Defines the default timezone used by the date functions
; http://php.net/date.timezone
; http://php.net/date.timezone
date.timezone = America/New_York
date.timezone = America/New_York


Ctrl+o Enter to save
Ctrl+o Enter to save


CTRL+x to exit
CTRL+x to exit


Restart Apache
Restart Apache


service apache2 reload
service apache2 reload
 




Line 167: Line 171:




cd /usr/src && wget http://www.andywilcock.com/code/cambozola/cambozola-latest.tar.gz
cd /usr/src && wget http://www.andywilcock.com/code/cambozola/cambozola-latest.tar.gz


tar -xzvf cambozola-latest.tar.gz
tar -xzvf cambozola-latest.tar.gz


replace 936 in the next line with cambozola version downloaded
replace 936 in the next line with cambozola version downloaded


cp cambozola-0.936/dist/cambozola.jar /usr/share/zoneminder/www
cp cambozola-0.936/dist/cambozola.jar /usr/share/zoneminder


You should now be able to access the web server using https://servername
You should now be able to access the web server using https://servername
Line 179: Line 183:
NTP Daily Sync
NTP Daily Sync


nano /etc/cron.daily/ntpdate
nano /etc/cron.daily/ntpdate


Copy the following into nano
Copy the following into nano


!/bin/sh  
!/bin/sh  
ntpdate ntp.ubuntu.com
ntpdate ntp.ubuntu.com


Ctrl+o Enter to save
Ctrl+o Enter to save
Line 190: Line 194:
CTRL+x to exit
CTRL+x to exit


chmod 755 /etc/cron.daily/ntpdate
chmod 755 /etc/cron.daily/ntpdate


Open Zoneminder in web browser
Open Zoneminder in web browser

Revision as of 19:49, 22 October 2015

Zoneminder 1.28.1 on Ubuntu 14.04. Should also works on Ubuntu 14.10 running init.

22OCT15 Returned this to original version as 1.28.1 has been returned to the iconnor PPA

I did this install on a 64 BIT server but it should work on 32 BIT. As of 20FEB15 I have tested this with a local USB camera and a remote h.264 camera with Ffmpeg and Libvlc.

If you install from CD install Ubuntu Server, OpenSSH Server, and LAMP Server (LAMP installs Apache2, PHP, and MySQL server)

If you use the minimum ISO CD install Basic Server, OpenSSH Server, and LAMP Server (LAMP installs Apache2, PHP, and MySQL server)

Log in then become root:

sudo su

If you used the server install CD

apt-get update apt-get upgrade apt-get dist-upgrade

Optional: Set static IP address

nano /etc/network/interfaces

Make changes similar to this:

auto eth0 iface eth0 inet static

 address 192.168.1.10
 netmask 255.255.255.0
 gateway 192.168.1.1
 dns-nameservers 192.168.1.1

Note: for Ubuntu 14.04 the resolv.conf is dynamically assigned. The "dns-servers" entry in the interfaces file will set the DNS Multiple DNS server entries can be used.

Reboot server

Log in and become root

sudo su

Suggested changes to MySQL

For most of you Zoneminder will run just fine with the default MySQL settings. There are a couple of settings that may, in time, provide beneficial especially if you have a number of cameras and many events with a lot of files. One setting I recommend is the "innodb_file_per_table" This will be a default setting in MySQL 5.6 but should be added in MySQL 5.5 which comes with Ubuntu 14.04. A description can be found here: http://dev.mysql.com/doc/refman/5.5/en/innodb-multiple-tablespaces.html

To add "innodb_file_per_table" edit the my.cnf file:

nano /etc/mysql/my.cnf

Under [mysqld] add

innodb_file_per_table

Ctrl+o Enter to save

CTRL+x to exit

Restart MySQL

service mysql restart

As you add cameras to your system and the events build up you may need to increase the size of the "innodb_buffer_pool_size" when this setting runs out of space your system may act like it is out of disk space. One way to check this is to install mysqltuner and run it from the command line. When the results are shown you can edit the my.cnf file and change the buffer size. The default "innodb_buffer_pool_size" is 128M. In the ZM forum I have found a recommended setting of 256M. My production server required a setting greater than 410M. Install and run mysqltuner to determine the recommended size for your system. Be sure to restart MySQL after making changes.

Add Repository

add-apt-repository ppa:iconnor/zoneminder

apt-get update

Install Zoneminder

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 dir

cd ~

Create a hidden password file

nano .my.cnf

Enter this content

[client] user=root password=(mysqlpass)

Ctrl+o Enter to save

CTRL+x to exit

Create database

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)

Remove password file

rm .my.cnf

Set permissions of /etc/zm/zm.conf to root:www-data 740

chmod 740 /etc/zm/zm.conf

chown root:www-data /etc/zm/zm.conf

Add 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


Create a new user

adduser www-data video

Enable CGI and Zoneminder configuration in Apache.

a2enmod cgi

a2enconf zoneminder

a2enmod rewrite

Start Zoneminder

service zoneminder start

Add timezone to PHP

nano /etc/php5/apache2/php.ini

Search for [Date] and make changes as follows for your time zone

[Date]

Defines the default timezone used by the date functions
http://php.net/date.timezone

date.timezone = America/New_York

Ctrl+o Enter to save

CTRL+x to exit

Restart Apache

service apache2 reload


Install Cambozola (needed if you use Internet Explorer)


cd /usr/src && wget http://www.andywilcock.com/code/cambozola/cambozola-latest.tar.gz

tar -xzvf cambozola-latest.tar.gz

replace 936 in the next line with cambozola version downloaded

cp cambozola-0.936/dist/cambozola.jar /usr/share/zoneminder

You should now be able to access the web server using https://servername

NTP Daily Sync

nano /etc/cron.daily/ntpdate

Copy the following into nano

!/bin/sh ntpdate ntp.ubuntu.com

Ctrl+o Enter to save

CTRL+x to exit

chmod 755 /etc/cron.daily/ntpdate

Open Zoneminder in web browser

http://serverip/zm

Click Options

Uncheck: Check with zoneminder.com for updated versions (?) click Save

Click Images tab

check Is the (optional) cambozola java streaming client installed (?) Click Save