Difference between revisions of "Ubuntu Server or Desktop Zoneminder 1.34.x"

From ZoneMinder Wiki
Jump to navigationJump to search
m (Create all-caps notaions flag to get attention of tired eyes better.)
 
(75 intermediate revisions by 4 users not shown)
Line 1: Line 1:
'''Zoneminder 1.30.0 on Ubuntu 16.10 Server '''
__TOC__
 
'''Security Note: Prior version of my install procedure and install script contained  a "Fix Permissions: chown -R www-data:www-data /usr/share/zoneminder/" step. It has been brought to my attention that this could allow the www-data user to write inthis area which is not a good thing. To correct this on your system run: chown -R root:root /usr/share/zoneminder/
'''
 
'''Note: the same install procedure applies for server or desktop. Ubuntu 19.04 is not included as support for this release ends January 2020.'''
 
'''A word of caution for upgraders. As of 22JAN20 the PPA/zoneminder-master, the development area, has versions of Zoneminder 1.34. If you were using the 1.33.x development version of Zoneminder and you apt update - apt upgrade without changing to PPA/zoneminder-1.34 you will get the next development version. Just be aware that it is possible some things may not work!'''
 
'''Also, these procedures are for a new Zoneminder install. Upgraders are encouraged to check the Zoneminder-1.34 Forum area for information.'''
 
 
 
 
==Install Zoneminder 1.34.x on Ubuntu 20.04, 18.04 with shell script==
 
This will install Zoneminder 1.34.x by using a shell script with one basic command (how easy is that!).
 
You will need a Ubuntu 20.40 or 18.04 install with LAMP (Apache, Mariadb and PHP) installed desktop or server.
 
As an alternate you may use MySQL in lieu of Mariadb but I find Mariadb easier to work with.


__TOC__
Google is your friend if you need instructions for setting up a LAMP server. However, a simple LAMP can be installed with these commands:


===Ubuntu 16.10 with LAMP===
apt install apache2 php mariadb-server php-mysql libapache2-mod-php


This procedure can be used to install Zoneminder on a basic Ubuntu install, a server install or a desktop install.  
Secure Mariadb, create root password et. al.


Ubuntu basic install can be done from the net install CD (https://www.ubuntu.com/download/alternative-downloads) This is creates a CD from the file mini.iso. When prompted (tasksel) install standard system utilities, OpenSSH Server, and LAMP Server. This is the minimum that is required to set up and run Zoneminder and does not load other apps that are not needed.
mysql_secure_installation


Ubuntu Server Install: When prompted by Tasksel install OpenSSH Server, and LAMP Server.
'''Note: As of 31MAR20 the iconnor PPA contains the install files for Focal Develpoment version, Ubuntu 20.04. I have tested this script on a server live install of Focal. Should work for you and I will keep up to date as Focal nears the release date.'''


Ubuntu Desktop: You will have to install tasksel in a terminal (sudo apt-get install tasksel) then run tasksel to install OpenSSH Server, and LAMP Server.
Shell script file contents:


If you get a blank screen after installing Ubuntu 16.04 minimal install or server, press Alt + F1 to open a console.
#!/bin/sh
clear
read -p "This script installs Zoneminder 1.34.x on Ubuntu 20.04 or 18.04 with LAMP (MySQL or Mariadb) installed...
Press Enter to continue or Ctrl + c to quit" nothing
clear
read -p "You must be logged in as root using sudo su If you are installing on MySQL 8 perform the additional steps before continuing!
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.34
apt update
clear
apt install -y zoneminder
systemctl enable zoneminder
service zoneminder start
adduser www-data video
a2enconf zoneminder
a2enmod rewrite
a2enmod headers
a2enmod expires
service apache2 reload
clear
read -p "Install complete. Open Zoneminder/Options and set the timezine. 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


Log in then become root:
Then:
 
Ctrl + o
Ctrl + x
 
Next run:


  sudo su
  chmod 755 zm-install


Make sure you are up to date
Start the script by entering:


  apt-get update
  ./zm-install
apt-get upgrade
apt-get dist-upgrade


At this point you should have Ubuntu 16.10 installed with LAMP which includes the default MySQL 5.7. You have the option to use Mariadb Server 10.0 which will replace MySQL 5.7 (Click on Options link in Contents above) or continue with MySQL 5.7..
Follow the prompts. Things are pretty simple. The timezone is now set in Zoneminder/Options.


You may want to set the system swap file usage. See:  https://wiki.zoneminder.com/Common_Issues_with_Zoneminder_Installation_on_Ubuntu#Ubuntu_Swap_File
Good Luck!


You will need to make a settings change to MySQL as follows:
===MySQL 8 - Additional Steps - Ubuntu 19.10 - Retained for reference===


NOTE:  The MySQL default configuration file (/etc/mysql/mysql.cnf)is read through several symbolic links beginning with /etc/mysql/my.cnf as follows:
'''19MAY20 it has been verified with Ubuntu 20.04 with MySQL 8 and PHP 7.4 that the addition of "default_authentication_plugin = mysql_native_password" is not required. This was tested on a system that did not have the "VALIDATE PASSWORD COMPONENT" activated. This will be retained just-in-case someone still wants to install Zoneminder on Ubuntu 19.10'''
/etc/mysql/my.cnf -> /etc/alternatives/my.cnf
/etc/alternatives/my.cnf -> /etc/mysql/mysql.cnf


/etc/mysql/mysql.cnf is a basic file
MySQL 8 has added security measures that will have to be modified to run Zoneminder.  


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


rm /etc/mysql/my.cnf  (this removes the current symbolic link)
This procedure should be done before installing Zoneminder. However, I have done it before and after running the install. If done before installing Zoneminder you will see errors reported after the zm database is created. That's OK as the error is the install package not creating the "zmuser" which what this procedure does. If you run this procedure after the install you will see the same error and additional error when the script tries to start Zoneminder. Just run this procedure and when done run "systemctl start zoneminder"


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


To change MySQL settings:
Secure MySQL if you haven't already done it. Do not activate VALIDATE PASSWORD COMPONENT.


  nano /etc/mysql/my.cnf
  mysql_secure_installation


In the [mysqld] section add the following
Edit MySQL configuration to use native password


  sql_mode = NO_ENGINE_SUBSTITUTION
  nano /etc/mysql/mysql.conf.d/mysqld.cnf


Ctrl+o Enter to save
Below [mysqld] add
 
default_authentication_plugin = mysql_native_password


CTRL+x to exit
CTRL + o to save CTRL +x to exit


Restart MySQL
Restart MySQL
Line 60: Line 112:
  systemctl restart mysql
  systemctl restart mysql


Recommended: Secure MySQL.
Note: The Zoneminder package will not complete successfully and will show errors. This will be corrected in the next step.


WARNING:  Do _NOT_ setup the VALIDATE PASSWORD plugin during the following step or it will cause the creation of the 'admin' account in the 'zm' MySQL database to fail. If needed, please enable this plugin _after_ you manually change the 'admin' password in a running instance of Zoneminder from the web interface. Be sure that the new 'admin' password will satisfy the plugin strength level that you chose at the time you enabled it!
Create user and set permissions (press Enter after each entry)


  mysql_secure_installation
  mysql (Enter MySQL processing)
 
mysql> CREATE USER 'zmuser'@localhost IDENTIFIED WITH mysql_native_password BY 'zmpass';
 
mysql> GRANT ALL PRIVILEGES ON zm.* TO 'zmuser'@'localhost' WITH GRANT OPTION;
 
mysql> FLUSH PRIVILEGES ;
 
mysql> \q
 
Reload MySQL
 
mysqladmin -uroot -p reload
 
You may now install Zoneminder
 
==Install Zoneminder 1.34.x on Ubuntu 18.04 LEMP (NGNIX, Mariadb, PHP)==
 
Thanks to "terdinglage" for the input to get this to work!
 
While not tested this procedure should work on Ubuntu 19.10 using PHP 7.3 and Ubuntu 20.04 using PHP 7.4.
 
Start with a basic Ubuntu 18.04 install. You can use a server or desktop install. Do not install LAMP!


Become root


Optional: A tool that you may want to install is mysqltuner. This is handy to see what database parameters need to be adjusted as your ZM system builds up events.
sudo su


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


Once installed, run mysqltuner from a command prompt as root (sudo). Review recommended changes. Edit the configuration file (my.cnf) and make the recommended changes. Stop zoneminder, restart the database server then start zoneminder.
apt install nginx mariadb-server php-fpm php-mysql fcgiwrap


===Install Zoneminder 1.30.0===
Secure the Mariadb server


Install Zoneminder
mysql_secure_installation


apt-get install zoneminder
Restart Mariadb


Create Zoneminder database in MySQL (NOTE: this also creates the default Zoneminder user and permissions in MySQL)
  systemctl restart mysql


mysql -uroot -p < /usr/share/zoneminder/db/zm_create.sql
Edit the php.ini file (Change the PHP version for Ubuntu 20.04!


  mysql -uroot -p -e "grant all on zm.* to 'zmuser'@localhost identified by 'zmpass';"
  nano /etc/php/7.2/fpm/php.ini


mysqladmin -uroot -p reload
Locate (Ctrl+w) cgi.fix_pathinfo=1 and change to


cgi.fix_pathinfo=0


Set permissions of /etc/zm/zm.conf to root:www-data 740
Remember to remove the leading ;


chmod 740 /etc/zm/zm.conf
Ctrl+o Enter to save


chown root:www-data /etc/zm/zm.conf
CTRL+x to exit


Create a new user
Restart php-fpm


  adduser www-data video
  systemctl restart php7.2-fpm


Enable CGI, Zoneminder and rewrite configuration in Apache.


a2enmod cgi
Add Repository


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


  a2enmod rewrite
  add-apt-repository ppa:iconnor/zoneminder-1.34


Fix Permissions


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


Fix to allow API to work
apt install zoneminder


nano /etc/apache2/apache2.conf
Create a new user if you plan to use local (USB or capture card) cameras.


Change None to All two places as shown below
adduser www-data video


<Directory /usr/share>
Change the ZM_PATH_ZMS in the 01-system-paths.conf file to /cgi-bin/nph-zms by dropping the /zm/  
        AllowOverride All
        Require all granted
</Directory>


  <Directory /var/www/>
  nano /etc/zm/conf.d/01-system-paths.conf
        Options Indexes FollowSymLinks
        AllowOverride All
        Require all granted
</Directory>


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


CTRL+x to exit
CTRL+x to exit  


Enable and start Zoneminder
Enable and start Zoneminder
Line 137: Line 204:
  service zoneminder start
  service zoneminder start


Add timezone to PHP


  nano /etc/php/7.0/apache2/php.ini
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


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
  include /etc/nginx/zoneminder.conf;
'''
[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+o Enter to save


CTRL+x to exit
CTRL+x to exit  


Restart Apache
Create a Zoneminder conf file


  service apache2 reload
  nano /etc/nginx/zoneminder.conf


Enter the following into the zoneminder.conf file (This file was improved by databoy2k)
Change "php7.2-fpm.sock" to "php7.4-fpm.sock" for Ubuntu 20.04.


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;
        }
    }


'''IMPORTANT FINAL STEP:'''  open Zoneminder in a web browser (http://server-ip/zm). Click on Options - Paths and change '''PATH_ZMS''' to
Ctrl+o Enter to save


/zm/cgi-bin/nph-zms
CTRL+x to exit


Click the '''SAVE''' button
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;


Create or edit the fcgiwrap:


nano /etc/default/fcgiwrap


---------------------------------------------------------------------------------------
and insert (with the number of children -c equal to the number of cameras) Note that you may need to have this value larger than the number if cameras. In my case I run "camera walls" from a custom web page that accesses the Zoneminder monitors. I have needed to increase the -c to include the number of cameras in the camera wall web pages.


---------------------------------------------------------------------------------------
DAEMON_OPTS=-c 10


===Optional Upgrade to MariaDB Server 10.0. before installing Zoneminder===
Ctrl+o Enter to save


MariaDB has some enhanced features which do not exist in MySQL and thus migration back to MySQL might not always work.
CTRL+x to exit


'''NOTE:  This procedure is to upgrade to Mariadb before installing Zoneminder!'''
then restart the fcgiwrap service.


Upgrade the LAMP installed MySQL 5.7 to Mariadb with the command:
systemctl restart fcgiwrap


apt-get install mariadb-server
Open Zoneminder and under Options set your timezone.


Secure Mariadb, create root password et. al.
==Install Zoneminder 1.34.x on Ubuntu 16.04 with shell script==


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


NOTE:  The MySQL/MariaDB configuration file is located at: /etc/mysql/mysql.conf.d/mysqld.cnf To better manage the MariaDB server I recommend you move the config file and replace the default my.cnf symbolic link (this also works for MySQL 5.6).
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


rm /etc/mysql/my.cnf  (this removes the current symbolic link)
Shell script file contents:


  cp /etc/mysql/mariadb.conf.d/50-server.cnf /etc/mysql/my.cnf
  #!/bin/sh
clear
read -p "This script installs Zoneminder 1.34.x on Ubuntu 16.04 with LAMP (MySQL or Mariadb) 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 two PPA repositorys, 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-1.34
apt update
clear
apt install -y zoneminder
systemctl enable zoneminder
service zoneminder start
adduser www-data video
a2enconf zoneminder
a2enmod rewrite
service apache2 reload
clear
read -p "Install complete. Open Zoneminder/Options and set timezone. Press enter to continue" nothing
clear


To change Mariadb settings:
Copy the contents of the script, open a terminal and run:


  nano /etc/mysql/my.cnf
  nano zm-install


Ctrl+o Enter to save
Paste the contents of the script into Nano


CTRL+x to exit
Then:


A tool that you may want to install is mysqltuner. This is handy to see what database paramaters need to be adjusted as your ZM system builds up events.
Ctrl + o
Ctrl + x


apt-get install mysqltuner
Next run:


Continue installing Zoneminder: https://wiki.zoneminder.com/Ubuntu_Server_16.10_64-bit_with_Zoneminder_1.30.0_the_easy_way#Install_Zoneminder_1.30.0
chmod 755 zm-install


Start the script by entering:


./zm-install


----------------------------------------------------------------------------------------
Follow the prompts. Things are pretty simple. Remember to open Zoneminder and set the timezone under options.


===Optional Upgrade to MariaDB Server 10.0. with Zoneminder (or other databases) installed===
Good Luck!


NOTE:  This procedure is concerned with backing up and recreating the Zoneminder database. You can use the same commands, with other database names, if your system has other databases running in MySQL.
==Zoneminder 1.34.x on Ubuntu Server 14.04==


Stop Zoneminder
Note: While this install seems to work, 14.04 is old and you will have a better system with 18.04.


service zoneminder stop
Install Basic Server (if you used the mini.iso), OpenSSH Server, and LAMP Server


Backup Zoneminder database (or other databases)
Log in then become root:


  mysqldump -uroot -p zm > zm.sql
  sudo su


Upgrade the LAMP installed MySQL 5.7 to Mariadb with the command:
Add the following two Repositories (if you get an error run: apt-get install software-properties-common)


  apt-get install mariadb-server
  add-apt-repository ppa:iconnor/zoneminder
add-apt-repository ppa:iconnor/zoneminder-1.34


Secure Mariadb, create root password et. al.
Update Sources


  mysql_secure_installation
  apt-get update


NOTE:  The MySQL/MariaDB configuration file is located at: /etc/mysql/mysql.conf.d/mysqld.cnf To better manage the MariaDB server I recommend you move the config file and replace the default my.cnf symbolic link.
Install Zoneminder


Remove the current symbolic link
apt-get install zoneminder


rm /etc/mysql/my.cnf 
Add delay to allow MySQL to start before Zoneminder


Create new my.cnf
nano /etc/init.d/zoneminder


cp /etc/mysql/mariadb.conf.d/50-server.cnf /etc/mysql/my.cnf
Add sleep 15 after the existing "start() {" as shown:


To change Mariadb settings:
start() {
 
      sleep 15
nano /etc/mysql/my.cnf
      echo -n "Starting $prog: "


Ctrl+o Enter to save
Ctrl+o Enter to save
Line 248: Line 385:
CTRL+x to exit  
CTRL+x to exit  


Create new empty zm database


mysql -uroot -p
Create a new user


You are now in the Mariadb console
adduser www-data video


CREATE DATABASE zm;
Enable CGI, Zoneminder and rewrite configuration in Apache.


Quit Mariadb console
a2enmod cgi


  \q
  a2enconf zoneminder


Restore zm database from backup
a2enmod rewrite


mysql -uroot -p zm < zm.sql
Start Zoneminder if needed (If you get an error Zoneminder is likely running already)


Set permissions
service zoneminder start


mysql -uroot -p -e "grant all on zm.* to 'zmuser'@localhost identified by 'zmpass';"
Restart Apache


Start Zoneminder
  service apache2 reload
 
  service zoneminder start


You should now be running Mariadb server!
Open Zoneminder and set timezone under Options

Latest revision as of 03:46, 15 April 2021

Security Note: Prior version of my install procedure and install script contained a "Fix Permissions: chown -R www-data:www-data /usr/share/zoneminder/" step. It has been brought to my attention that this could allow the www-data user to write inthis area which is not a good thing. To correct this on your system run: chown -R root:root /usr/share/zoneminder/

Note: the same install procedure applies for server or desktop. Ubuntu 19.04 is not included as support for this release ends January 2020.

A word of caution for upgraders. As of 22JAN20 the PPA/zoneminder-master, the development area, has versions of Zoneminder 1.34. If you were using the 1.33.x development version of Zoneminder and you apt update - apt upgrade without changing to PPA/zoneminder-1.34 you will get the next development version. Just be aware that it is possible some things may not work!

Also, these procedures are for a new Zoneminder install. Upgraders are encouraged to check the Zoneminder-1.34 Forum area for information.



Install Zoneminder 1.34.x on Ubuntu 20.04, 18.04 with shell script

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

You will need a Ubuntu 20.40 or 18.04 install with LAMP (Apache, Mariadb and PHP) installed desktop or server.

As an alternate you may use MySQL in lieu of Mariadb but I find Mariadb easier to work with.

Google is your friend if you need instructions for setting up a LAMP server. However, a simple LAMP can be installed with these commands:

apt install apache2 php mariadb-server php-mysql libapache2-mod-php

Secure Mariadb, create root password et. al.

mysql_secure_installation

Note: As of 31MAR20 the iconnor PPA contains the install files for Focal Develpoment version, Ubuntu 20.04. I have tested this script on a server live install of Focal. Should work for you and I will keep up to date as Focal nears the release date.

Shell script file contents:

#!/bin/sh
clear
read -p "This script installs Zoneminder 1.34.x on Ubuntu 20.04 or 18.04 with LAMP (MySQL or Mariadb) installed...
Press Enter to continue or Ctrl + c to quit" nothing
clear
read -p "You must be logged in as root using sudo su If you are installing on MySQL 8 perform the additional steps before continuing!
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.34
apt update
clear
apt install -y zoneminder
systemctl enable zoneminder
service zoneminder start
adduser www-data video
a2enconf zoneminder
a2enmod rewrite
a2enmod headers
a2enmod expires
service apache2 reload
clear
read -p "Install complete. Open Zoneminder/Options and set the timezine. 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 is now set in Zoneminder/Options.

Good Luck!

MySQL 8 - Additional Steps - Ubuntu 19.10 - Retained for reference

19MAY20 it has been verified with Ubuntu 20.04 with MySQL 8 and PHP 7.4 that the addition of "default_authentication_plugin = mysql_native_password" is not required. This was tested on a system that did not have the "VALIDATE PASSWORD COMPONENT" activated. This will be retained just-in-case someone still wants to install Zoneminder on Ubuntu 19.10

MySQL 8 has added security measures that will have to be modified to run Zoneminder.


This procedure should be done before installing Zoneminder. However, I have done it before and after running the install. If done before installing Zoneminder you will see errors reported after the zm database is created. That's OK as the error is the install package not creating the "zmuser" which what this procedure does. If you run this procedure after the install you will see the same error and additional error when the script tries to start Zoneminder. Just run this procedure and when done run "systemctl start zoneminder"


Secure MySQL if you haven't already done it. Do not activate VALIDATE PASSWORD COMPONENT.

mysql_secure_installation

Edit MySQL configuration to use native password

nano /etc/mysql/mysql.conf.d/mysqld.cnf

Below [mysqld] add

default_authentication_plugin = mysql_native_password

CTRL + o to save CTRL +x to exit

Restart MySQL

systemctl restart mysql

Note: The Zoneminder package will not complete successfully and will show errors. This will be corrected in the next step.

Create user and set permissions (press Enter after each entry)

mysql (Enter MySQL processing)
mysql> CREATE USER 'zmuser'@localhost IDENTIFIED WITH mysql_native_password BY 'zmpass';
mysql> GRANT ALL PRIVILEGES ON zm.* TO 'zmuser'@'localhost' WITH GRANT OPTION;
mysql> FLUSH PRIVILEGES ;
mysql> \q

Reload MySQL

mysqladmin -uroot -p reload

You may now install Zoneminder

Install Zoneminder 1.34.x on Ubuntu 18.04 LEMP (NGNIX, Mariadb, PHP)

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

While not tested this procedure should work on Ubuntu 19.10 using PHP 7.3 and Ubuntu 20.04 using PHP 7.4.

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 (Change the PHP version for Ubuntu 20.04!

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 ;

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


Install Zoneminder

apt install zoneminder

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

adduser www-data video

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) Change "php7.2-fpm.sock" to "php7.4-fpm.sock" for Ubuntu 20.04.

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;

Create or edit the fcgiwrap:

nano /etc/default/fcgiwrap

and insert (with the number of children -c equal to the number of cameras) Note that you may need to have this value larger than the number if cameras. In my case I run "camera walls" from a custom web page that accesses the Zoneminder monitors. I have needed to increase the -c to include the number of cameras in the camera wall web pages.

DAEMON_OPTS=-c 10

Ctrl+o Enter to save

CTRL+x to exit

then restart the fcgiwrap service.

systemctl restart fcgiwrap

Open Zoneminder and under Options set your timezone.

Install Zoneminder 1.34.x 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.34.x on Ubuntu 16.04 with LAMP (MySQL or Mariadb) 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 two PPA repositorys, 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-1.34
apt update
clear
apt install -y zoneminder
systemctl enable zoneminder
service zoneminder start
adduser www-data video
a2enconf zoneminder
a2enmod rewrite
service apache2 reload
clear
read -p "Install complete. Open Zoneminder/Options and set timezone. 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. Remember to open Zoneminder and set the timezone under options.

Good Luck!

Zoneminder 1.34.x on Ubuntu Server 14.04

Note: While this install seems to work, 14.04 is old and you will have a better system with 18.04.

Install Basic Server (if you used the mini.iso), OpenSSH Server, and LAMP Server

Log in then become root:

sudo su

Add the following two Repositories (if you get an error run: apt-get install software-properties-common)

add-apt-repository ppa:iconnor/zoneminder
add-apt-repository ppa:iconnor/zoneminder-1.34

Update Sources

apt-get update

Install Zoneminder

apt-get install zoneminder

Add delay to allow MySQL to start before Zoneminder

nano /etc/init.d/zoneminder

Add sleep 15 after the existing "start() {" as shown:

start() {
     sleep 15
     echo -n "Starting $prog: "

Ctrl+o Enter to save

CTRL+x to exit


Create a new user

adduser www-data video

Enable CGI, Zoneminder and rewrite configuration in Apache.

a2enmod cgi
a2enconf zoneminder
a2enmod rewrite

Start Zoneminder if needed (If you get an error Zoneminder is likely running already)

service zoneminder start

Restart Apache

service apache2 reload

Open Zoneminder and set timezone under Options