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

From ZoneMinder Wiki
Jump to navigationJump to search
Line 76: Line 76:


===Ubuntu 18.04 LEMP (NGNIX, Mariadb, PHP)===
===Ubuntu 18.04 LEMP (NGNIX, Mariadb, PHP)===
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!
Start with a basic Ubuntu 18.04 install. You can use a server or desktop install. Do not install LAMP!
Line 120: Line 122:
  systemctl restart php7.2-fpm
  systemctl restart php7.2-fpm


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


wget --no-check-certificate 'https://docs.google.com/uc?export=download&id=1bZhVcBnlW46SwCnSnZ0sdZzwtOcCiisX' -O /tmp/zoneminder-1.30.4-bionic-amd64.deb
Add Repository
 
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
 


Install Zoneminder
Install Zoneminder


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


Create a new user
Create a new user
Line 135: Line 141:


  chown -R www-data:www-data /usr/share/zoneminder/
  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
Enable and start Zoneminder
Line 150: Line 164:


  index index.php index.html index.htm index.nginx-debian.html;
  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+o Enter to save
Line 161: Line 179:
Enter the following into the zoneminder.conf file (This file was improved by databoy2k)
Enter the following into the zoneminder.conf file (This file was improved by databoy2k)


  location /zm/cgi-bin {
  location /cgi-bin {
    gzip off;
auth_basic off;
    alias /usr/lib/zoneminder/cgi-bin;
 
alias /usr/lib/zoneminder/cgi-bin;    
    include /etc/nginx/fastcgi_params;
include fastcgi_params;
    fastcgi_param SCRIPT_FILENAME $request_filename;
fastcgi_param SCRIPT_FILENAME $request_filename;
    fastcgi_pass unix:/var/run/fcgiwrap.socket;
fastcgi_param HTTP_PROXY "";
}
fastcgi_pass unix:/var/run/fcgiwrap.socket;
}
location /zm {
       
#  if ($scheme ~ ^http:){
location /zm/cache {
#      rewrite ^(.*)$  https://$host$1 permanent;
auth_basic off;
#  }
 
         alias /var/cache/zoneminder/cache;
    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
location ~ /zm/api/(css|img|ico) {
auth_basic off;


CTRL+x to exit
rewrite ^/zm/api(.+)$ /api/app/webroot/$1 break;
try_files $uri $uri/ =404;
}


Edit the default sites enabled
location /zm {
auth_basic off;


nano /etc/nginx/sites-enabled/default
alias /usr/share/zoneminder/www;
try_files $uri $uri/ /index.php?$args =404;   


In the "server" section after listen [::] :80 default_Server; add
location /zm/api {
auth_basic off;


include /etc/nginx/zoneminder.conf;
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.2-fpm.sock;
        }
    }


Ctrl+o Enter to save
Ctrl+o Enter to save
Line 221: Line 235:


Note: If Nginx gives you an error on restart go back one step and re-enter include /etc/ngnix/zoneminder.conf;
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.
Note: 29JUL18 Thanks to Tiver for this suggestion that seems to work with the fcgiwrap issue.

Revision as of 14:18, 9 January 2019

Things to check before installing Zoneminder on Bionic!

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

There have been some reports of the install failing. We feel this is due to missing repositories in the sources.list. You can check this by running

nano /etc/apt.sources.list

Look for the universe repositorys of which there should be three, bionic universe, bionic-updates universe and bionic-security universe

See: https://help.ubuntu.com/community/Repositories/CommandLine

Install Zoneminder on Ubuntu 18.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 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.32.x 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 we will add the PPA repository, install and configure the system to run Zoneminder. 
Press enter to continue" nothing
apt install -y software-properties-common
clear
add-apt-repository ppa:iconnor/zoneminder-1.32
apt update
clear
awk '$0="date.timezone = "$0' /etc/timezone >> /etc/php/7.2/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 18.04 LEMP (NGNIX, Mariadb, PHP)

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.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


Add Repository

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


Install Zoneminder

apt install zoneminder

Create a new user

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.2-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