Zoneminder Installation

Zoneminder is an opensource security camera system that is configurable and scalable.   For my home system, it’s probably overkill, however I feel learning how to install, setup, and use it will be advantageous for future installations and expand my general Linux capabilities.  Here are my step by step instructions to install Zoneminder onto a Linux Xubuntu 14.04.4 LTS system.  Zoneminder has good instructions on their website, but I wanted to record exactly what I did as well as there are some ‘extra’ commands not documented that I captured here.Hikvision camera for zoneminder

Install Xubuntu 14.04.4 LTS onto system.

Install Xubuntu amd 64-bit version from a CD by downloading the torrent from here:  http://xubuntu.org/getxubuntu/  I strongly recommend using the torrent for downloading vs. a direct, single-file download as the torrent is MUCH faster.  I used uTorrent.  Refer to previous blog post about grub_rescue if needed during the install process.  I had horrendous issues with this, but it seems I’m unique.

Install gedit and openssh

Once Linux Xubuntu is installed, I want to install a couple of programs I like to use.  gedit is a simple text editor and openssh is a ‘remote’ in program that allows you to login to the system remotely and using WinSCP from Windows allows easy file transfer between PCs.  From the terminal:
sudo apt-get install gedit
sudo apt-get install openssh-server

SSH to PC as needed

Use the command “ip addr show” to look for the PC IP Address.  In this case it is:  168.192.0.113.

ip addr show

From here, I can use the IP Address to SSH into the new Xubuntu system from another computer and easily transfer files.  In this case I had some setup instructions in a word file that I could use to copy/paste.  I SSH’d from my Windows 7 computer using https://winscp.net/eng/index.php.

Network Setup

At this point, I want to ensure my 2nd Ethernet Card (NIC- Network Interface Card) is setup so that when Zoneminder is installed we’ll be able to talk to the cameras immediately.  I used a 2nd Ethernet card to separate the LAN and the camera Ethernet networks.  The little bit that I read on zoneminder said that I probably wouldn’t have an issue using my existing home network with the cameras, but I think separating the two networks is better practice.   If you have a different network setup (IE, no 2nd ethernet card), skip this section.

The onboard PC ethernet connection will be configured as DHCP to connect to the internet while the 2nd Ethernet card will be setup with a Static IP Address to talk to the cameras.

Here is a block diagram of my Zoneminder system:

zoneminder Architecture Layout Xubuntu

In the figure above, you’ll notice two switches (incorrectly labeled as ROUTERS, I might add), that are used to connect data and power (POE) to the cameras in the front and back of the house.  The most cost effective POE switch I could find was the Trendnet TPE-S44, which has 4 standard ethernet ports (no power for cameras) and 4 POE ethernet ports.  While I show only 4 cameras in the figure above, I think I’ll install 5 or 6 cameras total, so having more POE ports will be required.

One of the cameras I bought has wireless, but I recall my Grandfather complaining about automatic car windows in the 1980’s as “that’s just more to go wrong.”  So, I’m not using wireless for that simple reason…

NIC Ethernet Card Specs:

AirLink AG32PCIv2 10/100/1000Mbps PCI Network Adapter  $6.99
Bought at Fry’s.  Amazon had it, but more $$.

NIC Ethernet Card IP SETUP

Drivers Installed

To install the 2nd Ethernet card, check to see if the drivers are installed.  After doing a little reading on my Airlink card, the drivers are Realtek r8169 drivers. Use the following linux terminal command to see if the drivers are installed:

lsmod | grep r8169
r8169                  81920
mii                    16384 1 r8169

In this case, it looks like the drivers are installed.  On my previous install, I went through and re-installed drivers, but it appears that was not necessary.  I got the drivers from the disk that came with the Ethernet card, which this was about the first time in 15-20 years that I actually installed drivers off a CD!!!  I did after searching for the drivers only to find that the CD had the most current:-)

I read that the Gateway should be setup as the IP address as the switch.  The Trendnet TPE-S44 POE switch I’m using has a default IP Address of 192.168.1.1 and username: admin passwd: router, per this site.  However, I did try to connect into without success.
See installation instructions (word doc) on how to:  sudo gedit etc/network/interfaces

Update /etc/network/interfaces file

To configure the 2nd Ethernet card, we need to update the /etc/network/interfaces file.
#sudo gedit etc/network/interfaces

Here is the modified file:
# interfaces(5) file used by ifup(8) and ifdown(8)
auto lo
iface lo inet loopback

auto eth1
iface eth1 inet dhcp

auto eth0
iface eth0 inet static
address 192.168.13.13
netmask 255.255.255.0
#gateway 192.168.1.1  Comment out this line to prevent errors.   Posted to ubuntuforums.
#***********************END OF FILE*********************

Then reboot your system and from a terminal issue the ifconfig command:

ifconfig working 20160321

This shows that I have:
eth0 static IP for Camera network:  192.168.13.13
eth1 DHCP IP:  192.168.0.113

I wasn’t able to get the networking setup without some consternation!  I originally had this error when booting:
Waiting for Network Configuration…
Waiting up to 60 Seconds for network configuration…

I was able to solve that by commenting out the Gateway line in the interfaces file listed above.  To help troubleshoot network issues, here are some linux commands/notes made on my journey.  Maybe they’ll be of help.

Camera Setup

Refer to your manual on setting up your camera(s).  When I get a new camera, I’ll do a write-up on setup, but quite frankly, I forgot what I did other than to setup the IP Addresses and change the passwords.  Here are the cameras I’m using along with some basic information about them:

#1  Bullet Camera DS-2CD2032F-IW:
Camera IP: 192.168.13.1
Port:  8000
SubNet Mask: 255.255.255.0
(IPv4) GateWay: 192.168.13.255
IPv6 Address:  ::
IPv6 Gateway:  ::
IPv6 Prefix Length:  64
HTTP Port:  80
Device Serial No:  DS-2CD2032F-A BUNCH MORE NUMBERS
Preferred DNS Server:  8.8.8.8
#2  Dome Camera DS-2CD3145F-IS
Camera IP: 192.168.13.2
Port:  8000
SubNet Mask: 255.255.255.0
(IPv4) GateWay: 192.168.13.255
IPv6 Address:  ::
IPv6 Gateway:  ::
IPv6 Prefix Length:  0
HTTP Port:  80
Device Serial No:  DS-2CD3145F-IS2015+ BUNCH MORE NUMBERS
Preferred DNS Server:  8.8.8.8

ZONEMINDER Install

Finally, time to install Zoneminder.  We want to use the Easy Way to Install Zoneminder (Ubuntu 14.X) from the Zoneminder Installation Guide.  Expert users may not find my step-by-step write-up below useful, but for novices like me, it may be helpful.

Open a terminal in Xubuntu and enter the commands.

Step 1:  Install Zoneminder

1
2
3
4
TERMINAL Line Commands
sudo  add-apt-repository ppa:iconnor/zoneminder
sudo apt-get update
sudo apt-get install zoneminder
TERMINAL Line Commands
sudo  add-apt-repository ppa:iconnor/zoneminder
sudo apt-get update
sudo apt-get install zoneminder

The installation installs MySQL and you are requested to enter a MySQL admin “root” user Password.  The instructions say to click “OK”, but I entered a password.  I needed the password in the next step.  Also, the configuration of MySQL will configure nullmailer which is the mailname of your system (from MySQL).  I wrote that down next to the password, although I have not had any reason to use it.  Here are screen shots I took of the MySQL setup:

zminstall MySQL root psswd requestzminstall MSQL nullmailer 1 zminstall MySQL nullmailer

Step 2:  Set up DB

1
2
3
TERMINAL Line Commands
sudo mysql -uroot -p < /usr/share/zoneminder/db/zm_create.sql
mysql -uroot -p -e "grant select,insert,update,delete,create,alter,index,lock tables on zm.* to 'zmuser'@localhost identified by 'zmpass';"
TERMINAL Line Commands
sudo mysql -uroot -p < /usr/share/zoneminder/db/zm_create.sql
mysql -uroot -p -e "grant select,insert,update,delete,create,alter,index,lock tables on zm.* to 'zmuser'@localhost identified by 'zmpass';"

For the 2nd command “mysql -uroot….” you will be prompted for a password, it is the MySQL Root password from the previous step and not the sudo password.

Step 3:  Set up Apache

1
2
3
4
Terminal Line Commands
sudo a2enconf zoneminder
sudo a2enmod rewrite
sudo a2enmod cgi
Terminal Line Commands
sudo a2enconf zoneminder
sudo a2enmod rewrite
sudo a2enmod cgi

When issuing the above terminal line commands, I received instructions to issue more commands.  On the 2nd command, I was asked to restart apache2 and I received few [FAIL]. I simply continued on with the instructions.  Also, I received a fail for the XXXXX command and again, continued on.  In a later step (step 7), you asked to restart apache2 and in that step it STARTS!  Below are the commands and my results for reference:

sudo a2enconf zoneminder
Terminal:  To activate the new configuration, you need to run:  service apache2 reload.  (So I ran it, no issues).

sudo a2enmod rewrite
Enabling module rewrite.
To activate the new configuration, you need to run the :  service apache2 restart
I issued the restart command and received:   * Restarting web server apache2                  [fail]

sudo a2enmod cgi  –>  Also, issued the ‘service apache2 restart’ and it also failed.   I moved on to the next step.

Step 4:  Some tweaks that will be needed:

I had to issue a sudo, where the web instructions didn’t include the sudo.  Also, I use gedit and not edit, so the command is:

1
sudo gedit /etc/init.d/zoneminder
sudo gedit /etc/init.d/zoneminder

Per instructions, I did this:  Add a sleep 10 right after line 25 that reads echo -n “Starting $prog:” (The reason we need this sleep is to make sure ZM starts after mysqld starts)

I also enetered the next command with these instructions/note:  As of Oct 3 2015, zm.conf is not readable by ZM. This is likely a bug and will go away in the next package

1
sudo chown www-data:www-data /etc/zm/zm.conf
sudo chown www-data:www-data /etc/zm/zm.conf

Step 5:  If you have changed your DB login/password

Part 1.  I did not change my MySQL DB password ‘after’ installing Zoneminder so I skipped the first part of this step which talks about manually editing your password for the database.   I would guess that if you did not enter a password for MySQL root, you also skip the first part of this step.

Part 2:  To install php5-gd (as of 1.28.107, this is not installed).

1
sudo apt-get install php5-gd
sudo apt-get install php5-gd

Step 6:  Edit Timezone in PHP

I used gedit and not vi to edit the php.ini file and update the date.timezone.  Also, my time zone was Los_Angeles as shown below.  The instructions from Zoneminder are:

vi /etc/php5/apache2/php.ini Look for [Date] and inside it you will see a date.timezone that is commented. remove the comment and specific your timezone. Please make sure the timezone is valid (see [this](http://php.net/manual/en/timezones.php))

sudo gedit /etc/php5/apache2/php.ini
date.timezone = America/Los_Angeles

Step 7:  Make sure live streaming works.

Part 1.  Ok – I did NOT do this Part 1. because of the note “(you should not need to do this for packages, as this should automatically work)”.    I assume I installed packages.  The instructions ask you to edit the PATH_ZMS in the ZM Console (Options->Path) and set to /zm/cgi-bin/nph-zms.

Part 2.  Restart (apache2 service – finally).  I DID this and it Worked!!

1
2
3
4
5
6
7
8
sudo service apache2 restart
sudo /etc/init.d/zoneminder restart
*NOTE:  Needed sudo for zoneminder restart above, which is not highlighted in install instructions.
RESULTS FROM RESTART ABOVE
seccam@seccam-hp-dc7800p:~$ sudo service apache2 restart
* Restarting web server apache2  
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                           [ OK ]
sudo service apache2 restart
sudo /etc/init.d/zoneminder restart
*NOTE:  Needed sudo for zoneminder restart above, which is not highlighted in install instructions.
RESULTS FROM RESTART ABOVE
seccam@seccam-hp-dc7800p:~$ sudo service apache2 restart
* Restarting web server apache2  
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                           [ OK ]

I’m not sure if the above is okay or not, but I continued on.

Step 8:  Making sure ZM and APIs work:  (optional – only if you need APIs)

This Step 8 appears to be 3 INDEPENDENT steps in 1.  I broke the steps into Part 1, Part 2, and Part 3.   Parts 2 and 3 are really checking that your system works and should be

Part 1:  Make sure APIs work:  I followed the instructions for checking the APIs and they worked!!  I did Step 8, Part 1 for two reasons.
1.  One to see if my install worked well up to this point.
2.  I might add some X10 devices someday and X10 requires the APIs to work.

Here are the instructions for Step 8, Part 1 from Zoneminder:

  1. Open up a browser and go to http://localhost/zm – should bring up ZM
  2. (OPTIONAL – just for peace of mind) open up a tab and go to http://localhost/zm/api – should bring up a screen showing CakePHP version with some green color boxes (ADD SCREEN SHOT LINK HERE). Green is good. If you see red, or you don’t see green, there may be a problem (should not happen). Ignore any warnings in yellow saying “DebugKit” not installed. You don’t need it
  3. Open up a tab in the same browser and go to http://localhost/zm/api/host/getVersion.json

If it responds with something like:

1
2
3
4
{
 "version": "1.28.107",
 "apiversion": "1.28.107.1"
}
{
 "version": "1.28.107",
 "apiversion": "1.28.107.1"
}

Then, your APIs are working!

Part 2:  Make sure you can view Monitor View:
1.  Open up ZM, configure your monitors and verify you can view Monitor feeds.  (NOTE – THIS IS WHERE I AM, DOCUMENT THAT SETUP WITH LINK TO BELOW)
2. If not, open up ZM console in your browser, go to Options->Path and make sure PATH_ZMS is set to /zm/cgi-bin/nph-zms and restart ZM (you should not need to do this for packages, as this should automatically work)

Part 3:  Make sure ZM and APIs work with Security    (NOTE  – NEED TO DO THIS)
1. Enable OPT_AUTH in ZM
2. Log out of ZM in browser
3. Open a NEW tab in the SAME BROWSER (important) and go to http://localhost/zm/api/host/getVersion.json – should give you “Unauthorized” along with a lot more of text
4. Go to another tab in the SAME BROWSER (important) and log into ZM
5. Repeat step 3 and it should give you the ZM and API version

Congrats – Your installation is complete

The installation of Zoneminder is complete, but setup is not…  Continue on to Configuring Zoneminder!

CONFIGURING ZONEMINDER

Configure instructions continued here…   Work in progress!!

 

Leave a Reply

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code lang=""> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <pre lang="" extra="">