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

From ZoneMinder Wiki
Jump to navigationJump to search
 
(58 intermediate revisions by 3 users not shown)
Line 1: Line 1:
Shell script zm-install-bionic
__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.
 
mysql_secure_installation


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


===Script for Ubuntu with LAMP (MySQL)===
Shell script file contents:


  #!/bin/sh
  #!/bin/sh
  clear
  clear
  read -p "This script installs Zoneminder 1.30.4 on Ubuntu 18.04 AMD64 with LAMP (MySQL) installed...
  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
  Press Enter to continue or Ctrl + c to quit" nothing
  clear
  clear
  read -p "You must be logged in as root using sudo su ...
  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
  Press Enter to continue or Ctrl + c to quit" nothing
  clear
  clear
read -p "Next secure MySQL server by entering requested information. Press enter to continue" nothing
  read -p "Next we will add the PPA repository, install and configure the system to run Zoneminder.  
mysql_secure_installation
  read -p "Next we will download the Zoneminder install package and install it.
  Press enter to continue" nothing
  Press enter to continue" nothing
  wget --no-check-certificate https://173.163.189.225/zoneminder-1.30.4-bionic-amd64.deb -P /tmp/
  apt install -y software-properties-common
  ls /tmp/zoneminder*
  clear
  read -p "Check above to be sure the file downloaded. Should be:
  add-apt-repository ppa:iconnor/zoneminder-1.34
/tmp/zoneminder-1.30.4-bionic-amd64.deb (5686708)
  apt update
  Press Enter to continue or Ctrl + c to quit" nothing
  clear
  clear
awk '$0="date.timezone = "$0' /etc/timezone >> /etc/php/7.2/apache2/php.ini
  apt install -y zoneminder
echo "[mysqld]" >> /etc/mysql/my.cnf
echo "init_connect = 'SET @@sql_mode = CASE CURRENT_USER() WHEN \'zmuser@localhost\' THEN \'NO_ENGINE_SUBSTITUTION\' ELSE @@sql_mode END;'" >> /etc/mysql/my.cnf
systemctl restart mysql
  apt-get -y install /tmp/zoneminder-1.30.4-bionic-amd64.deb
  systemctl enable zoneminder
  systemctl enable zoneminder
  service zoneminder start
  service zoneminder start
  adduser www-data video
  adduser www-data video
a2enmod cgi
  a2enconf zoneminder
  a2enconf zoneminder
  a2enmod rewrite
  a2enmod rewrite
  chown -R www-data:www-data /usr/share/zoneminder/
  a2enmod headers
a2enmod expires
  service apache2 reload
  service apache2 reload
  clear
  clear
  read -p "Open Zoneminder in a web browser (http://server-ip/zm).
  read -p "Install complete. Open Zoneminder/Options and set the timezine. Press enter to continue" nothing
Click on Options - Paths and change PATH_ZMS to /zm/cgi-bin/nph-zms
Click the Save button.  
Press enter to continue" nothing
  clear
  clear


===Script for Ubuntu 18.04 - will install Apache, Mariadb, PHP and Zoneminder 1.30.4===
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
  #!/bin/sh
  clear
  clear
  read -p "This script installs Apache, Mariadb, PHP, and Zoneminder 1.30.4 on Ubuntu 18.04 AMD64
  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
  Press Enter to continue or Ctrl + c to quit" nothing
  clear
  clear
Line 53: Line 307:
  Press Enter to continue or Ctrl + c to quit" nothing
  Press Enter to continue or Ctrl + c to quit" nothing
  clear
  clear
  read -p "Next we will install Apache, Mariadb Server and PHP
  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 or Ctrl + c to quit" nothing
apt update
apt -y install apache2 mariadb-server mariadb-client php7.2 libapache2-mod-php7.2 php7.2-common php7.2-mbstring php7.2-xmlrpc php7.2-soap php7.2-gd php7.2-xml php7.2-intl php7.2-mysql php7.2-cli php7.2-zip php7.2-curl
clear
read -p "Next secure mariadb server by entering requested information. Press enter to continue" nothing
mysql_secure_installation
read -p "Next we will download the Zoneminder install package. This may take a minute to connect
  Press enter to continue" nothing
  Press enter to continue" nothing
  wget --no-check-certificate 'https://docs.google.com/uc?export=download&id=1bZhVcBnlW46SwCnSnZ0sdZzwtOcCiisX' -O /tmp/zoneminder-1.30.4-bionic-amd64.deb
  apt install -y software-properties-common
ls /tmp/zoneminder*
read -p "Check above to be sure the file downloaded. Should be:
/tmp/zoneminder-1.30.4-bionic-amd64.deb (5686708)
Press Enter to continue or Ctrl + c to quit" nothing
  clear
  clear
  read -p "Next we will add time zone to PHP config files.  
  add-apt-repository ppa:iconnor/zoneminder-1.34
  Press enter to continue" nothing
  apt update
awk '$0="date.timezone = "$0' /etc/timezone >> /etc/php/7.2/apache2/php.ini
  clear
  clear
  read -p "Now we will install, enable and start Zoneminder.
  apt install -y zoneminder
Press enter to continue" nothing
apt-get -y install /tmp/zoneminder-1.30.4-bionic-amd64.deb
  systemctl enable zoneminder
  systemctl enable zoneminder
  service zoneminder start
  service zoneminder start
read -p "Now we will add settings to Apache and restart it.
Press enter to continue" nothing
  adduser www-data video
  adduser www-data video
a2enmod cgi
  a2enconf zoneminder
  a2enconf zoneminder
  a2enmod rewrite
  a2enmod rewrite
chown -R www-data:www-data /usr/share/zoneminder/
  service apache2 reload
  service apache2 reload
  clear
  clear
  read -p "Open Zoneminder in a web browser (http://server-ip/zm).
  read -p "Install complete. Open Zoneminder/Options and set timezone. Press enter to continue" nothing
Click on Options - Paths and change PATH_ZMS to /zm/cgi-bin/nph-zms
Click the Save button.  
Press enter to continue" nothing
  clear
  clear


===Script to patch upgrade from Ubuntu 16.04 to 18.04. Works with MySQL or Mariadb (MySQL)===
Copy the contents of the script, open a terminal and run:
#!/bin/sh
 
clear
nano zm-install
read -p "This script updates Zoneminder 1.30.4 on Ubuntu 18.04 with LAMP (MySQL) after an upgrade from Ubuntu 16.04...
 
Press Enter to continue or Ctrl + c to quit" nothing
Paste the contents of the script into Nano
clear
 
  read -p "You must be logged in as root using sudo su ...
Then:
Press Enter to continue or Ctrl + c to quit" nothing
 
clear
Ctrl + o
read -p "Next we will download the Zoneminder install package. This may take a minute to connect
Ctrl + x
Press enter to continue" nothing
 
  wget --no-check-certificate 'https://docs.google.com/uc?export=download&id=1bZhVcBnlW46SwCnSnZ0sdZzwtOcCiisX' -O /tmp/zoneminder-1.30.4-bionic-amd64.deb
Next run:
  ls /tmp/zoneminder*
 
read -p "Check above to be sure the file downloaded. Should be:
chmod 755 zm-install
  /tmp/zoneminder-1.30.4-bionic-amd64.deb (5686708)
 
  Press Enter to continue or Ctrl + c to quit" nothing
Start the script by entering:
clear
 
read -p "Next we will add settings to PHP config files.
./zm-install
Press enter to continue" nothing
 
awk '$0="date.timezone = "$0' /etc/timezone >> /etc/php/7.2/apache2/php.ini
Follow the prompts. Things are pretty simple. Remember to open Zoneminder and set the timezone under options.
clear
 
read -p "Now we will upgrade, enable and start Zoneminder.
Good Luck!
Press enter to continue" nothing
 
  apt-get -y --allow-downgrades install /tmp/zoneminder-1.30.4-bionic-amd64.deb
==Zoneminder 1.34.x on Ubuntu Server 14.04==
systemctl enable zoneminder
 
service zoneminder start
Note: While this install seems to work, 14.04 is old and you will have a better system with 18.04.
a2enmod php7.2
 
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
  a2enmod cgi
  a2enconf zoneminder
  a2enconf zoneminder
  a2enmod rewrite
  a2enmod rewrite
  chown -R www-data:www-data /usr/share/zoneminder/
 
Start Zoneminder if needed (If you get an error Zoneminder is likely running already)
 
  service zoneminder start
 
Restart Apache
 
  service apache2 reload
  service apache2 reload
clear
 
read -p "Open Zoneminder in a web browser (http://server-ip/zm).
Open Zoneminder and set timezone under Options
Click on Options - Paths and chech that PATH_ZMS is /zm/cgi-bin/nph-zms
Click the Save button.
Press enter to continue" nothing
clear

Latest revision as of 04: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