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

From ZoneMinder Wiki
Jump to navigationJump to search
 
(8 intermediate revisions by one other user not shown)
Line 1: Line 1:
If you are not experienced with Linux and would like a quick way to get Zoneminder running for you, consider Zoneminder on a stick, a per-configured Lubuntu 14.04 with Zoneminder 1.29.0. See: https://wiki.zoneminder.com/Lubuntu_14.04_with_Zoneminder_1.29.0_pre-configured_CD_or_USB
[[Ubuntu|<Home]]


04OCT15
__TOC__
This procedure has been updated because we've learned a few things. We used to tell you to use the 14.04 - 1.26.5 instructions.


===Ubuntu 17.10 with LAMP===


If you use the minimum Ubuntu ISO CD, install Basic Server, OpenSSH Server, and LAMP Server (LAMP installs Apache2, PHP, and MySQL server)
This is an interim procedure to install Zoneminder 1.30.4 on Ubuntu 17.10


'''Note: There have been several reports of things, like the API, not working with Zoneminder and Ubuntu 17.10. You are better off to use Ubuntu 16.04!'''


There is a newer version of Zoneminder in the iconnor/zoneminder PPA.
'''Note - installing Zoneminder this way will not prevent it from being overwritten when you do "apt upgrade" To prevent Zoneminder from being upgraded enter "sudo apt-mark hold zoneminder"'''


Log in then become root:
There are some issues with the Zoneminder package provided with Ubuntu 17.10. This is an alternate install procedure that uses the install package from the iconnor PPA for Zesty (Ubuntu 17.04)


  sudo su
This assumes you have installed Ubuntu 17.10 with LAMP.
 
You will need to make a settings change to MySQL as follows:
 
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 following 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


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


Optional: Set static IP address
systemctl restart mysql


nano /etc/network/interfaces
Download the Zoneminder install package from the iconnor PPA. Note this is for the 64 bit version.


Make changes similar to this:
wget https://launchpad.net/~iconnor/+archive/ubuntu/zoneminder/+build/12557069/+files/zoneminder_1.30.4-zesty1_amd64.deb


auto eth0
Install Zoneminder - Note: Change (user) to the user in the home directory on your system
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


apt install vlc-plugin-base /home/(user)/zoneminder_1.30.4-zesty1_amd64.deb


Reboot server
'''Note - installing Zoneminder this way will not prevent it from being overwritten when you do "apt upgrade" To prevent Zoneminder from being upgraded enter "sudo apt-mark hold zoneminder"'''


CGI is not enabled in Ubuntu 15.04 by default. Enable it this way:
Create a new user
 
adduser www-data video
 
Enable CGI, Zoneminder and rewrite configuration in Apache.


  a2enmod cgi
  a2enmod cgi
a2enconf zoneminder
a2enmod rewrite
Fix Permissions
chown -R www-data:www-data /usr/share/zoneminder/
Enable and start Zoneminder
systemctl enable zoneminder
service zoneminder start
Add timezone to PHP
nano /etc/php/7.1/apache2/php.ini
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 Apache
Restart Apache


  service apache2 restart
  service apache2 reload
 
 
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 17.10 with LEMP (NGINX, Mariadb and PHP)===
 
Ubuntu 17.10 Nginx Mariadb PHP Zoneminder 1.30.4
 
'''Note - installing Zoneminder this way will not prevent it from being overwritten when you do "apt upgrade" To prevent Zoneminder from being upgraded enter "sudo apt-mark hold zoneminder"'''
 
Start with an install of Ubuntu 17.10, server, desktop or bare bones basic. Do not install LAMP!
 
Become root
 
sudo su
 
Install Nginx and Mariadb


Install Zoneminder
apt install nginx


  apt-get install zoneminder
  apt install mariadb-server


Secure Mariadb


Enable Zoneminder
mysql_secure_installation


systemctl enable zoneminder.service
Remove the symbolic link for Mariadb


Start Zoneminder
rm /etc/mysql/my.cnf


systemctl start zoneminder.service
Copy a basic config file to replace the symbolic link


Check to see that Zoneminder is running
cp /etc/mysql/mariadb.conf.d/50-server.cnf /etc/mysql/my.cnf


systemctl status zoneminder.service
Edit the Mariadb config file


nano /etc/mysql/my.cnf


Create a symbolic link
Locate entries like the following and replace them


  ln -s /etc/zm/apache.conf /etc/apache2/conf-enabled/zoneminder.conf
  character-set-server = latin1
collation-server = latin1_swedish_ci


Note: The above settings are actually the Mariadb default. Changing back to default is necessary to avoid errors when logging into Zoneminder. This was added on 01APR17 but is not an April Fool! It may be necessary to align these settings with your regional language.


Create a new user
Ctrl+o Enter to save
 
CTRL+x to exit
 
Restart Mariadb
 
systemctl restart mysql
 
Install PHP components
 
apt install php-fpm php-mysql fcgiwrap
 
Edit the PHP ini file
 
nano /etc/php/7.1/fpm/php.ini
 
Locate (Ctrl+w) cgi.fix_pathinfo=1 and change to
 
cgi.fix_pathinfo=0
 
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-fm
 
systemctl restart php7.1-fpm
 
Download the Zoneminder .deb file from the iconnor repository
 
wget https://launchpad.net/~iconnor/+archive/ubuntu/zoneminder/+build/12557069/+files/zoneminder_1.30.4-zesty1_amd64.deb
 
Install Zoneminder. Change (user) as shown below to your user name on your Ubuntu install
 
apt install vlc-plugin-base /home/(user)/zoneminder_1.30.4-zesty1_amd64.deb
 
'''Note - installing Zoneminder this way will not prevent it from being overwritten when you do "apt upgrade" To prevent Zoneminder from being upgraded enter "sudo apt-mark hold zoneminder"'''
 
Add a user to enable local cameras


  adduser www-data video
  adduser www-data video


Restart Apache
Change permissions
 
chown -R www-data:www-data /usr/share/zoneminder/
 
Enable and start Zoneminder


  service apache2 restart
systemctl enable zoneminder
  service zoneminder start


Install Cambozola (needed if you use Internet Explorer)
Edit the Nginx default config file


nano /etc/nginx/sites-available/default


cd /usr/src && wget http://www.andywilcock.com/code/cambozola/cambozola-latest.tar.gz
Locate the line "index index.html index.htm index.nginx-debian.html;" and add "index.php"


  tar -xzvf cambozola-latest.tar.gz
  index index.php index.html index.htm index.nginx-debian.html;


replace 936 in the following with cambozola version downloaded
Ctrl+o Enter to save


  cp cambozola-0.936/dist/cambozola.jar /usr/share/zoneminder
Somewhere in the "server" section add
 
  include /etc/nginx/zoneminder.conf;
 
Ctrl+o Enter to save


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


Optional NTP Daily Sync
Create a Zoneminder config file


  nano /etc/cron.daily/ntpdate
  nano /etc/nginx/zoneminder.conf


Copy the following into nano
Copy the following into it


  !/bin/sh ntpdate ntp.ubuntu.com
  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.1-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+o Enter to save


CTRL+x to exit
CTRL+x to exit  
 
Restart Nginx


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


Open Zoneminder in web browser
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


http://serverip/zm
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".


Click Options
nano /etc/default/fcgiwrap


Uncheck: Check with zoneminder.com for updated versions (?) click Save
Enter (change the 1 to the number of cameras)


Click Images tab
DAEMON_OPTS="-f -c 1"


check Is the (optional) cambozola java streaming client installed (?) Click Save
Ctrl+o Enter to save
 
CTRL+x to exit

Latest revision as of 17:19, 18 March 2019

<Home

Ubuntu 17.10 with LAMP

This is an interim procedure to install Zoneminder 1.30.4 on Ubuntu 17.10

Note: There have been several reports of things, like the API, not working with Zoneminder and Ubuntu 17.10. You are better off to use Ubuntu 16.04!

Note - installing Zoneminder this way will not prevent it from being overwritten when you do "apt upgrade" To prevent Zoneminder from being upgraded enter "sudo apt-mark hold zoneminder"

There are some issues with the Zoneminder package provided with Ubuntu 17.10. This is an alternate install procedure that uses the install package from the iconnor PPA for Zesty (Ubuntu 17.04)

This assumes you have installed Ubuntu 17.10 with LAMP.

You will need to make a settings change to MySQL as follows:

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

Download the Zoneminder install package from the iconnor PPA. Note this is for the 64 bit version.

wget https://launchpad.net/~iconnor/+archive/ubuntu/zoneminder/+build/12557069/+files/zoneminder_1.30.4-zesty1_amd64.deb

Install Zoneminder - Note: Change (user) to the user in the home directory on your system

apt install vlc-plugin-base /home/(user)/zoneminder_1.30.4-zesty1_amd64.deb

Note - installing Zoneminder this way will not prevent it from being overwritten when you do "apt upgrade" To prevent Zoneminder from being upgraded enter "sudo apt-mark hold zoneminder"

Create a new user

adduser www-data video

Enable CGI, Zoneminder and rewrite configuration in Apache.

a2enmod cgi
a2enconf zoneminder
a2enmod rewrite

Fix Permissions

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

Enable and start Zoneminder

systemctl enable zoneminder
service zoneminder start

Add timezone to PHP

nano /etc/php/7.1/apache2/php.ini

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 Apache

service apache2 reload


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 17.10 with LEMP (NGINX, Mariadb and PHP)

Ubuntu 17.10 Nginx Mariadb PHP Zoneminder 1.30.4

Note - installing Zoneminder this way will not prevent it from being overwritten when you do "apt upgrade" To prevent Zoneminder from being upgraded enter "sudo apt-mark hold zoneminder"

Start with an install of Ubuntu 17.10, server, desktop or bare bones basic. Do not install LAMP!

Become root

sudo su

Install Nginx and Mariadb

apt install nginx
apt install mariadb-server

Secure Mariadb

mysql_secure_installation

Remove the symbolic link for Mariadb

rm /etc/mysql/my.cnf

Copy a basic config file to replace the symbolic link

cp /etc/mysql/mariadb.conf.d/50-server.cnf /etc/mysql/my.cnf

Edit the Mariadb config file

nano /etc/mysql/my.cnf

Locate entries like the following and replace them

character-set-server = latin1
collation-server = latin1_swedish_ci

Note: The above settings are actually the Mariadb default. Changing back to default is necessary to avoid errors when logging into Zoneminder. This was added on 01APR17 but is not an April Fool! It may be necessary to align these settings with your regional language.

Ctrl+o Enter to save

CTRL+x to exit

Restart Mariadb

systemctl restart mysql

Install PHP components

apt install php-fpm php-mysql fcgiwrap

Edit the PHP ini file

nano /etc/php/7.1/fpm/php.ini

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

cgi.fix_pathinfo=0

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

systemctl restart php7.1-fpm

Download the Zoneminder .deb file from the iconnor repository

wget https://launchpad.net/~iconnor/+archive/ubuntu/zoneminder/+build/12557069/+files/zoneminder_1.30.4-zesty1_amd64.deb

Install Zoneminder. Change (user) as shown below to your user name on your Ubuntu install

apt install vlc-plugin-base /home/(user)/zoneminder_1.30.4-zesty1_amd64.deb

Note - installing Zoneminder this way will not prevent it from being overwritten when you do "apt upgrade" To prevent Zoneminder from being upgraded enter "sudo apt-mark hold zoneminder"

Add a user to enable local cameras

adduser www-data video

Change permissions

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

Enable and start Zoneminder

systemctl enable zoneminder
service zoneminder start

Edit the Nginx default config file

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

Somewhere in the "server" section add

include /etc/nginx/zoneminder.conf;

Ctrl+o Enter to save

CTRL+x to exit

Create a Zoneminder config file

nano /etc/nginx/zoneminder.conf

Copy the following into it

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

Restart Nginx

service nginx 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

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