How to install ZoneMinder 1.24.2 on Ubuntu 10.04 LTS Server

May 23, 2010 7:18 am    Posted by Viktor Petersson    Comments (80)

Last week I published a new version of my ZoneMinder Virtual Appliance. The virtual appliance is great if you want to easily deploy ZoneMinder without having to spend time setting it up. However, in some situations, you want to run ZoneMinder directly on the hardware. Perhaps you need better performance or simply need to capture video streams from V4L-devices.

Since I already spent the time getting it running, I thought I’d share the instructions for getting it running. It’s pretty straight forward, but there are a few minor things that took me some time to get around.

Installation

Optional: I personally prefer to install the ‘minimal’ version of Ubuntu. You can install this mode by simply hitting F4 right at boot.

Other than the installing the ‘minimal’ system, the only things you would need to keep in mind are to install “LAMP” and “OpenSSH” under the Software selection. You will also need to pick a MySQL password, which will be used later.

Configuration

Upgrade the package repository:

sudo apt-get update && sudo apt-get upgrade

Install all required dependencies:

sudo apt-get install build-essential ffmpeg libmysqlclient-dev libjpeg-dev libssl-dev libdate-manip-perl wget liblwp-useragent-determined-perl libavformat-dev libphp-serialization-perl libswscale-dev joe

Get Zoneminder:

wget http://www.zoneminder.com/downloads/ZoneMinder-1.24.2.tar.gz

Extract Zoneminder and change permission:

sudo tar xvfz ZoneMinder-1.24.2.tar.gz -C /usr/local/
sudo chown -R $(whoami) /usr/local/ZoneMinder-1.24.2

Configure Zoneminder:

cd /usr/local/ZoneMinder-1.24.2
./configure --with-webdir=/var/www/zm --with-cgidir=/usr/lib/cgi-bin/ --with-webuser=www-data --with-webgroup=www-data ZM_DB_USER=zm ZM_DB_NAME=zm ZM_DB_PASS=yourpassword ZM_SSL_LIB=openssl

Resolve a bug (discussed more here):

joe src/zm_utils.cpp

(or your favorite editor)
Add the line ‘#include ‘ on row 22 (or somewhere in that general area). To exit and save with Joe, press ctrl+k x.

Build and install Zoneminder

make
sudo make install

Configure the database:

mysql -uroot -p < db/zm_create.sql
echo "GRANT ALL PRIVILEGES ON zm.* TO 'zm'@'localhost' IDENTIFIED BY 'yourpassword'; FLUSH PRIVILEGES;" | mysql -uroot -p

Install Cambozola:

cd
wget http://www.charliemouse.com:8080/code/cambozola/cambozola-latest.tar.gz 
tar xvfz cambozola-latest.tar.gz 
sudo cp cambozola-*/dist/cambozola.jar /var/www/zm/

Make Zoneminder the root-page in Apache:

sudo joe /etc/apache2/sites-enabled/000-default

Change “DocumentRoot /var/www” to “DocumentRoot /var/www/zm” and “Directory /var/www/” to “Directory /var/www/zm/”

Restart Apache:

sudo /etc/init.d/apache2 restart

Change some system parameters:

sudo sysctl kernel.shmall=134217728
sudo sysctl kernel.shmmax=134217728

Make the system parameters permanent:

sudo joe /etc/sysctl.conf

Add the following lines at the end:

kernel.shmall=134217728
kernel.shmmax=134217728

Install the startup-script (from the official site):

sudo wget http://viktorpetersson.com/upload/zm -O /etc/init.d/zm
sudo chmod +x /etc/init.d/zm
sudo update-rc.d zm defaults
sudo /etc/init.d/zm start

That’s it. You should now have a fully working version of ZoneMinder. All you need to do now is to point your browser to the IP address of the server.

Update: Thanks to Peter for pointing out that that there is a newer version of Cambozola. The guide has been updated to reflect this.

  • Dave

    SELECT command denied to user 'zmuser'@'localhost' for table 'Config' I finnaly got a log In screen after a dozen tries. I'm using ubuntu 10.04 with a WinTv all in wonder pvr 250 card. I was able to get it working in windows, but in linux… I'm now getting the above error. Your help would be great.

  • Boga

    Its is stupid tutorial. Make it work on your pc first and then suggest people.

  • Saint

    @”resolve a bug” you should use html code for < < and > > or the browser will read it as a html tag

  • Saint

    @”resolve a bug” you should use html code for < < and > > or the browser will read it as a html tag

  • Anonymous

    Well, obviously I did get it to work using these exact instructions, otherwise I wouldn’t have been able to produce the virtual appliance referred to in the opening of the article.

    • SpeedKreature

      I’m having this issue as well. Is the password for “zm” configured at…

      cd /usr/local/ZoneMinder-1.24.2
      ./configure –with-webdir=/var/www/zm –with-cgidir=/usr/lib/cgi-bin/ –with-webuser=www-data –with-webgroup=www-data ZM_DB_USER=zm ZM_DB_NAME=zm ZM_DB_PASS=yourpassword ZM_SSL_LIB=openssl

      Where “yourpassword” is replaced by the password one wishes to use?

      • SpeedKreature

        sorry…posted in the wrong place…meant to post under the DB error “vpetersson” posted a few comments above.

      • Anonymous

        Yes, ‘yourpassword’ is the password you wish to use. Please note that it must be the same as the password you set in MySQL, otherwise it won’t work.

  • Tavo Tell

    I have a problem…

    root@Server:~/Descargas# sudo /etc/init.d/zm start
    Starting ZoneMinder: DBI connect(‘database=zm;host=localhost’,'zm’,…) failed: Access denied for user ‘zm’@'localhost’ (using password: YES) at /usr/local/share/perl/5.10.1/ZoneMinder/Config.pm line 89
    Can’t call method “prepare_cached” on an undefined value at /usr/local/share/perl/5.10.1/ZoneMinder/Config.pm line 91.
    BEGIN failed–compilation aborted at /usr/local/share/perl/5.10.1/ZoneMinder/Config.pm line 100.
    Compilation failed in require at /usr/local/share/perl/5.10.1/ZoneMinder.pm line 33.
    BEGIN failed–compilation aborted at /usr/local/share/perl/5.10.1/ZoneMinder.pm line 33.
    Compilation failed in require at /usr/local/bin/zmpkg.pl line 46.
    BEGIN failed–compilation aborted at /usr/local/bin/zmpkg.pl line 46.
    failure

  • Anonymous

    Sounds like you’re having problem with the database access. Try connecting to the database by hand with:
    “mysql -uzm -p zm”
    When prompted, enter the database password for the Zoneminder user under “Configure the database.”

    If you’re able to connect, go back to the “Configure Zoneminder” and make sure the password in the line is the same as you entered above.

  • Spy

    Hi,
    I got it working with the instructions above. thanks!!
    As mentioned, you have to be careful with password sections and those should set correctly then it is working.

  • Bob

    I assime for this to work it has to be Ubuntu 10.04 LTS _SERVER_?

    • Viktor Petersson

      I set it up on the server version, but they’re fairly similar, so I would imagine it would work on the Desktop and Alternative version too.

    • Anonymous

      No, it probably works with 10.04 LTS Desktop too, but I simply prefer not to have X11-bloat on my servers =).

  • nausser

    when you say add the line ‘#include’, what exactly am I changing? There are two lines there that are commented out:
    #include “zm_utils.h”

    #include

    Do I uncomment one or both of the lines? Do I add ‘#include’ to line 22 which is directly in between the two?
    Sorry about the simple question. Its just not clear to me for some reason.

    Thanks for the instructions though!

    • Anonymous

      It looks like the template cut out that some of the data, it should read:#include

      Ignore this–>

  • Victor Mangraviti

    man… you are a fucking star. Sorry for the bad language but I couldn’t find a better word to describe how much you’ve helped me… Thanks a bunch!

  • Abc

    you have busted my whole server …. please better delete this page so that ppl may not be misguided

    • Anonymous

      So it worked for me and numerous other people, but not for you. Then it *must* be something wrong with the guide.

  • mike

    Thanks for the walkthough, but it seems I have mashed something.

    I get to the “make” stage and then get:

    root@gonkbox:/usr/local/ZoneMinder-1.24.2# make
    make: *** No targets specified and no makefile found. Stop.

    Any suggestions would be appreciated :)

    • Anonymous

      The extraction of the tarball must have failed. There should be a file called ‘Makefile’ in that directory. Try wiping the entire folder /usr/local/ZoneMinder-1.24.2, download the tar-ball again and extract it.

      • russ

        viktor

        i had the same problem–no makefile after the make command. i found that my configuration had an error in it. the openssl was OPENSSL and caused the failure. The makefile is generated with a good configuration. after i corrected this the makefile worked.
        i’m learning
        russ

        • Gsilver352

          How do I view the configuration file in a text editor to see if it changed my openssl to OPENSSL

      • Gsilver352

        Found info later in posts…I opened the configure file using Joe. Searched for “OPENSSL”, and there was only one instance of it #define HAVE_LIB_GNUTLS_OPENSSL 1. I have Makefile.am and Makefile.in in the Zoneminder folder, make still does nothing for me.

  • Dennis

    Wow – I struggled like you can’t believe until I found this tutorial. Thanks a million!

  • Topchienko Peter

    Thanks a lot, it works!
    Works with some changes:
    - do not change DocumentRoot and Directory in apache configuration
    - “Add the line ‘#include ‘ on row 22″ – is mean “Add the line ‘#include ‘ on row 22″
    That’s all.
    P.S. sorry for my english, best regards.

    • Anonymous

      Thanks Peter. I’ve updated the guide.

  • Topchienko Peter

    And “sudo cp cambozola-0.76/dist/cambozola.jar /var/www/zm/” must typed as “sudo cp cambozola-0.80/dist/cambozola.jar /var/www/zm/”. There is a new version.

    • Anonymous

      Thanks. The guide is updated to reflect this change.

  • Frustrated

    Wow. This seems impossibly difficult. I have to fix a bug and recompile it? I have not done any programming for 30 years.

    • Viktor Petersson

      First, I wouldn’t call changing one line in one text-file programming. Second, if you find that so difficult, you’re always welcome to go for a commercial solution and spend a few thousand dollars. It’s your call. Nobody’s forcing you.

    • Anonymous

      First, I wouldn’t call changing one line in a text-file programming (with very clear instructions) and second, if you don’t like it, you’re always welcome to spend a few grand on a commercial solution.

      It’s your call. Nobody is forcing you.

  • Needrays

    ./configure –with-webdir=/var/www/zm –with-cgidir=/usr/lib/cgi-bin/ –with-webuser=www-data –with-webgroup=www-data ZM_DB_USER=zm ZM_DB_NAME=zm ZM_DB_PASS=Swingline65 ZM_SSL_LIB=openssl

  • russ

    hi Viktor

    I am new to ubuntu and zoneminder and was excited to find your how-to. I have been trying for weeks to get the software installed and working. I ran into the first problem at extracting zoneminder and changing permissions. The error message states you cannot specify more than one Acdtrux option. I’m sure it worked for you and others so why do i and others have this problem? Can you help me rework the command so that it works on my machine?
    Also— the password used in configuration of zoneminder and the sql database is confusing. Could you be very specific?

    thanks
    russ

    • Anonymous

      Hey Russ,

      Sorry, but I don’t have the bandwidth for that. If you’re Linux/Ubuntu, I suggest you pick up some getting-started book.

      • russ

        No viktor–i don’t expect you to connect to my machine–but can the line
        sudo tar xvfz Zoneminder-1.24.tar.gz -C/usr/local
        be rewritten so as not to get the error?
        I was wondering if you developed this procedure on a 64 bit machine and it is choking on my 32 bit machine?
        russ

        • Anonymous

          (I was referring to bandwidth in the sense of time, not speed of the connection btw =)

          32bit vs. 64bit shouldn’t matter, but I can see the error. You missed a space between the ‘C’ and the slash. It should be:
          sudo tar xvfz Zoneminder-1.24.tar.gz -C /usr/local/

          • russ

            Thanks Viktor, you were right on with the solution to my problem–thank you. The software loaded but i was a little confused about the passwords. Can you help me one more time?

            If i’m the only one on my machine and i install the software as user ‘russ’ and the password is
            ‘easyone’ and during installation i’m asked to input a password for mysql database–i input
            ‘hardone’; what password should i input to configure Zoneminder and what password should i use in configuring the database?

            i’m sure all will work if this is cleared up.
            Thanks so much for your excellent work.

          • russ

            thanks viktor–i can see that i need to do some reading about zoneminder database.
            if you can point me to some reading mat’l that would help, i would appreciate it.

            thanks again

          • Anonymous

            It’s a regular MySQL database. You can find a ton of tutorials around the web. You might also want to take a look at the official documentation: http://dev.mysql.com/doc/refman/5.0/en/index.html

  • yzcrakker

    Viktor, Thank you – I have been tearing my hair out with this thing, you are sensible and straight forward.

  • sean

    I keep getting the following error after running this command:

    ~$ sudo cp cambozola-*/dist/cambozola.jar /var/www/zm/

    Error:

    cp: cannot create regular file `/var/www/zm/’: Is a directory

    • Anonymous

      The command you wrote looks right to me. You must have done something wrong at an earlier point in the guide or perhaps copied down the command or error wrong.

  • boggsman

    I messed up the first time through… but I went back a second time and checked everything. Works like a charm. Thank you!

  • adam

    Thank you Viktor!

    I used your guide today and it worked great!!!

    One small thing – in the “Configure Zoneminder” step the dashes before each variable like ‘–with-webdir’ should be hyphens (the shorter line). It was telling me that they were invalid variable names before I changed the dashes to hyphens.

  • Gsilver352

    (whoami) is my user name right?

    • Anonymous

      no. the command $(whoami) executes the command ‘whoami’, which in turn returns your username.

  • Gsilver352

    I keep seeing all the comments about the guide being updated…but I see no changes here on the website, is there another link im not seeing?

    • Anonymous

      The updates have been updated in the original post.

  • Gsilver352

    “One small thing – in the “Configure Zoneminder” step the dashes before each variable like ‘–with-webdir’ should be hyphens (the shorter line). It was telling me that they were invalid variable names before I changed the dashes to hyphens. ” is this information accurate? —fyi much appreciated for the guide.

    • Anonymous

      I think my WordPress theme rewrote them. It should be ./configure –foo-bar (ie, two single-hyphens first and then one hyphen between words).

  • Gsilver352

    After I exited Joe, What is my target to make? it’s asking me.

  • stickyc

    As an FYI – There is a package for Zoneminder. If you install it, zoneminder goes under /usr/share/zoneminder. This affects the destination of your copy statement for camboozle:
    sudo cp cambozola-*/dist/cambozola.jar /usr/share/zoneminder
    I found I was able to get away with just going the apt-get install zoneminder, the manual camboozle steps, and the kernel memory changes to get a working (so far) zoneminder install on a LAMP-based Ubuntu 10.04 LTS setup.

    • michael paterson

      Hi Stickyc I have been using Zoneminder for a while now and upgraded to zoneminder 1.24.2 using the apt get install and editing shmmax shmall, etc. I have reinstalled several times and kept finding that it broke after a few a hours. Each time I seem to lost the live camera feeds. From what I have learnt there have been errors in the build and after chasing forums, etc building it from source should produce less errors. If you have better luck can you let me know?([email protected]).

  • Michael Paterson

    Hi Viktor, firstly thanks for the time you have spent on creating this guide. It was all going good for me until I did the following ;
    ./configure –with-webdir=/var/www/zm –with-cgidir=/usr/lib/cgi-bin/ –with-webuser=www-data –with-webgroup=www-data ZM_DB_USER=zm ZM_DB_NAME=zm ZM_DB_PASS=mick1234 ZM_SSL_LIB=openssl

    i ended up with this error ; configure: error: zm requires DBI
    It’s probably something simple can you point me in the right direction?
    Many thanx in advance

    Michael Paterson

    • Anonymous

      If I recall correctly, ZoneMinder is written in Perl to some extent, so I suppose the DBI error is referring to the lack of Perl::DBI. If so, you can install it by running:

      perl -MCPAN -e shell
      cpan> install DBI

      • Michael Paterson

        Thanks I will give it a shot tonight.

  • ClassicUser

    Viktor you are the master, the Jedi! jaja, really very good job. I’m from argentina, sorry for my english…only one question if you know why can’t create a video file.the ffmpeg.log say:sh /usr/local/bin/ffmpeg:not found. thanks for your how to, from argentine!

    • Viktor Petersson

      Judging from the error, it sounds like you forgot to install ffmpeg.

  • gregom

    Thanks for your guide, it wen’t pretty smoothly. I installed over a month ago and had one or two small issues but I can’t recall what they were.

    Anyway, is there a way to test or confirm MPEG is setup correctly? This is the first time I’m trying to get MPEG cameras working with ZM and i’m not doing well. I’m not sure if it is my configurations I am attempting or if MPEG does not work in my ZM.

    Any ideas?

  • Ns

    I am getting the following errors after the make command, i have tried all the solutions discussed below:

    make: ***no rule to make target ‘sudo’. stop.

    • Anonymous

      It looks like you wrote ‘make sudo’ instead of ‘sudo make.’

      • Nik

        it works. Thanks!

  • Timposey1962

    I followed letter for letter, it did not work!

  • Lisandromassera

    Hi! Tried to install today and had some trouble when trying to build and install ZM. Something about UINT64-C not being defined in ffmpeg. Did a google search and found that here(http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/2010-May/088074.html) is the solution. It worked perfectly.

    • Ephestione

      As a matter of fact, translating what you read there, all you need to od is to add those lines at the beginning of the common.h file

      Following this tutorial:
      sudo gedit /usr/include/libavutil/common.h

      Add lines at the beginning of file:
      #ifdef __cplusplus
      #define __STDC_CONSTANT_MACROS
      #ifdef _STDINT_H
      #undef _STDINT_H
      #endif
      # include
      #endif

      Also as other user pointed out months ago, the “#include” patch is missing the parameter, stupid wordpress also messed up the hyphens again.

  • Jonmgreg

    I’m totally new to ubuntu and linux in general. I’ve tried this step for step and get an error message at the end…

    Starting ZoneMinder: /etc/init.d/zm: 60: /usr/local/bin/zmpkg.pl: not found
    failure

    Now what have I screwed up? Help.

  • Wayneirw1

    under configure zoneminder should be _ minus sigh in front of (with) . also had a requires dbi error

  • iago

    Hi, I’m trying to makes it work, but i always got the same error, /var/lock/zm doesn’t exist

    why i got this??

  • Blaise

    When I run zmpkg.pl start I get the following:

     DBI connect(‘database=zm;host=localhost’,'zminder’,…) failed: Can’t connect to local MySQL server through socket ‘/var/run/mysqld/mysqld.sock’ (2) at /usr/local/share/perl/5.10.1/ZoneMinder/Config.pm line 89
    Can’t call method “prepare_cached” on an undefined value at /usr/local/share/perl/5.10.1/ZoneMinder/Config.pm line 91.
    BEGIN failed–compilation aborted at /usr/local/share/perl/5.10.1/ZoneMinder/Config.pm line 100.
    Compilation failed in require at /usr/local/share/perl/5.10.1/ZoneMinder.pm line 33.
    BEGIN failed–compilation aborted at /usr/local/share/perl/5.10.1/ZoneMinder.pm line 33.
    Compilation failed in require at ./bin/zmpkg.pl line 46.
    BEGIN failed–compilation aborted at ./bin/zmpkg.pl line 46.

    I can connect to MySQL normally though. Any idea how to solve this?

    • Anonymous

      Right, but are you able to connect using the socket?

      To try the following: “mysql –user=zminder –host=localhost zm”
      (that’s basically wht zmpkg.pl is doing.)

  • http://profiles.google.com/radio.w7jhb James Brown

    I found a simpler solution under Ubuntu 10.04 LTS (Lucid) that does not require recompiling, etc. What I did was basically disable the update script where it tries to update the zoneminder database to the latest version. Since the create sql file that ships w/ zoneminder already has all the updates for 1.24.2 installed there is no reason to do the updates (and they fail).

    Here’s what I did …

    1. sudo apt-get install zoneminder
    (yes, this fails w/ an error about database ‘zm’ not existing)

    2. launch phpMyAdmin from the browser

    2.1. create database ‘zm’

    2.2. create a new user named ‘zmuser’ with password ‘zmpass’ and give it all rights to ‘zm.*’

    3. at the command line do the following:

    3.1 mysql -uzmuser -pzmpass zm disconnect();
    die( “Can’t find upgrade from version ‘$version’” );
    }
    } ### you added this line
    print( “nDatabase upgrade to version “.ZM_VERSION.” successful.n” );
    }

    3.2.6 now press Ctrl-X to exit and tell nano to save the file (hit ‘Y’ and return)

    4 sudo apt-get install zoneminder

    The second install should work correctly with no errors. That’s it, zoneminder should now be installed and working.

  • Jack Jenkins

    Hello:  The above instructions worked for me with 1.24.2 and  10.04 LTS.

    I am working with the same instructions trying to install 1.24.4 and 10.04.2 LTS.  Everything progresses nicely until I try to make then:  ***No targets specified and no makefile found message is returned.

    Makefile.am and Makefile.in are present in /usr/local/ZoneMinder-1.24.4

    Any thoughts?

    Thanks,Jack

  • Pingback: squishydale.hypernexus.net » Zoneminder Security Server

  • EMF

    The parameter kernel.shmall is measured in pages, not in bytes, so based on a 4096-byte PAGE_SIZE (getconf PAGE_SIZE), shouldn’t it be kernel.shmall=32768 to go with the kernel.shmmax=134217728?

  • EMF

    And if you’re using a USB webcam that has cropping issues, you can patch the source before the ./configure line above.  Look at  http://www.zoneminder.com/forums/viewtopic.php?p=59472#59472 for more details.

  • Labo Ts

    ESXI??
    I downloaded and unzipped the files of the VA. transferred to the datastore, then added to the inventory.
    This creates the virtual machine will not start.

    • Viktor Petersson

      Dig into the log-files then. I’ve never tried this on ESXi myself.

  • Rob

    I am working with the same instructions trying to install 1.24.4 and
    10.04.2 LTS.  Everything progresses nicely until I try to make then:
     ***No targets specified and no makefile found message is returned.

  • Henryjia18

     it says no makefile