Ubuntu Server 18.04 64-bit with Zoneminder 1.30.4 the easy way

From ZoneMinder Wiki
Revision as of 13:03, 20 April 2018 by Bbunge (talk | contribs)
Jump to navigationJump to search

Ubuntu 18.04 with Zoneminder 1.30.4 Preliminary Install Procedure

Ubuntu 18.04 with LAMP and Zoneminder 1.30.4

For upgrade instructions from Ubuntu 16.04 to 18.04 see here:

https://wiki.zoneminder.com/Common_Issues_with_Zoneminder_Installation_on_Ubuntu#Ubuntu_16.04_with_ZM_1.30.4_Upgrade_to_Ubuntu_18.04_with_ZM_1.30.4

Notice: 20APR18 - 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

Warning!!! This is a preliminary procedure and changes to the nightly build may cause problems.

Ubuntu 18.04 Bionic Server Nightly Build (22MAR18) installed with LAMP and OpenSSH Server

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 (Password not set in nightly build). 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://docs.google.com/uc?export=download&id=1bZhVcBnlW46SwCnSnZ0sdZzwtOcCiisX' -O zoneminder-1.30.4-bionic-amd64.deb


Note: If needed you can get the file from Onedrive https://1drv.ms/u/s!ApMZyp0q7cregdRym0MrU9BeMP_JUQ or Google Drive https://drive.google.com/open?id=1bZhVcBnlW46SwCnSnZ0sdZzwtOcCiisX


Install Zoneminder - change (user) to the name you use to login.

apt install /home/(user)/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

Open Zoneminder in a web browser (http://server-ip/zm).


Install Zoneminder on Ubuntu 18.04 with shell script

Updated 20APR18

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

I have tested this on Ubuntu 18.04 server x64. You have two options: A Ubuntu Bionic Server with LAMP (Apache, MySQL and PHP) installed or a basic Ubuntu Bionic install, desktop or server, and the script will install Mariadb, Apache2 and PHP. Either script will install everything Zoneminder needs to function and set up Zoneminder!

View the file contents here:

Shell script zm-install-bionic

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

nano install

Paste the contents of the script into Nano

Then:

Ctrl + o
Ctrl + x

Next run:

chmod 755 zm-install-bionic

Start the script by entering:

./install

Follow the prompts. Things are pretty simple. The timezone will be detected from the OS and added to the php.ini. A modification to my.cnf for Zoneminder will also be done.

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)

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

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: To avoid problems with feeds from multiple cameras "fcgiwrap" should be configured to start at least as many processes as there are cameras. It can be done by adjusting DAEMON_OPTS in "/etc/default/fcgiwrap".

nano /etc/default/fcgiwrap

Enter (change the 1 to the number of cameras)

DAEMON_OPTS="-f -c 1" 

Ctrl+o Enter to save

CTRL+x to exit