Friday, 1 August 2008

Getting Zoneminder to work as quick as possible

About a week ago I decided to see if there was any Linux software available for setting up a security system in one's house. It didn't take much searching to find Zoneminder. My time is quite restricted and thus I was looking for the quickest way to get something working.

I have a server available consisting of:
  • a 1400 MHz Intel Celeron,
  • 640 MB of RAM
  • 120 GB hard drive
  • a USB Aiptek Pencam
  • a USB Logitech QuickCam Express

That by my standards is a lot for a server :-)

Firstly I donwloaded the ZoneMinder liveCD. That was quite painless. I burnt the downloaded image to a CD and did a reboot. The server started and both my USB webcams were working. The only thing I did have to do was to increase the minimum and maximum amounts for shared memory. I then had the liveCD install to my hard drive. Even this went smoothly but it does take at least a couple of hours to install. After the installation I changed the shmall and shmmax values in /etc/sysctl.conf. I just squared the number a couple of times. The proper way of calculating the amount of shared memory you should allocate is available on the Zoneminder website (see the FAQs), but I was lazy.

I'm quite religious about a server not having a GUI and being headless. So when I was sure everything worked well I set my default runlevel to 3 in the inittab.

I guess this was way too painless for my liking. They always say be careful what you wish for and I guess things couldn't be easier than that.

So, I started wondering whether I could add to my cameras by using my Hauppauge card. However, Zoneminder didn't pick this up too well. It did recognised the card but obviously lacked some drivers because the video devices were never required.

I thought I'd give Ubuntu a go. I'm not going to get into the Ubuntu effort too much because although Ubuntu picked the Hauppauge card up really well I then discovered there were some issues using the card with Zoneminder. There are workarounds that you can find more information on in the forums, but I didn't have time for that. My main problem was that Ubuntu didn't want to work well with my Logitech Quickcam. Ubuntu also managed to break my liveCD installation so I couldn't boot into that anymore.

I even tried re-installing the liveCD, but I still couldn't get the liveCD installation to boot - it just resulted in a kernel panic. Playing around with GRUB didn't help.

I thought I'd try one more alternative and if this didn't work I'd just delete all partitions and do a liveCD installation from scratch. This time I was going to try Fedora Core 8. Of the Linux distros, I'm the most familar with Fedora, hence my choice.

Once again everything went so smoothly I couldn't have asked for anything better. Here is what I did:


Step 1:

Install Fedora 8 from DVD. Make sure to install MySQL, Apache with PHP and (unless you have another installation for development) a C++ development environment because you are going to have to compile some drivers. I'm usually quite religious about not having development environments on servers too, but this is just my own little server and if it does ever move into a production environment I'll remove it again.

Step 2:
After the Fedora installation, install ZoneMinder. At the command prompt type: yum install zoneminder

Step 3:
Set the services to be started at startup
chkconfig --levels 345 httpd
chkconfig --levels 345 mysqld
chkconfig --levels 345 zoneminder

Step 4:
Create the ZoneMinder database with the following commands:
cd /usr/share/zoneminder/db
mysql < style="font-weight: bold;">Step 5:
Modify the following configuration file for Apache:
In /etc/httpd/conf.d/zoneminder.conf, remove the line containing: Deny from all

Step 6:
Change the shared memory by editing /etc/sysctl.conf and add the following lines or if they are modify them appropriately:

kernel.shmall = 134217728
kernel.shmmax = 134217728

Step 7:
If you are going to try everything before rebooting you will have to changes this manually. Do this with the following commands:
echo 134217728 >/proc/sys/kernel/shmall
echo 134217728 >/proc/sys/kernel/shmmax
sysctl -p

Step 8:
Fedora Core 8 detect my Aiptek Pencam quite happily, but it does not have the drivers for the Logitech QuickCam Express. I firstly tried the gspca driver, but that didn't work. I then downloaded and compiled the quickcam driver and that works perfectly. Following are instructions for compiling and installing both drivers:

gspca:


wget http://mxhaard.free.fr/spca50x/Download/gspcav1-20071224.tar.gz
tar -xzf gspcav1-20071224.tar.gz
cd gspcav1-20071224
make
make install
/sbin/modprobe gspca

quickcam:

wget http://surfnet.dl.sourceforge.net/sourceforge/qce-ga/qc-usb-0.6.6.tar.gz
tar xvzf qc-usb-0.6.6.tar.g
cd qc-usb-0.6.6
make all
make install
modprobe quickcam

Step 9:
Start zoneminder, apache and mysql with the following commands:
/etc/rc.d/init.d/httpd start
/etc/rc.d/init.d/mysqld start
/etc/rc.d/init.d/zoneminer start

Things might or might not work at this point. Rebooting though, would be your safest bet to make sure everything is properly installed for future use.







4 comments:

Anonymous said...

hi can you help me with install zoneminder on mandriva 2010 and quickcam express?
lsusb
Bus 003 Device 002: ID 046d:0920 Logitech, Inc. QuickCam Express

camorama dosnt know it
and skype worked out only with
LD_PRELOAD=/usr/lib/libv4l/v4l2convert.so skype

rychovvladimir@hotmail.com write me back please.

jannetta said...

Sorry kiddo. I have never used Mandriva and I haven't really touched Zoneminder for over a year.

chettai said...

hi frnd,
am jst a man who tried a lot on zoneminder n atlast its almost worked.. but ryt now am using zm arch linux live cd for my project..
i too having these probs,but atlast my cam workd..
did ur cam works with any other player like the same way u shown?? like mplyer or any other.. pls try to do so..so that v can point out the problm position.. k
n reply me.. ok

jannetta said...

Hi chettai

I haven't used ZoneMinder since 2008. I set it up to run while I was on holiday and haven't been on holiday since. So I haven't needed it. I really can't remember whether it worked with other applications or not, so I don't think I can be of much more help.