Difference between revisions of "Ubuntu Server 16.04 64-bit with Zoneminder 1.32.x the easy way"

From ZoneMinder Wiki
Jump to navigationJump to search
 
(21 intermediate revisions by one other user not shown)
Line 1: Line 1:
For Ubuntu 15.10 with default Zoneminder 1.28.1
[[Ubuntu|<Home]]


Install Ubuntu 15.10 from the server CD with LAMP. If you use the minimum setup disk install basic server and LAMP. You may configure a static IP address for you server. Learn how to do this elsewhere.
__TOC__
 
 
===02OCT18 A new version, 1.32.1 is released.===
 
 
'''We recommend you read the release notes to see what has changed in this version. The release notes can be found here: https://github.com/ZoneMinder/zoneminder/releases'''
 
===Install Zoneminder on Ubuntu 16.04 with shell script===
 
This will install Zoneminder by using a shell script with one basic command (how easy is that!).
 
You will need a Ubuntu 16.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.32.x on Ubuntu 16.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 we will add the PPA repository, install and configure the system to run Zoneminder. You will have to press enter twice to load two PPA repositories.
Press enter to continue" nothing
apt install -y software-properties-common
clear
add-apt-repository ppa:iconnor/zoneminder
add-apt-repository ppa:iconnor/zoneminder-1.32
apt update
clear
awk '$0="date.timezone = "$0' /etc/timezone >> /etc/php/7.0/apache2/php.ini
clear
apt install -y zoneminder
systemctl enable zoneminder
service zoneminder start
adduser www-data video
a2enconf zoneminder
a2enmod rewrite
chown -R www-data:www-data /usr/share/zoneminder/
service apache2 reload
clear
read -p "Install complete.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 16.04 LEMP (NGNIX, Mariadb, PHP)===
 
This is not quite ready to use. Figuring out why video does not display... 09JAN19
 
Thanks to "terdinglage" for the input to get this to work!
 
Start with a basic Ubuntu 18.04 install. You can use a server or desktop install. Do not install LAMP!


Become root
Become root
Line 7: Line 84:
  sudo su
  sudo su


Install Zoneminder
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


  apt-get install zoneminder
  systemctl restart mysql


Create Zoneminder database in MySQL (Note: this also creates the default Zoneminder user and permissions in MySQL)
Edit the php.ini file


This next step creates a file which contained the MySQL user and password. Otherwise you will have to enter the user and password on teh command line which is not secure!
nano /etc/php/7.0/fpm/php.ini


Go to the root directory
Locate (Ctrl+w) cgi.fix_pathinfo=1 and change to
cd ~


Create a hidden password file
cgi.fix_pathinfo=0


nano .my.cnf
Remember to remove the leading ;


Enter this content (but use your MySQL root password!)
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


  [client]
  [Date]
  user=root
  ; Defines the default timezone used by the date functions
  password=(mysqlpass)
; http://php.net/date.timezone
  date.timezone = America/New_York


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


CTRL+x to exit
CTRL+x to exit  
 
Restart php-fpm
 
systemctl restart php7.0-fpm


Create database (press ENTER after each command)


mysql < /usr/share/zoneminder/db/zm_create.sql
Add two iconnor/Zoneminder Repository's (to pick up dependencies)


mysql -e "grant select,insert,update,delete,create,alter,lock tables,index on zm.* to 'zmuser'@localhost identified by 'zmpass';"
NOTE:You may need to run: "apt install software-properties-common" if you did the minimal net install of Ubuntu.
Remove password file


  rm .my.cnf
  add-apt-repository ppa:iconnor/zoneminder-1.32
   
  add-apt-repository ppa:iconnor/zoneminder
Set permissions of /etc/zm/zm.conf to root:www-data 740


  chmod 740 /etc/zm/zm.conf
  apt update


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


Enable Zoneminder service to start at boot
Install Zoneminder


  systemctl enable zoneminder.service
  apt install zoneminder


Create a new user
Create a new user if you plan to use local (USB or capture card) cameras.


  adduser www-data video
  adduser www-data video


Start Zoneminder
Fix Permissions
 
chown -R www-data:www-data /usr/share/zoneminder/
 
Change the ZM_PATH_ZMS in the 01-system-paths.conf file to /cgi-bin/nph-zms by dropping the /zm/
 
nano /etc/zm/conf.d/01-system-paths.conf
 
Ctrl+o Enter to save
 
CTRL+x to exit
 
Enable and start Zoneminder
 
systemctl enable zoneminder


  systemctl start zoneminder.service
  service zoneminder start


Check to see that Zoneminder is running


systemctl status zoneminder.service
Edit the Ngnix default configuration.  


Enable CGI and Zoneminder configuration in Apache.
nano /etc/nginx/sites-available/default


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


  a2enmod rewrite
  index index.php index.html index.htm index.nginx-debian.html;
 
In the "server" section after listen [::] :80 default_Server; add


  a2enconf zoneminder
  include /etc/nginx/zoneminder.conf;


Ctrl+o Enter to save


Restart Apache
CTRL+x to exit


service apache2 restart
Create a Zoneminder conf file


Sending email notifications. This version of Zoneminder does not install an email client.
nano /etc/nginx/zoneminder.conf
You may install nullmailer if needed:


apt-get install nullmailer
Enter the following into the zoneminder.conf file (This file was improved by databoy2k)


Install Cambozola (needed if you use Internet Explorer)
location /cgi-bin {
auth_basic off;
        alias /usr/lib/zoneminder/cgi-bin;   
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $request_filename;
        fastcgi_param HTTP_PROXY "";
        fastcgi_pass unix:/var/run/fcgiwrap.socket;
}
location /zm/cache {
auth_basic off;
        alias /var/cache/zoneminder/cache;
}
location ~ /zm/api/(css|img|ico) {
auth_basic off;
        rewrite ^/zm/api(.+)$ /api/app/webroot/$1 break;
        try_files $uri $uri/ =404;
}
location /zm {
auth_basic off;
        alias /usr/share/zoneminder/www;
        try_files $uri $uri/ /index.php?$args =404;   
        location /zm/api {
auth_basic off;
                rewrite ^/zm/api(.+)$ /zm/api/app/webroot/index.php?p=$1 last;
          }
                location ~ \.php$ {
                auth_basic off;
                        include fastcgi_params;
                        fastcgi_param SCRIPT_FILENAME $request_filename;
                        fastcgi_param HTTP_PROXY "";
                fastcgi_index index.php;
                        fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
        }
    }


cd /usr/src && wget http://www.andywilcock.com/code/cambozola/cambozola-latest.tar.gz
Ctrl+o Enter to save


tar -xzvf cambozola-latest.tar.gz
CTRL+x to exit


Replace "936" in the next line with the cambozola version downloaded
Restart Ngnix


  cp cambozola-0.936/dist/cambozola.jar /usr/share/zoneminder/www
  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
Note: 29JUL18 Thanks to Tiver for this suggestion that seems to work with the fcgiwrap issue.


Click Options
If it does not exist create


Click Images tab
nano /etc/default/fcgiwrap


Check Is the (optional) cambozola java streaming client installed (?) (to view streams on Internet Explorer. May need Java installed)
and insert (with the number of children -c equal to the number of cameras)


Check Is the ffmpeg video encoder/decoder installed (?) (to enable exporting of videos. Note that avconv is installed in 15.10)
DAEMON_OPTS=-c 10


Click Save
then restart the fcgiwrap service.


Additional documentation is available at: http://zoneminder.readthedocs.org/en/latest/
systemctl restart fcgiwrap

Latest revision as of 17:16, 18 March 2019

<Home


02OCT18 A new version, 1.32.1 is released.

We recommend you read the release notes to see what has changed in this version. The release notes can be found here: https://github.com/ZoneMinder/zoneminder/releases

Install Zoneminder on Ubuntu 16.04 with shell script

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

You will need a Ubuntu 16.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.32.x on Ubuntu 16.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 we will add the PPA repository, install and configure the system to run Zoneminder. You will have to press enter twice to load two PPA repositories.
Press enter to continue" nothing
apt install -y software-properties-common
clear
add-apt-repository ppa:iconnor/zoneminder
add-apt-repository ppa:iconnor/zoneminder-1.32
apt update
clear
awk '$0="date.timezone = "$0' /etc/timezone >> /etc/php/7.0/apache2/php.ini
clear
apt install -y zoneminder
systemctl enable zoneminder
service zoneminder start
adduser www-data video
a2enconf zoneminder
a2enmod rewrite
chown -R www-data:www-data /usr/share/zoneminder/
service apache2 reload
clear
read -p "Install complete.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 16.04 LEMP (NGNIX, Mariadb, PHP)

This is not quite ready to use. Figuring out why video does not display... 09JAN19

Thanks to "terdinglage" for the input to get this to work!

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.0/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.0-fpm


Add two iconnor/Zoneminder Repository's (to pick up dependencies)

NOTE:You may need to run: "apt install software-properties-common" if you did the minimal net install of Ubuntu.

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


Install Zoneminder

apt install zoneminder

Create a new user if you plan to use local (USB or capture card) cameras.

adduser www-data video

Fix Permissions

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

Change the ZM_PATH_ZMS in the 01-system-paths.conf file to /cgi-bin/nph-zms by dropping the /zm/

nano /etc/zm/conf.d/01-system-paths.conf

Ctrl+o Enter to save

CTRL+x to exit

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;

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

include /etc/nginx/zoneminder.conf;

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 /cgi-bin {
auth_basic off;
        alias /usr/lib/zoneminder/cgi-bin;     
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $request_filename;
        fastcgi_param HTTP_PROXY "";
        fastcgi_pass unix:/var/run/fcgiwrap.socket;
}
location /zm/cache {
auth_basic off;
        alias /var/cache/zoneminder/cache;
}
location ~ /zm/api/(css|img|ico) {
auth_basic off;
        rewrite ^/zm/api(.+)$ /api/app/webroot/$1 break;
        try_files $uri $uri/ =404;
}
location /zm {
auth_basic off;
        alias /usr/share/zoneminder/www;
        try_files $uri $uri/ /index.php?$args =404;    
        location /zm/api {
auth_basic off;
                rewrite ^/zm/api(.+)$ /zm/api/app/webroot/index.php?p=$1 last;
         }
                location ~ \.php$ {
                auth_basic off;
                        include fastcgi_params;
                        fastcgi_param SCRIPT_FILENAME $request_filename;
                        fastcgi_param HTTP_PROXY "";
                fastcgi_index index.php;
                        fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
        }
    }

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;

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