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

From ZoneMinder Wiki
Jump to navigationJump to search
(Added missing notations and steps regards cli install errors to ignore and user permissions setup)
 
(79 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.
 
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.


__TOC__
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:


===Ubuntu 16.10 with LAMP===
#!/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


This procedure can be used to install Zoneminder on a basic Ubuntu install, a server install or a desktop install.
Copy the contents of the script, open a terminal and run:


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.
nano zm-install


Ubuntu Server Install: When prompted by Tasksel install OpenSSH Server, and LAMP Server.
Paste the contents of the script into Nano


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


If you get a blank screen after installing Ubuntu 16.04 minimal install or server, press Alt + F1 to open a console.
Ctrl + o
Ctrl + x


Next run:


Log in then become root:
chmod 755 zm-install


sudo su
Start the script by entering:


Make sure you are up to date
./zm-install


apt-get update
Follow the prompts. Things are pretty simple. The timezone is now set in Zoneminder/Options.
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..
Good Luck!


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
===MySQL 8 - Additional Steps - Ubuntu 19.10 - Retained for reference===


You will need to make a settings change to MySQL 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'''


Note: The MySQL default configuration file (/etc/mysql/mysql.cnf)is read through several symbolic links beginning with /etc/mysql/my.cnf as follows:
MySQL 8 has added security measures that will have to be modified to run Zoneminder.  
/etc/mysql/my.cnf -> /etc/alternatives/my.cnf
/etc/alternatives/my.cnf -> /etc/mysql/mysql.cnf


/etc/mysql/mysql.cnf is a basic file


To better manage the MySQL server I recommend you copy the sample config file and replace the default my.cnf 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"


rm /etc/mysql/my.cnf  (this removes the current symbolic link)


cp /etc/mysql/mysql.conf.d/mysqld.cnf /etc/mysql/my.cnf
Secure MySQL if you haven't already done it. Do not activate VALIDATE PASSWORD COMPONENT.


To change MySQL settings:
mysql_secure_installation


nano /etc/mysql/my.cnf
Edit MySQL configuration to use native password


In the [mysqld] section add the following
nano /etc/mysql/mysql.conf.d/mysqld.cnf


sql_mode = NO_ENGINE_SUBSTITUTION
Below [mysqld] add


Ctrl+o Enter to save
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.
 
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


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


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.
Start with a basic Ubuntu 18.04 install. You can use a server or desktop install. Do not install LAMP!


apt-get install mysqltuner
Become root


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


===Install Zoneminder 1.30.0===
Install Ngnix, Mariadb and PHP components


Install Zoneminder
apt install nginx mariadb-server php-fpm php-mysql fcgiwrap


apt-get install zoneminder
Secure the Mariadb server


NOTE: Ignore "Error [1819]" and/or "DBI connect" errors, etc. while apt is configuring the package as these are generated due to code for upgrading purposes and is not relevant to the first-time install. You will be fixing these errors as you proceed through the next steps.
mysql_secure_installation


Create Zoneminder database in MySQL (Note: this also creates the default Zoneminder user and permissions in MySQL)
Restart Mariadb


  mysql -uroot -p < /usr/share/zoneminder/db/zm_create.sql
  systemctl restart mysql


mysql -uroot -p -e "grant all on zm.* to 'zmuser'@localhost identified by 'zmpass';"
Edit the php.ini file (Change the PHP version for Ubuntu 20.04!


  mysqladmin -uroot -p reload
  nano /etc/php/7.2/fpm/php.ini
 
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;


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
In the "server" section after listen [::] :80 default_Server; add
'''
 
  [Date]
include /etc/nginx/zoneminder.conf;
  ; Defines the default timezone used by the date functions
 
  ; http://php.net/date.timezone
Ctrl+o Enter to save
  date.timezone = America/New_York
 
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+o Enter to save


CTRL+x to exit
CTRL+x to exit  


Restart Apache
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;


service apache2 reload
Create or edit the fcgiwrap:


Open Zoneminder in a web browser (http://server-ip/zm).
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.


===Optional Upgrade to MariaDB Server 10.0. before installing Zoneminder===
DAEMON_OPTS=-c 10


MariaDB has some enhanced features which do not exist in MySQL and thus migration back to MySQL might not always work.
Ctrl+o Enter to save


'''Note: This procedure is to upgrade to Mariadb before installing Zoneminder!'''
CTRL+x to exit


Upgrade the LAMP installed MySQL 5.7 to Mariadb with the command:
then restart the fcgiwrap service.


  apt-get install mariadb-server
  systemctl restart fcgiwrap


Secure Mariadb, create root password et. al.
Open Zoneminder and under Options set your timezone.


mysql_secure_installation
==Install Zoneminder 1.34.x on Ubuntu 16.04 with shell script==


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).
This will install Zoneminder by using a shell script with one basic command (how easy is that!).


rm /etc/mysql/my.cnf  (this removes the current symbolic link)
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


cp /etc/mysql/mariadb.conf.d/50-server.cnf /etc/mysql/my.cnf
Shell script file contents:


To change Mariadb settings:
#!/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


nano /etc/mysql/my.cnf
Copy the contents of the script, open a terminal and run:


Ctrl+o Enter to save
nano zm-install


CTRL+x to exit
Paste the contents of the script into Nano


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


apt-get install mysqltuner
Ctrl + o
Ctrl + x


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
Next run:


chmod 755 zm-install


Start the script by entering:


----------------------------------------------------------------------------------------
./zm-install


===Optional Upgrade to MariaDB Server 10.0. with Zoneminder (or other databases) installed===
Follow the prompts. Things are pretty simple. Remember to open Zoneminder and set the timezone under options.


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.
Good Luck!


Stop Zoneminder
==Zoneminder 1.34.x on Ubuntu Server 14.04==


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


Backup Zoneminder database (or other databases)
Install Basic Server (if you used the mini.iso), OpenSSH Server, and LAMP Server


mysqldump -uroot -p zm > zm.sql
Log in then become root:


Upgrade the LAMP installed MySQL 5.7 to Mariadb with the command:
sudo su


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


Secure Mariadb, create root password et. al.
add-apt-repository ppa:iconnor/zoneminder
add-apt-repository ppa:iconnor/zoneminder-1.34


mysql_secure_installation
Update Sources


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.
apt-get update


Remove the current symbolic link
Install Zoneminder


  rm /etc/mysql/my.cnf 
  apt-get install zoneminder


Create new my.cnf
Add delay to allow MySQL to start before Zoneminder


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


To change Mariadb settings:
Add sleep 15 after the existing "start() {" as shown:


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


Ctrl+o Enter to save
Ctrl+o Enter to save
Line 236: 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