Gentoo – Zoneminder

The Zoneminder ebuild in the portage tree has been broken for a couple of years now. Here is the process I use to build Zoneminder from source on a Gentoo x86 install:

1. Get Root Access

sudo -s

2. Make The Source Directory

mkdir /usr/src/Zoneminder

3. Get The Source Package

cd /usr/src/Zoneminder

Stable: 1.25.0

wget http://www2.zoneminder.com/downloads/ZoneMinder-1.25.0.tar.gz

Development: svn

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

4. Unpack The Sources

tar xzf ZoneMinder-1.25.0.tar.gz

5. Install Required Dependencies

Add the following to /etc/portage/package.keywords:

#Zoneminder
www-misc/zoneminder
dev-perl/PHP-Serialization
virtual/perl-Module-Load
perl-core/Module-Load

Emerge all dependencies:

emerge -avq dev-perl/Archive-Zip dev-perl/Device-SerialPort dev-perl/MIME-Lite dev-perl/MIME-tools dev-perl/PHP-Serialization virtual/perl-Getopt-Long virtual/perl-Module-Load virtual/perl-Time-HiRes dev-perl/DateManip ffmpeg libjpeg-turbo gnutls libgcrypt g-cpan

Install Sys::Mmap with cpan:

g-cpan -i Sys::Mmap

6. Configure and Build Zoneminder

cd /usr/src/Zoneminder/ZoneMinder-1.25.0

Configure the sources (note this is for a localhost install, you can change it to whatever vhost you want)

Make sure to change the zm db username and password to reflect your setup.

./configure --with-webdir=/var/www/localhost/htdocs/zm --with-cgidir=/var/www/localhost/cgi-bin ZM_DB_USER="YOUR_USER" ZM_DB_PASS="YOUR_PASS" cflags="-O2 -march=native -fomit-frame-pointer" cxxflags="-O2 -march=native -fomit-frame-pointer" CPPFLAGS="-D__STDC_CONSTANT_MACROS"

Setup the DB

mysql -u root -p
create database zm;
grant select,insert,update,delete on zm.* to '<database user>'@localhost identified by '<database password>';
flush privileges;
exit

Import the Initial DB

mysql -u root -p -D zm < db/zm_create.sql

Build it

make clean
make
make install

After all that Zoneminder should be installed on your system and ready to run. Here are is an init script that I created to get Zoneminder started, stopped and reset as well as allow it to start up and shutdown on a machine power cycle.

#!/sbin/runscript
# File:    /etc/init.d/zoneminder
# Purpose:  Startup the Zoneminder Server
# By:   Ronny L. Bull
# Date: 8-31-2010

ZM_START='/usr/local/bin/zmpkg.pl start'
ZM_STOP='/usr/local/bin/zmpkg.pl stop'

depend() {
    need net mysql
}

start() {
        ebegin "Starting Zoneminder"
        $ZM_START
        eend $? "Failed to start Zoneminder!"
}

stop() {
        ebegin "Stopping Zoneminder"
        $ZM_STOP
        eend $? "Failed to stop Zoneminder!"
}

Save the file as zoneminder and copy it to /etc/init.d/zoneminder then make sure to run

chmod +x /etc/init.d/zoneminder

Now you can start and stop your server by doing:

/etc/init.d/zoneminder start

If you want it to start on power up add it to the default runlevel

rc-update add zoneminder default

Thats it! You should now be able to access the Zoneminder web interface at http://serverip/zm.

Now go buy some cameras!

  1. No Comments