Installing ZoneMinder on UbuntuServer – Configure Apache

a2enconf zoneminder
Note: It came back with: To activate the new configuration, you need to run:
service apache2 reload
Note: Not sure if I do this now or not…
Decided to do now, even though two more commands to go

a2enmod cgi
Note: It came back with: AH00558: apache2: Could not reliably determine the server’s fully qualified domain name, using 127.0.1.1. Set the ‘ServerName’ directive globally to suppress this message
Enabling module cgi.
To activate the new configuration, you need to run:
service apache2 restart
Note: Did the: service apache2 restart

a2enmod rewrite
Note: It came back with: Enabling module rewrite.
To activate the new configuration, you need to run:
service apache2 restart
Note: Did the: service apache2 restart

Note: That’s it for this post. Now it’s on to enable and start ZoneMinder.

Installing ZoneMinder on UbuntuServer – Configuring dB

Now that the software is installed, I need to configure the ZoneMinder database.

ZoneMinder Installation

mysql -uroot -p < /usr/share/zoneminder/db/zm_create.sql Note: Entered my root password on file. I suppose this is creating a database. I also confirmed the files path of zoneminder files before running the command. mysql -uroot -p -e "grant select,insert,update,delete,create,alter,index,lock tables on zm.* to 'zmuser'@localhost identified by 'zmpass';" Note: I did a copy and past of this command; entered password; came back pretty quick. Maybe it's just a security update. Setting Permissions
Set /etc/zm/zm.conf to root:www-data 740 and www-data access to content
Note: Not sure what this means, but I’m setting permissions
chmod 740 /etc/zm/zm.conf
Note: Done
chown root:www-data /etc/zm/zm.conf
Note: Done
chown -R www-data:www-data /usr/share/zoneminder/
Note: Done

Note: That’s it for this post. On to configuring Apache.

Installing ZoneMinder on UbuntuServer – Zoneminder repo

Goal is to install the latest version of ZoneMinder

ZoneMinder Installation

Either run commands in this install using sudo or use the below to become root
sudo -i
Note: When I do this it asks for my password, and the prompt goes from $ to #, so I know it’s root access now

Appears that ZoneMinder is available via Ubuntu directly, but if I want the absolute latest, I need to configure something for iconnor — not sure who or what iconnor is, but I’ll do that

add-apt-repository ppa:iconnor/zoneminder
Note: Came back with references to requesting keyrings. Says that a trustdb is created.
Says Launchpad PPA for Isaac Connor imported — so it some guy called Isaac…

Update repo and upgrade
Note: I’m thinking this is redundant because I’ve just done the upgrade to UbuntuServer 16.04, but I’ll do anyway
apt-get update
Note: Done
apt-get upgrade
Note: Done
apt-get dist-upgrade
Note: Done

Configuring MySQL:
Looks like I have version 5.7.29 of MySQL installed
Certain new defaults in MySQL 5.7 are currently causing some issues with ZoneMinder, the workaround is to modify the sql_mode setting of MySQL.

To better manage the MySQL server it is recommended to copy the sample config file and replace the default my.cnf symbolic link.

rm /etc/mysql/my.cnf (this removes the current symbolic link)
Note: This removes the file my.cnf
Note: Before doing this command, I opened the file. Aside from a bunch of comments, there are lines:
!includedir /etc/mysql/conf.d/
!includedir /etc/mysql/mysql.conf.d/

rm /etc/mysql/my.cnf
Note: File has been deleted

cp /etc/mysql/mysql.conf.d/mysqld.cnf /etc/mysql/my.cnf
Note: The file my.cnf has way more stuff in it now

Change the settings in my.cnf with an application called nano
nano /etc/mysql/my.cnf

In the [mysqld] section add the following:
sql_mode = NO_ENGINE_SUBSTITUTION

CTRL+o then [Enter] to save
CTRL+x to exit
Note: I went back into to my.cnf and confirmed change. OK.

Restart MySQL Server
systemctl restart mysql
Note: Done

Install ZoneMinder
Note: I’m going to do a new post for the configuration, as this is getting long.
Note: So far so good. Don’t exactly know what all the commands are really doing, but I’m just following instructions…

apt-get install zoneminder
Note: This takes a while. Letting it unpack and chug.
Note: Wasn’t that bad — about 4-5 minutes long.

Now to configure the database

Installing ZoneMinder on UbuntuServer – LAMP

Now that I’ve done the upgrade to UbuntuServer 16.04, I can start the installation of ZoneMinder.

ZoneMinder Installation

Summary: Got Apache, MySQL and PHP installed and verified versions. See below.

First thing is installing LAMP (Apache, MySQL, PHP).

I’m not sure if this is already running, though. I checked with these statements:
dpkg -s apache2 | grep Status
Not installed
dpkg -s php5 | grep Status
Not installed

Installing LAMP, because I must not have done this during initial server install:
sudo tasksel install lamp-server
Note: Entered a password for MySQL Administrative “Root” user and filed

Tested to see if LAMP now installed/running:
dpkg -s apache2 | grep Status
Came back with files and directory

dpkg -s php5 | grep Status
Note: didn’t come back installed, but maybe LAMP is a different version of PHP

lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 16.04.3 LTS
Release: 16.04
Codename: xenial
Note: This confirms I did the server upgrade correctly to 16.04

/usr/sbin/apache2 -V
Server version: Apache/2.4.18 (Ubuntu)
Server built: 2017-09-18T15:09:02
Note: Looks like it installed version 2.4.18 of Apache

dpkg -s apache2 | grep Status
Status: install ok installed
Note: Really confirming that Apache is installed

mysql -u root -p
Note: I forgot that I had created a password for root.
mysql> select version();
+————————-+
| version() |
+————————-+
| 5.7.20-0ubuntu0.16.04.1 |
+————————-+
1 row in set (0.00 sec)
Note: Looks like I have version 5.7.29 of MySQL installed
Note: “quit” to quit out of MySQL prompt

php5 -v
No command ‘php5’ found, did you mean:
Command ‘php’ from package ‘php7.0-cli’ (main)
Note: Guess I don’t have version 5 of PHP

php -v
PHP 7.0.22-0ubuntu0.16.04.1 (cli) ( NTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2017 Zend Technologies
with Zend OPcache v7.0.22-0ubuntu0.16.04.1, Copyright (c) 1999-2017, by Zend Technologies
Note: Confirmed I have version 7.0.22 installed

Nearly forgot to test to see if my webserver is up and running:

http://192.168.1.15/
This is the default welcome page used to test the correct operation of the Apache2 server after installation on Ubuntu systems. It Works!

Looks like LAMP is installed, webserver is running, and now on to the next step…

Upgrading UbuntuServer from 14.04.4 LTS to 16.04.3 LTS

Summary and Lessons Learned:
-I needed to do an upgrade to the latest 14.04.5 LTS, first:
sudo apt update
sudo apt dist-upgrade
-Then the upgrade to version 16, using:
sudo do-release-upgrade (and followed all prompts)
Note: When asked to leave file as default – left as default

Figured it would be ideal to have the newest UbuntuServer running before installing the Security software (ZoneMinder).

When logging in to the server it says:

Welcome to Ubuntu 14.04.4 LTS (GNU/Linux 4.2.0-27-generic i686)
New release ‘16.04.3 LTS’ available.
Run ‘do-release-upgrade’ to upgrade to it.

Note: I know I have a 32-bit server — old laptop

I suppose I should be trying to backup first, but I haven’t done anything on the server so far.

Figured I should be root when doing upgrade:
sudo su

Message about SSH
Continue running under SSH?

This session appears to be running under ssh. It is not recommended
to perform a upgrade over ssh currently because in case of failure it
is harder to recover.

If you continue, an additional ssh daemon will be started at port
‘1022’.
Do you want to continue?
Note: I suppose I could do the upgrade directly on the server, but I’m going to use SSH for now.

Starting additional sshd

To make recovery in case of failure easier, an additional sshd will
be started on port ‘1022’. If anything goes wrong with the running
ssh you can still connect to the additional one.
If you run a firewall, you may need to temporarily open this port. As
this is potentially dangerous it’s not done automatically. You can
open the port with e.g.:
‘iptables -I INPUT -p tcp –dport 1022 -j ACCEPT’

Required depends is not installed

The required dependency ‘apt (>= 1.0.1ubuntu2.13)’ is not installed.
=== Command detached from window (Wed Dec 13 22:12:05 2017) ===
=== Command terminated with exit status 1 (Wed Dec 13 22:12:15 2017) ===

Note: That didn’t work…
I did find these two commands, so I’ll try that:

sudo apt-get install –reinstall update-manager-core
sudo apt-get install –reinstall update-manager
Note: Waited for a bunch of unpacking and installing to happen

Restarted Server
Note: Same version 14

Referring to Ubuntu Documentation:
-Install the update-manager-core package if it is not already installed.

OK – Note: May not need to do this again, but I did:
sudo apt-get install –reinstall update-manager-core
sudo apt-get install –reinstall update-manager

-Make sure the /etc/update-manager/release-upgrades is set to normal if you are using 15.10, lts if you are using 14.04 LTS.
Note: I confirmed file says “lts”

-Launch the upgrade tool with the command sudo do-release-upgrade.

Error: The required dependency ‘apt (>= 1.0.1ubuntu2.13)’ is not installed.

I’ve had the exact same problem today. Make sure your version is the latest Ubuntu 14.04 version before the upgrade. (Ubuntu 14.04.4 at this time)

Mine was stuck to Ubuntu 14.04.3 due to a bad mirror.

So first run:

sudo apt update
-Done

sudo apt dist-upgrade
-Done

Make sure the version is now Ubuntu 14.04.4 (update September 2016 : Ubuntu 14.04.5).

cat /etc/lsb-release
DISTRIB_DESCRIPTION=”Ubuntu 14.04.5 LTS”

And start Ubuntu 16.04 installation with

sudo do-release-upgrade

-Follow the on-screen instructions.

Welcome to Ubuntu 16.04.3 LTS (GNU/Linux 4.4.0-103-generic i686)

DONE!

Compilation of interests, thoughts and musings…