Installing Zoneminder on Ubuntu 9.04 32bit & 10.04 32bit - The open source surveillance system

Saturday, May 1, 2010
Yes... you may have heard the Linux is going into CCTV world! On this tutorial we are going to
install zoneminder on Ubuntu 9.04 32bit.
Note that this walkthrough is taken from http://www.zoneminder.com/wiki/index.php/Ubuntu_9.04_server_32bit with some modification due to update to ffmpeg module.
This also a solution to ffmpeg error on compiling zoneminder.We assume here you guys already installed the Ubuntu Server with LAMP and the SSH server if you guys want to do remote SSH,and change the IP of your server to static IP.

- Do the "apt-get update" and then "apt-get upgrade" to update your distribution to the latest
one.

- After that install webmin (optional), install sysvconfig: "apt-get install sysvconfig", enter; now
run it: "sysvconfig", enter , now choose "enable/disable", also
ensure webmin is checked if you want it; back to the main screen, hit "finished" to save; exit it;

- Ensure you had your capture card recognized, in my case i'm using Kodicom 8800 DVR card.
root@myhomeCCTV:/home/myhome# find /dev -name video*
/dev/video1
/dev/video7
/dev/video6
/dev/video5
/dev/video4
/dev/video3
/dev/video2
/dev/video0
/dev/.udev/names/video1
/dev/.udev/names/video7
/dev/.udev/names/video6
/dev/.udev/names/video5
/dev/.udev/names/video4
/dev/.udev/names/video3
/dev/.udev/names/video2
/dev/.udev/names/video0
root@myhomeCCTV:/home/myhome# lspci -v | grep Multimedia
04:08.0 Multimedia video controller: Brooktree Corporation Bt878 Video Capture (rev 11)
04:08.1 Multimedia controller: Brooktree Corporation Bt878 Audio Capture (rev 11)
04:09.0 Multimedia video controller: Brooktree Corporation Bt878 Video Capture (rev 11)
04:09.1 Multimedia controller: Brooktree Corporation Bt878 Audio Capture (rev 11)
04:0a.0 Multimedia video controller: Brooktree Corporation Bt878 Video Capture (rev 11)
04:0a.1 Multimedia controller: Brooktree Corporation Bt878 Audio Capture (rev 11)
04:0b.0 Multimedia video controller: Brooktree Corporation Bt878 Video Capture (rev 11)
04:0b.1 Multimedia controller: Brooktree Corporation Bt878 Audio Capture (rev 11)
04:0c.0 Multimedia video controller: Brooktree Corporation Bt878 Video Capture (rev 11)
04:0c.1 Multimedia controller: Brooktree Corporation Bt878 Audio Capture (rev 11)
04:0d.0 Multimedia video controller: Brooktree Corporation Bt878 Video Capture (rev 11)
04:0d.1 Multimedia controller: Brooktree Corporation Bt878 Audio Capture (rev 11)
04:0e.0 Multimedia video controller: Brooktree Corporation Bt878 Video Capture (rev 11)
04:0e.1 Multimedia controller: Brooktree Corporation Bt878 Audio Capture (rev 11)
04:0f.0 Multimedia video controller: Brooktree Corporation Bt878 Video Capture (rev 11)
04:0f.1 Multimedia controller: Brooktree Corporation Bt878 Audio Capture (rev 11)


ZM Installation :
echo "/usr/local/lib" > /etc/ld.so.conf.d/ffmpeg.conf

echo "LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH" >> /etc/bash.bashrc

echo "export LD_LIBRARY_PATH" >> /etc/bash.bashrc

ldconfig

aptitude install build-essential linux-headers-`uname -r` automake perl libnetssleay-perl openssl libauthen-pam-perl libpam-runtime libio-pty-perl libmd5-perl libmysqlclient15-dev libarchive-zip-perl libdate-manip-perl libdevice-serialport-perl libjpeg62 libjpeg62-dev libmime-perl libstdc++6 libwww-perl zlib1g zip unzip patch ntp openssl libpcre3-dev libssl-dev libjpeg-progs libcurl4-gnutls-dev munin munin-node libmime-lite-perl netpbm libbz2-dev subversion yasm


Install Perl Modules
type "perl -MCPAN -e shell", enter
(accept yes when prompted)
type "install CPAN", enter
(accept yes when prompted)
type "exit", enter
type "perl -MCPAN -e shell", enter
type "install YAML PHP::Serialization Module::Load X10::ActiveHome", enter
(accept yes when prompted,and yes again to fix dependencies problems if so)
type "exit", enter

FFmpeg & ZoneMinder from SVN
Install FFmpeg
cd /usr/src

svn checkout svn://svn.mplayerhq.hu/ffmpeg/trunk ffmpeg


cd ffmpeg

echo "Checked out external at revision 29318 - Checked out revision 18890" > xxx_SVN_info.txt

./configure --enable-gpl --enable-shared --enable-pthreads

make

make install

make install-libs

cd /lib

ln -s /usr/local/lib/libswscale.so.0
ln -s /usr/local/lib/libavformat.so.52
ln -s /usr/local/lib/libavcodec.so.52
ln -s /usr/local/lib/libavutil.so.50
ln -s /usr/local/lib/libavdevice.so.52

(all commands ran smooth, no broken symbolic links so far)

Install & Config ZoneMinder
cd /usr/src

svn co http://svn.zoneminder.com/svn/zm/trunk zm


cd zm

echo "Checked out revision 2887" > xxx_SVN_info.txt

./configure --with-webdir=/var/www/zm --with-cgidir=/usr/lib/cgi-bin --withffmpeg=/usr/src/ffmpeg CPPFLAGS="-D__STDC_CONSTANT_MACROS" ZM_DB_HOST=localhost ZM_DB_NAME=zm ZM_DB_USER=zmuser ZM_DB_PASS=zmpass --enable-debug=yes --withwebgroup=www-data --with-webuser=www-data


autoconf
(ok, outputs nothing here)

aclocal

automake

(now, the most important step, that takes about 3 minutes compiling)

make

(so far so good, lets now create the initial db; when prompted, use the **root
MySQL** password you created before;)

mysql -u root -p <> db/zm_create.sql

mysql -u root -p


grant select,insert,update,delete on zm.* to 'zmuser'@localhost identified by 'zmpass';

quit

make install


Post Install
Install Cambozola
cd /usr/src

wget http://www.charliemouse.com:8080/code/cambozola/cambozola-latest.tar.gz

tar -xzvf cambozola-latest.tar.gz

cp cambozola-0.70/dist/cambozola.jar /var/www/zm


Make sure ZoneMinder starts automatically
vim /etc/init.d/zm
#!/bin/sh
# description: Control ZoneMinder as a Service
# chkconfig: 2345 99 99
# Source function library.
#. /etc/rc.d/init.d/functions
prog=ZoneMinder
ZM_PATH_BIN="/usr/local/bin"
command="$ZM_PATH_BIN/zmpkg.pl"
start() {
echo -n "Starting $prog: "
$command start
RETVAL=$?
[ $RETVAL = 0 ] && echo success
[ $RETVAL != 0 ] && echo failure
return $RETVAL
}
stop() {
echo -n "Stopping $prog: "
$command stop
RETVAL=$?
[ $RETVAL = 0 ] && echo success
[ $RETVAL != 0 ] && echo failure
}
status() {
result=`$command status`
if [ "$result" = "running" ]; then
echo "ZoneMinder is running"
RETVAL=0
else
echo "ZoneMinder is stopped"
RETVAL=1
fi
}
case "$1" in
'start')
start
;;
'stop')
stop
;;
'restart')
stop
start
;;
'status')
status
;;
*)
echo "Usage: $0 { start | stop | restart | status }"
RETVAL=1
;;
esac
exit $RETVAL


Make /etc/init.d/zm executable:
chmod 755 /etc/init.d/zm

Make zm "automatic start on boot" -- Webmin -> System -> Bootup and Shutdown

Notes :
- There are some fix to also include support for Safari users or people surfing with the iPhone's built in Safari browser.Also, there is no need to do anything for Google chrome because its being detected as Mozilla\firefox.If you are using the JPEG streaming mode (Motion JPEG) with the browser Opera or Safari, or even using your iPhone, there is no reason to use cambozola because all those browsers support MJPEG natively.The problem: with ZM's CAN_STREAM setting set to "auto", ZM's auto detection believes those browsers don't support MJPEG, although they do.This is because ZM's auto detection is slightly outdated and this fix will update it.
You can do the changes manually or use the patch below.EDIT: If after this fix you experience flickering in Opera, here is how you fix it:
http://www.zoneminder.com/forums/viewtopic.php?p=61493
(or if you want the easiest way, you can download the
functions.php file from HERE, and overwrite the file function.php on /var/www/zm/includes/function.php)
- In file include/functions.php, change the following which is at around line 823 (May vary from installation to installation):
elseif (ereg( 'Opera ([0-9].[0-9]{1,2})',$_SERVER['HTTP_USER_AGENT'],$logVersion))
to
elseif (ereg( 'Opera/([0-9].[0-9]{1,2})',$_SERVER['HTTP_USER_AGENT'],$logVersion))
- In around line 876 (May vary from installation to installation),change:
function canStreamNative()
{
return( ZM_CAN_STREAM == "yes" || ( ZM_CAN_STREAM == "auto"
&& (isNetscape() || isKonqueror()) ) );
}

to
function canStreamNative()
{
return( ZM_CAN_STREAM == "yes" || ( ZM_CAN_STREAM == "auto" && (isNetscape
() || isKonqueror() || isOpera() || isSafari()) )
);
}

- In around line 840 (May vary from installation to installation),find this:
function isNetscape()
{
getBrowser( $browser, $version );
return( $browser == "mozilla" );
}

to
function isOpera() {
getBrowser( $browser, $version );
return( $browser == "opera" );
}
function isSafari() {
getBrowser( $browser, $version );
return( $browser == "safari" );
}


- For Kodicom KMC-8800 there's a fix, make a new file on /etc/modprobe.d/bttv.conf and place the option, for

for 1 card :
options i2c-algo-bit bit_test=1
options bttv gbuffers=16 card=102,102,102,102,102,102,102,102 radio=0,0,0,0,0,0,0,0 tuner=4,4,4,4,4,4,4,4 chroma_agc=1 combfilter=2 full_luma_range=1 coring=1 autoload=0

for 2 card :
options i2c-algo-bit bit_test=1
options bttv gbuffers=16 card=102,102,102,102,102,102,102,102,102,102,102,102,102,102,102,102 radio=0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 tuner=4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4 chroma_agc=1 combfilter=2 full_luma_range=1 coring=1 autoload=0


- There's a issue with shared memory with my installation - i don't know if you guys got the same issue too, if so... just insert below line to /etc/sysctl.conf
vim /etc/sysctl.conf
then insert :
kernel.shmall = 134217728
kernel.shmmax = 134217728
to load this setting immediately
sysctl -p

- If you want to use another partition as storage just create a symlink from /var/www/zm/events to zoneminder default folder :
ln -s /path/to/your/partition /var/www/zm/events

1 comments:

Anonymous said...

wonderful ... I'm keeping this as my REFERENCE howto

works every time (I've installed on an atom 270 mobo and a sheevaplug and guruplug ... works every time)

one slight correction in the zm ./configure command

--withffmpeg=

should be

--with-ffmpeg

and

--withwebgroup=www-data

should be

--with-webgroup=www-data

hope this helps

regards
jzaw

Post a Comment