Difference between revisions of "Ubuntu Server 18.04 64-bit with Zoneminder 1.30.4 the easy way"

From ZoneMinder Wiki
Jump to navigationJump to search
m
 
(44 intermediate revisions by 2 users not shown)
Line 1: Line 1:
Zoneminder 1.25.0 on Ubuntu 12.04 64-bit
[[Ubuntu|<Home]]


This installation uses Zoneminder from the Ubuntu sources. Zoneminder in Ubuntu since the 11.10 version is compiled with the mmap option. I am running an Optiplex 755 with a dual core processor, 2 GIG RAM and 160 GIG hard drive. I have 10 Linksys IP cameras with Modect operational. I have run this install and have set up the 10 cameras in about an hour!
'''Ubuntu 18.04 with Zoneminder 1.30.4 Install Procedure'''


Note: While not tested this should work for 32 BIT as well
__TOC__


Note2: These instructions work on Ubuntu Server 12.10 32-bit under VirtualBox 4.1.22 (host: Windows 7 Pro SP1), with 512MB RAM 8 GB HD. Tested with one IP camera (IP-400 camera from DealExtreme). (28-Oct-2012/ktt)
'''


Install Ubuntu
'''23JAN19 I have gone over these procedures and made corrections as needed. Tested/verified as long as the download server stays online. ''''''


There are plenty of sources for instructions on how to install Ubuntu.
===Ubuntu 18.04 AMD64 with LAMP and Zoneminder 1.30.4 Shell Script===


Install Basic Server (if you used the mini.iso), OpenSSH Server, and LAMP Server.
This will install Zoneminder by using a shell script with one basic command (how easy is that!).


Reboot server.
You will need a Ubuntu 18.04 install with LAMP (Apache, MySQL and PHP) installed desktop or server. As an alternate you may use Mariadb in lieu of MySQL


Log in then become root:
Shell script file contents:


  sudo su
  #!/bin/sh
clear
read -p "This script installs Zoneminder 1.30.4 on Ubuntu 18.04 AMD64 with LAMP (MySQL) installed...
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 secure MySQL server by entering requested information. Press enter to continue" nothing
mysql_secure_installation
read -p "Next we will download the Zoneminder install package and install it.
Press enter to continue" nothing
wget -O /tmp/zoneminder-1.30.4-bionic-amd64.deb --no-check-certificate "https://onedrive.live.com/download?cid=DECAED2A9DCA1993&resid=DECAED2A9DCA1993%2127789&authkey=ADtawB70vAFb11k"
clear
awk '$0="date.timezone = "$0' /etc/timezone >> /etc/php/7.2/apache2/php.ini
echo "[mysqld]" >> /etc/mysql/my.cnf
echo "init_connect = 'SET @@sql_mode = CASE CURRENT_USER() WHEN \'zmuser@localhost\' THEN \'NO_ENGINE_SUBSTITUTION\' ELSE @@sql_mode END;'" >> /etc/mysql/my.cnf
systemctl restart mysql
apt-get -y install /tmp/zoneminder-1.30.4-bionic-amd64.deb
systemctl enable zoneminder
service zoneminder start
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 "Open Zoneminder in a web browser (http://server-ip/zm).
Click on Options - Paths and change PATH_ZMS to /zm/cgi-bin/nph-zms
Click the Save button.
Press enter to continue" nothing
clear
 
Copy the contents of the script, open a terminal and run:
 
nano zm-install
 
Paste the contents of the script into Nano
 
Then:
 
Ctrl + o
Ctrl + x
 
Next run:
 
chmod 755 zm-install
 
Start the script by entering:
 
./zm-install
 
Follow the prompts. Things are pretty simple. The timezone will be detected from the OS and added to the php.ini.
 
Good Luck!
 
While this script worked for me I can't be responsible if you loose data when you run this. It is intended for a new install not an upgrade.
 
===Ubuntu 18.04 AMD64 with LAMP and Zoneminder 1.30.4 Manual Install===
 
''25APR18 - Zoneminder has been removed from the Ubuntu 18.04, Bionic, repository. PHP updates to version 7.2 also caused some problems which have been resolved (I hope!). This procedure uses a patched install from Zesty along with cakephp and crud updates to work with PHP7.2 ''
 
'''Ubuntu 18.04 Bionic installed with LAMP and OpenSSH Server 64 BIT Ubuntu only!
'''
 
To better manage the MySQL server I recommend you copy the sample config file and replace the default my.cnf symbolic link.
 
This removes the current symbolic link
 
rm /etc/mysql/my.cnf 
 
This moves the MYSQL Configuration file
 
cp /etc/mysql/mysql.conf.d/mysqld.cnf /etc/mysql/my.cnf
 
To change MySQL settings:
 
nano /etc/mysql/my.cnf
 
In the [mysqld] section add the following
 
sql_mode = NO_ENGINE_SUBSTITUTION
 
Note: if you are installing on an existing database server you can use the folowing as an alternate (Thanks to "bodom" for this alternate):
 
init_connect = 'SET @@sql_mode = CASE CURRENT_USER() WHEN \'zmuser@localhost\' THEN \'NO_ENGINE_SUBSTITUTION\' ELSE @@sql_mode END;'
 
Ctrl+o Enter to save
 
CTRL+x to exit
 
Restart MySQL
 
systemctl restart mysql
 
Secure MySQL and set root password.  Do not install the password validation plugin as the default Zoneminder password is not strong.
 
mysql_secure_installation
 
Dowmload the Zoneminder install package:
 
wget --no-check-certificate https://173.163.189.225/zoneminder-1.30.4-bionic-amd64.deb -P /tmp/
 
Install Zoneminder
 
apt install /tmp/zoneminder-1.30.4-bionic-amd64.deb
 
Enable Zoneminder service to start at boot
 
systemctl enable zoneminder.service
 
Add www-data to the sudo group (to enable use of local video devices)
 
adduser www-data video
 
Start Zoneminder
 
systemctl start zoneminder.service
 
Enable CGI and Zoneminder configuration in Apache.
 
a2enmod cgi
 
a2enmod rewrite
 
a2enconf zoneminder
 
Add timezone to PHP
 
nano /etc/php/7.2/apache2/php.ini
 
Search for [Date] (Ctrl + w then type Date and press Enter) and make changes as follows for your time zone. Be sure to remove the ; before date.timezone


apt-get update
[Date]
apt-get upgrade
; Defines the default timezone used by the date functions
apt-get dist-upgrade
; http://php.net/date.timezone
date.timezone = America/New_York


Ctrl+o Enter to save


Optional: Set static IP address
CTRL+x to exit


nano /etc/network/interfaces
Change permissions in /usr/share/zoneminder/


Make changes similar to this:
chown -R www-data:www-data /usr/share/zoneminder/


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 68.87.75.194


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


  Ctrl+o Enter to save
  service apache2 restart


CTRL+x to exit
IMPORTANT FINAL STEP: Open Zoneminder in a web browser (http://server-ip/zm). Click on Options - Paths and change PATH_ZMS to /zm/cgi-bin/nph-zms


Reboot server
===Ubuntu 18.04 LEMP (NGNIX, Mariadb, PHP)===


From this point on I used Putty from another PC to configure the server.
Start with a basic Ubuntu 18.04 install. You can use a server or desktop install. Do not install LAMP!


Install Zoneminder
Become root


Log in then become root
  sudo su
  sudo su


apt-get install zoneminder
Install Ngnix, Mariadb and PHP components


Note: You will be prompted to configure Nullmailer during the Zoneminder install. You can leave the program un-configured if you do not plan to have the server email alerts. Or search for instructions to configure Nullmailer.
apt install nginx mariadb-server php-fpm php-mysql fcgiwrap


Add the H.264 packages if wanted.
Secure the Mariadb server


  apt-get install x264
  mysql_secure_installation


Add delay to allow MySQL to start before Zoneminder
Restart Mariadb


  nano /etc/init.d/zoneminder
  systemctl restart mysql


Add above "zmfix -a" sleep 15
Edit the php.ini file


  Ctrl+o Enter to save
  nano /etc/php/7.2/fpm/php.ini


CTRL+x to exit
Locate (Ctrl+w) cgi.fix_pathinfo=1 and change to


Link Apache to Zoneminder
cgi.fix_pathinfo=0


Remember to remove the leading ;


ln -s /etc/zm/apache.conf /etc/apache2/conf.d/zoneminder.conf
Also fix date. Search for [Date] (Ctrl + w then type Date and press Enter) and make changes as follows for your time zone. Make sure to remove the ; from the front of date.timezone


  /etc/init.d/apache2 force-reload
  [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 php-fpm
 
systemctl restart php7.2-fpm
 
Download the Zoneminder install package. This may take a minute to connect
 
wget --no-check-certificate https://173.163.189.225/zoneminder-1.30.4-bionic-amd64.deb -P /tmp/
 
Install Zoneminder
 
apt install /tmp/zoneminder-1.30.4-bionic-amd64.deb
 
Create a new user


  adduser www-data video
  adduser www-data video


Optional Install Cambozola
Fix Permissions
 
chown -R www-data:www-data /usr/share/zoneminder/
 
Enable and start Zoneminder


  cd /usr/src && wget http://www.charliemouse.com:8080/code/cambozola/cambozola-latest.tar.gz
  systemctl enable zoneminder


  tar -xzvf cambozola-latest.tar.gz
  service zoneminder start


replace "93" with cambozola version downloaded


cp cambozola-0.93/dist/cambozola.jar /usr/share/zoneminder
Edit the Ngnix default configuration.  


Optional Add SSL to Apache2
nano /etc/nginx/sites-available/default


Create a self-signed certificate:
Locate the line "index index.html index.htm index.nginx-debian.html;" and add index.php


  make-ssl-cert generate-default-snakeoil --force-overwrite
  index index.php index.html index.htm index.nginx-debian.html;


Activate Apache SSL module:
Ctrl+o Enter to save


a2enmod ssl
CTRL+x to exit


Activate Apache default ssl virtual host:
Create a Zoneminder conf file


  a2ensite default-ssl
  nano /etc/nginx/zoneminder.conf


Restart Apache:
Enter the following into the zoneminder.conf file (This file was improved by databoy2k)


  service apache2 restart
  location /zm/cgi-bin {
    gzip off;
    alias /usr/lib/zoneminder/cgi-bin;
    include /etc/nginx/fastcgi_params;
    fastcgi_param SCRIPT_FILENAME $request_filename;
    fastcgi_pass  unix:/var/run/fcgiwrap.socket;
}
location /zm {
#  if ($scheme ~ ^http:){
#      rewrite ^(.*)$  https://$host$1 permanent;
#  }
    gzip off;
    alias                  /usr/share/zoneminder/www;
    index                  index.php;
    location ~ \.php$ {
        if (!-f $request_filename) { return 404; }
        expires            epoch;
        include            /etc/nginx/fastcgi_params;
        fastcgi_param      SCRIPT_FILENAME        $request_filename;
        fastcgi_index      index.php;
        fastcgi_pass        unix:/var/run/php/php7.2-fpm.sock;
    }
    location ~ \.(jpg|jpeg|gif|png|ico)$ {
        access_log          off;
        expires        33d;
    }
    location /zm/api/ {
        alias                  /usr/share/zoneminder/www/api;
        rewrite ^/zm/api(.+)$ /zm/api/index.php?p=$1 last;
    }
}


Ctrl+o Enter to save


You should now be able to access the web server using https://serverip
CTRL+x to exit


NTP Daily Sync
Edit the default sites enabled


  nano /etc/cron.daily/ntpdate
  nano /etc/nginx/sites-enabled/default


Copy the following two lines into nano
In the "server" section after listen [::] :80 default_Server; add


  #!/bin/sh
  include /etc/nginx/zoneminder.conf;
ntpdate ntp.ubuntu.com


Note: replace ntp.ubuntu.com with the time server(s) of your choice. I use time-a.nist.gov time-b.nist.gov
Ctrl+o Enter to save


Ctrl+o Enter to save
CTRL+x to exit


CTRL+x to exit
Restart Ngnix


  chmod 755 /etc/cron.daily/ntpdate
  service nginx restart


Open Zoneminder in web browser
Note: If Nginx gives you an error on restart go back one step and re-enter include /etc/ngnix/zoneminder.conf;


http://serverip/zm
IMPORTANT FINAL STEP: Open Zoneminder in a web browser (http://server-ip/zm). Click on Options - Paths and change PATH_ZMS to /zm/cgi-bin/nph-zms


Click Options
Note: 29JUL18 Thanks to Tiver for this suggestion that seems to work with the fcgiwrap issue.


Uncheck: Check with zoneminder.com for updated versions (?) click Save.
If it does not exist create


Click Images tab
nano /etc/default/fcgiwrap


Optional:  check "Is the (optional) cambozola java streaming client installed (?)"
and insert (with the number of children -c equal to the number of cameras)


Path to (optional) ffmpeg mpeg encoder (?) enter /usr/bin/ffmpeg click Save
DAEMON_OPTS=-c 10


Reboot server to insure Zoneminder starts on boot.  
then restart the fcgiwrap service.


Return to the Zoneminder web page to set up your cameras.
systemctl restart fcgiwrap

Latest revision as of 13:37, 9 June 2019

<Home

Ubuntu 18.04 with Zoneminder 1.30.4 Install Procedure

23JAN19 I have gone over these procedures and made corrections as needed. Tested/verified as long as the download server stays online. '

Ubuntu 18.04 AMD64 with LAMP and Zoneminder 1.30.4 Shell Script

This will install Zoneminder by using a shell script with one basic command (how easy is that!).

You will need a Ubuntu 18.04 install with LAMP (Apache, MySQL and PHP) installed desktop or server. As an alternate you may use Mariadb in lieu of MySQL

Shell script file contents:

#!/bin/sh
clear
read -p "This script installs Zoneminder 1.30.4 on Ubuntu 18.04 AMD64 with LAMP (MySQL) installed...
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 secure MySQL server by entering requested information. Press enter to continue" nothing
mysql_secure_installation
read -p "Next we will download the Zoneminder install package and install it.
Press enter to continue" nothing
wget -O /tmp/zoneminder-1.30.4-bionic-amd64.deb --no-check-certificate "https://onedrive.live.com/download?cid=DECAED2A9DCA1993&resid=DECAED2A9DCA1993%2127789&authkey=ADtawB70vAFb11k"
clear
awk '$0="date.timezone = "$0' /etc/timezone >> /etc/php/7.2/apache2/php.ini
echo "[mysqld]" >> /etc/mysql/my.cnf
echo "init_connect = 'SET @@sql_mode = CASE CURRENT_USER() WHEN \'zmuser@localhost\' THEN \'NO_ENGINE_SUBSTITUTION\' ELSE @@sql_mode END;'" >> /etc/mysql/my.cnf
systemctl restart mysql
apt-get -y install /tmp/zoneminder-1.30.4-bionic-amd64.deb
systemctl enable zoneminder
service zoneminder start
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 "Open Zoneminder in a web browser (http://server-ip/zm). 
Click on Options - Paths and change PATH_ZMS to /zm/cgi-bin/nph-zms 
Click the Save button. 
Press enter to continue" nothing
clear

Copy the contents of the script, open a terminal and run:

nano zm-install

Paste the contents of the script into Nano

Then:

Ctrl + o
Ctrl + x

Next run:

chmod 755 zm-install

Start the script by entering:

./zm-install

Follow the prompts. Things are pretty simple. The timezone will be detected from the OS and added to the php.ini.

Good Luck!

While this script worked for me I can't be responsible if you loose data when you run this. It is intended for a new install not an upgrade.

Ubuntu 18.04 AMD64 with LAMP and Zoneminder 1.30.4 Manual Install

25APR18 - Zoneminder has been removed from the Ubuntu 18.04, Bionic, repository. PHP updates to version 7.2 also caused some problems which have been resolved (I hope!). This procedure uses a patched install from Zesty along with cakephp and crud updates to work with PHP7.2

Ubuntu 18.04 Bionic installed with LAMP and OpenSSH Server 64 BIT Ubuntu only!

To better manage the MySQL server I recommend you copy the sample config file and replace the default my.cnf symbolic link.

This removes the current symbolic link

rm /etc/mysql/my.cnf  

This moves the MYSQL Configuration file

cp /etc/mysql/mysql.conf.d/mysqld.cnf /etc/mysql/my.cnf

To change MySQL settings:

nano /etc/mysql/my.cnf

In the [mysqld] section add the following

sql_mode = NO_ENGINE_SUBSTITUTION

Note: if you are installing on an existing database server you can use the folowing as an alternate (Thanks to "bodom" for this alternate):

init_connect = 'SET @@sql_mode = CASE CURRENT_USER() WHEN \'zmuser@localhost\' THEN \'NO_ENGINE_SUBSTITUTION\' ELSE @@sql_mode END;'

Ctrl+o Enter to save

CTRL+x to exit

Restart MySQL

systemctl restart mysql

Secure MySQL and set root password. Do not install the password validation plugin as the default Zoneminder password is not strong.

mysql_secure_installation

Dowmload the Zoneminder install package:

wget --no-check-certificate https://173.163.189.225/zoneminder-1.30.4-bionic-amd64.deb -P /tmp/

Install Zoneminder

apt install /tmp/zoneminder-1.30.4-bionic-amd64.deb

Enable Zoneminder service to start at boot

systemctl enable zoneminder.service

Add www-data to the sudo group (to enable use of local video devices)

adduser www-data video

Start Zoneminder

systemctl start zoneminder.service

Enable CGI and Zoneminder configuration in Apache.

a2enmod cgi
a2enmod rewrite
a2enconf zoneminder

Add timezone to PHP

nano /etc/php/7.2/apache2/php.ini

Search for [Date] (Ctrl + w then type Date and press Enter) and make changes as follows for your time zone. Be sure to remove the ; before date.timezone

[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

Change permissions in /usr/share/zoneminder/

chown -R www-data:www-data /usr/share/zoneminder/


Restart Apache

service apache2 restart

IMPORTANT FINAL STEP: Open Zoneminder in a web browser (http://server-ip/zm). Click on Options - Paths and change PATH_ZMS to /zm/cgi-bin/nph-zms

Ubuntu 18.04 LEMP (NGNIX, Mariadb, PHP)

Start with a basic Ubuntu 18.04 install. You can use a server or desktop install. Do not install LAMP!

Become root

sudo su

Install Ngnix, Mariadb and PHP components

apt install nginx mariadb-server php-fpm php-mysql fcgiwrap

Secure the Mariadb server

mysql_secure_installation

Restart Mariadb

systemctl restart mysql

Edit the php.ini file

nano /etc/php/7.2/fpm/php.ini

Locate (Ctrl+w) cgi.fix_pathinfo=1 and change to

cgi.fix_pathinfo=0

Remember to remove the leading ;

Also fix date. Search for [Date] (Ctrl + w then type Date and press Enter) and make changes as follows for your time zone. Make sure to remove the ; from the front of date.timezone

[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 php-fpm

systemctl restart php7.2-fpm

Download the Zoneminder install package. This may take a minute to connect

wget --no-check-certificate https://173.163.189.225/zoneminder-1.30.4-bionic-amd64.deb -P /tmp/

Install Zoneminder

apt install /tmp/zoneminder-1.30.4-bionic-amd64.deb

Create a new user

adduser www-data video

Fix Permissions

chown -R www-data:www-data /usr/share/zoneminder/

Enable and start Zoneminder

systemctl enable zoneminder
service zoneminder start


Edit the Ngnix default configuration.

nano /etc/nginx/sites-available/default

Locate the line "index index.html index.htm index.nginx-debian.html;" and add index.php

index index.php index.html index.htm index.nginx-debian.html;

Ctrl+o Enter to save

CTRL+x to exit

Create a Zoneminder conf file

nano /etc/nginx/zoneminder.conf

Enter the following into the zoneminder.conf file (This file was improved by databoy2k)

location /zm/cgi-bin {
    gzip off;
    alias /usr/lib/zoneminder/cgi-bin;

    include /etc/nginx/fastcgi_params;
    fastcgi_param SCRIPT_FILENAME $request_filename;
    fastcgi_pass  unix:/var/run/fcgiwrap.socket;
}

location /zm {
#   if ($scheme ~ ^http:){
#       rewrite ^(.*)$  https://$host$1 permanent;
#   }

    gzip off;
    alias                   /usr/share/zoneminder/www;
    index                   index.php;

    location ~ \.php$ {
        if (!-f $request_filename) { return 404; }
        expires             epoch;
        include             /etc/nginx/fastcgi_params;
        fastcgi_param       SCRIPT_FILENAME         $request_filename;
        fastcgi_index       index.php;
        fastcgi_pass        unix:/var/run/php/php7.2-fpm.sock;
    }


    location ~ \.(jpg|jpeg|gif|png|ico)$ {
        access_log          off;
        expires         33d;
    }

    location /zm/api/ {
        alias                   /usr/share/zoneminder/www/api;
        rewrite ^/zm/api(.+)$ /zm/api/index.php?p=$1 last;
    }
}

Ctrl+o Enter to save

CTRL+x to exit

Edit the default sites enabled

nano /etc/nginx/sites-enabled/default

In the "server" section after listen [::] :80 default_Server; add

include /etc/nginx/zoneminder.conf;

Ctrl+o Enter to save

CTRL+x to exit

Restart Ngnix

service nginx restart

Note: If Nginx gives you an error on restart go back one step and re-enter include /etc/ngnix/zoneminder.conf;

IMPORTANT FINAL STEP: Open Zoneminder in a web browser (http://server-ip/zm). Click on Options - Paths and change PATH_ZMS to /zm/cgi-bin/nph-zms

Note: 29JUL18 Thanks to Tiver for this suggestion that seems to work with the fcgiwrap issue.

If it does not exist create

nano /etc/default/fcgiwrap

and insert (with the number of children -c equal to the number of cameras)

DAEMON_OPTS=-c 10

then restart the fcgiwrap service.

systemctl restart fcgiwrap