newspaint

Documenting Problems That Were Difficult To Find The Answer To

Compiling/Installing ZoneMinder on Ubuntu Trusty 14.04 From Source

Download ZoneMinder

Download from http://www.zoneminder.com/downloads.

sudo apt-get install wget
wget 'https://github.com/ZoneMinder/ZoneMinder/archive/v1.28.1.tar.gz'
tar -xvzf v1.28.1.tar.gz

Build

Find required packages at http://packages.ubuntu.com/.

sudo apt-get install autoconf automake
sudo apt-get install libmariadbclient-dev
sudo apt-get install libpolkit-gobject-1-0 libpolkit-gobject-1-dev
sudo apt-get install g++
sudo apt-get install libjpeg62 libjpeg62-dev
sudo apt-get install libgnutls-dev
sudo apt-get install libdbi-perl libdbd-mysql-perl libdate-manip-perl libwww-perl libsys-mmap-perl
sudo apt-get install libavutil-dev libavcodec-dev libavformat-dev libavdevice-dev
sudo apt-get install libswscale-dev libbz2-dev libx264-dev
sudo apt-get install netpbm libvlc-dev
sudo apt-get install libarchive-zip-perl libmime-lite-perl

Then configure.

./bootstrap.sh
./configure --with-webdir=/opt/zm/web/zm --with-cgidir=/opt/zm/web/cgi --with-webuser=www-data --with-webgroup=www-data --prefix=/opt/zm --with-libarch=lib

Next make.

sudo apt-get install make
nice make -j 2

Was receiving the build error:

./configure: line 3430: syntax error near unexpected token `POLKIT,'
./configure: line 3430: `PKG_CHECK_MODULES(POLKIT, polkit-gobject-1)'

Solution was to sudo apt-get install libpolkit-gobject-1-0 libpolkit-gobject-1-dev and ./bootstrap.sh again.

Install.

sudo make install
sudo mkdir /opt/zm/share/perl
sudo ln -s '/opt/zm/share/perl5/' '/opt/zm/share/perl/5.18.2'

Then set up database.

sudo apt-get install mariadb-client mariadb-server
echo "create database zm" |mysql -u root -p

Add to my.cnf as per this MySQL webpage and this MariaDB webpage:

[mysqld]
innodb_file_per_table=1
innodb_file_format=Barracuda

Then:

mysql -u root -p zm < /opt/zm/share/zoneminder/db/zm_create.sql
echo "grant select,insert,update,delete,lock tables,alter on zm.* to 'zmuser'@localhost identified by 'zmpass'" |mysql -u root -p

Now we need a lock directory:

sudo mkdir /var/lock/subsys

Then we need an init script:

Create /etc/init.d/zm from this ZoneMinder webpage.

Apache

sudo apt-get install apache2-mpm-worker

And, as recommended by this forum post for PHP5 CGI:

sudo apt-get install libapache2-mod-fcgid
sudo apt-get install php5-cgi php5-cli php5-mysqlnd

Enable SSL and CGI modules:

sudo mkdir /etc/apache2/ssl
a2enmod ssl
a2enmod cgi
sudo mkdir /var/log/apache2/zm/

And for basic authentication (to run htpasswd in Ubuntu) you need to:

sudo apt-get install apache2-utils # for htpasswd

A configuration that can be placed in /etc/apache2/sites-available is:

<IfModule mod_ssl.c>
  <VirtualHost _default_:443>
    ServerAdmin webmaster@localhost

    DocumentRoot /opt/zm/web/zm

    ErrorLog /var/log/apache2/zm/error.log
    CustomLog /var/log/apache2/zm/access.log combined

    #   SSL Engine Switch:
    #   Enable/Disable SSL for this virtual host.
    SSLEngine on

    # You're going to have to create your own PEM file
    SSLCertificateFile /etc/apache2/ssl/apache.pem
    <FilesMatch "\.(cgi|shtml|phtml|php)$">
      SSLOptions +StdEnvVars
    </FilesMatch>
    <Directory /opt/zm/web/cgi>
      SSLOptions +StdEnvVars
    </Directory>

    BrowserMatch "MSIE [2-6]" \
      nokeepalive ssl-unclean-shutdown \
      downgrade-1.0 force-response-1.0 
    BrowserMatch "MSIE [17-9]" ssl-unclean-shutdown

    <Directory /opt/zm/web/zm>
      <IfModule mod_authz_core.c>
        # Apache 2.4
        Require all granted
      </IfModule>
      <IfModule !mod_authz_core.c>
        # Apache 2.2
        Order deny,allow
        Allow from all
      </IfModule>

      AddHandler fcgid-script .php
      FCGIWrapper /usr/lib/cgi-bin/php5 .php
      Options +ExecCGI +Indexes

      AllowOverride All
    </Directory>

    ScriptAlias /cgi-bin/ /opt/zm/web/cgi/
    <Directory /opt/zm/web/cgi>
      Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
      AllowOverride All
      <IfModule mod_authz_core.c>
        # Apache 2.4
        Require all granted
      </IfModule>
      <IfModule !mod_authz_core.c>
        # Apache 2.2
        Order deny,allow
        Allow from all
      </IfModule>

      <FilesMatch "(nph-zms|zms)">
        SetHandler cgi-script
        SSLOptions +StdEnvVars
       </FilesMatch>
    </Directory>

    <Directory />
      <IfModule mod_authz_core.c>
        # Apache 2.4
        Require all denied
      </IfModule>
      <IfModule !mod_authz_core.c>
        # Apache 2.2
        Order deny,allow
        Deny from all
      </IfModule>
    </Directory>
  </VirtualHost>
</IfModule>

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: