Ubuntu Server 11.04 64-bit with ZoneMinder 1.24.x from SVN, FFmpeg, libjpeg-turbo, Webmin, Cambozola
From ZoneMinder
I hope you do not mind that I am copying this tutorial from the 10.10 server guide, but I just wanted to share my experiences with installing ZoneMinder (from SVN) on Ubuntu 11.04 64-bit. In addition, I added some knowledge from the forum to make things work.
- This guide is not intended to assist in installing Ubuntu or using ZoneMinder, only to obtain a simplified installation of ZoneMinder that is fast and just works.
#Install Ubuntu Server Edition 11.04 64-bit. (http://www.ubuntu.com/business/get-ubuntu/download)
#At software selection, select LAMP and OpenSSH server.
#After install completes, log in and set a static IP address in /etc/network/interfaces. Edit the addresses to suit YOUR network:
sudo nano /etc/network/interfaces
####################################
####################################
# The primary network interface
auto eth0
iface eth0 inet static
address 192.168.1.10
netmask 255.255.255.0
gateway 192.168.1.1
####################################
####################################
# ctrl-o to save ctrl-x to exit nano
sudo ifdown -a
sudo ifup -a
#Once networking is in order and you can reach the internet, ssh into your zoneminder system from another linux computer on your LAN.
#Now you can copy/paste the following commands into a terminal unless you prefer to type. Multiple commands without an empty line in between
#can be copied and pasted together. Do not paste lines that start with #
########################
#Update system software#
########################
sudo apt-get update
sudo apt-get upgrade
sudo reboot
#############
#Become root#
#############
sudo su
#######################
#Optimize GCC compiler#
#######################
export CFLAGS="-march=native -O2 -pipe" && \
export CXXFLAGS="${CFLAGS}" && \
export CPPFLAGS="${CFLAGS}"
#########################################
#Install prerequisites from repositories#
#########################################
aptitude install build-essential linux-headers-`uname -r` automake perl libauthen-pam-perl \
libpam-runtime libio-pty-perl libmysqlclient-dev \
libarchive-zip-perl libdate-manip-perl libdevice-serialport-perl libjpeg62 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 libnet-ssleay-perl libauthen-pam-perl libio-pty-perl apt-show-versions git-core mysql-server mysql-client
################
#Install Webmin#
################
wget http://downloads.sourceforge.net/project/webadmin/webmin/1.550/webmin_1.550_all.deb?use_mirror=voxel
mv webmin_1.550_all.deb\?use_mirror\=voxel webmin_1.550_all.deb && \
dpkg -i webmin_1.550_all.deb
#######################
#Install libjpeg-turbo# (AMD64)
#######################
wget http://downloads.sourceforge.net/project/libjpeg-turbo/1.1.0/libjpeg-turbo_1.1.0_amd64.deb?use_mirror=voxel
mv libjpeg-turbo_1.1.0_amd64.deb?use_mirror=voxel libjpeg-turbo_1.1.0_amd64.deb && \
dpkg -i libjpeg-turbo_1.1.0_amd64.deb
ln -s /opt/libjpeg-turbo/lib/libjpeg.a /usr/lib/libjpeg.a && \
ln -s /opt/libjpeg-turbo/include/jconfig.h /usr/include/jconfig.h && \
ln -s /opt/libjpeg-turbo/include/jerror.h /usr/include/jerror.h && \
ln -s /opt/libjpeg-turbo/include/jmorecfg.h /usr/include/jmorecfg.h && \
ln -s /opt/libjpeg-turbo/include/jpeglib.h /usr/include/jpeglib.h
#######################
#Configure Lib Paths#
#######################
echo "/opt/libjpeg-turbo/lib" > /etc/ld.so.conf.d/libjpeg-turbo.conf && \
echo "/usr/local/lib" > /etc/ld.so.conf.d/ffmpeg.conf && \
echo "LD_LIBRARY_PATH=/usr/local/lib:/opt/libjpeg-turbo/lib:$LD_LIBRARY_PATH" >> /etc/bash.bashrc && \
echo "export LD_LIBRARY_PATH" >> /etc/bash.bashrc
ldconfig
######################
#Install Perl Modules#
######################
perl -MCPAN -e shell
install CPAN
exit
perl -MCPAN -e shell
install YAML PHP::Serialization Module::Load X10::ActiveHome
exit
#
#Command below is updated from the 10.10 guide, because the original command gave me test
#errors on Mmap.
#
LC_ALL=C perl -MCPAN -e shell
install Sys::Mmap
install DBI
install DBD::mysql
exit
################
#Install FFmpeg#
################
# subversion no longer maintained
#cd /usr/src && svn checkout svn://svn.mplayerhq.hu/ffmpeg/trunk ffmpeg
# use git resource: http://www.ffmpeg.org/download.html
cd /usr/src && git clone git://git.videolan.org/ffmpeg.git
cd /usr/src/ffmpeg/ && ./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
ldconfig
#####################
##Install Zoneminder#
#####################
cd /usr/src
svn co http://svn.zoneminder.com/svn/zm/trunk zm
cd /usr/src/zm/src && nano zm_utils.cpp
#Insert the following line after other includes,then Ctrl-o to save, Ctrl-x to exit nano
#include <cstdio>
###Edit files below, or ZoneMinder will not compile (depricated as of May 13th, look at update below.)
#
###nano src/zm_ffmpeg_camera.cpp # change “CODEC_TYPE_VIDEO” to “AVMEDIA_TYPE_VIDEO”
###nano src/zm_mpeg.cpp # change “PKT_FLAG_KEY” to “AV_PKT_FLAG_KEY”
###nano src/zm_mpeg.cpp # change “CODEC_TYPE_VIDEO” to “AVMEDIA_TYPE_VIDEO”
###nano src/zm_remote_camera_rtsp.cpp # change as before
###nano src/zm_rtsp.cpp # change as before
###nano src/zm_sdp.cpp # change all CODEC_TYPE_ to AVMEDIA_TYPE_
###nano src/zm_sdp.h # change “enum CodecType” to “enum AVMediaType”
#UPDATE May 13th, thanks to Nogero (http://www.zoneminder.com/forums/viewtopic.php?f=21&t=17621)
### script to edit cpp files using sed so they compile on Ubuntu 11.04
sed 's/CODEC_TYPE_VIDEO/AVMEDIA_TYPE_VIDEO/g' zm_ffmpeg_camera.cpp > /tmp/ptmp.cpp ; mv /tmp/ptmp.cpp zm_ffmpeg_camera.cpp
sed 's/PKT_FLAG_KEY/AV_PKT_FLAG_KEY/g' zm_mpeg.cpp > /tmp/ptmp.cpp ; mv /tmp/ptmp.cpp zm_mpeg.cpp
sed 's/CODEC_TYPE_VIDEO/AVMEDIA_TYPE_VIDEO/g' zm_mpeg.cpp > /tmp/ptmp.cpp ; mv /tmp/ptmp.cpp zm_mpeg.cpp
# zm_remote_camera_rtsp.cpp # change as before
sed 's/PKT_FLAG_KEY/AV_PKT_FLAG_KEY/g' zm_remote_camera_rtsp.cpp > /tmp/ptmp.cpp ; mv /tmp/ptmp.cpp zm_remote_camera_rtsp.cpp
sed 's/CODEC_TYPE_VIDEO/AVMEDIA_TYPE_VIDEO/g' zm_remote_camera_rtsp.cpp > /tmp/ptmp.cpp ; mv /tmp/ptmp.cpp zm_remote_camera_rtsp.cpp
# zm_rtsp.cpp # change as before
sed 's/PKT_FLAG_KEY/AV_PKT_FLAG_KEY/g' zm_rtsp.cpp > /tmp/ptmp.cpp ; mv /tmp/ptmp.cpp zm_rtsp.cpp
sed 's/CODEC_TYPE_VIDEO/AVMEDIA_TYPE_VIDEO/g' zm_rtsp.cpp > /tmp/ptmp.cpp ; mv /tmp/ptmp.cpp zm_rtsp.cpp
sed 's/CODEC_TYPE_/AVMEDIA_TYPE_/g' zm_sdp.cpp > /tmp/ptmp.cpp ; mv /tmp/ptmp.cpp zm_sdp.cpp
sed 's/enum CodecType/enum AVMediaType/g' zm_sdp.h > /tmp/ptmp.cpp ; mv /tmp/ptmp.cpp zm_sdp.h
# -------------- end of script -----------------
cd /usr/src/zm && \
./configure --with-webdir=/var/www/zm --with-cgidir=/usr/lib/cgi-bin \
ZM_DB_HOST=localhost ZM_DB_NAME=zm ZM_DB_USER=zmuser \
ZM_DB_PASS=zmpass ZM_SSL_LIB=openssl --enable-debug=no \
--with-webgroup=www-data --with-webuser=www-data --enable-mmap CPPFLAGS="-D__STDC_CONSTANT_MACROS ${CPPFLAGS}"
autoconf
aclocal
automake
make
mysql -u root -p < db/zm_create.sql
#Password that is requested is Mysql root password that was entered during install, not your ubuntu password.
mysql -u root -p
grant select,insert,update,delete on zm.* to 'zmuser'@localhost identified by 'zmpass';
quit
mysqladmin -p reload
make install
####################
##Install Cambozola#
####################
cd /usr/src && wget http://www.charliemouse.com:8080/code/cambozola/cambozola-latest.tar.gz
tar -xzvf cambozola-latest.tar.gz
#replace xx with cambozola version downloaded
cp cambozola-0.xx/dist/cambozola.jar /var/www/zm
###################################
##Create Zoneminder startup script#
###################################
nano -w /etc/init.d/zm
#Paste everything BETWEEN the lines below.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#!/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
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#ctrl-o to save, ctrl-x to exit nano
chmod 755 /etc/init.d/zm
#Because Ubuntu clears /tmp for some kind of reason at reboot,
#the /tmp/zm directory will also be deleted after a reboot. Creation in script/zmdc.in.pl
#will resolve this.
nano scripts/zmdc.pl
#Add following lines (marked with a '+'-sign between the lines given (do not include '+').
foreach my $arg ( @ARGV )
}
}
+# Create the directory first if it doesn't exist
+mkdir(ZM_PATH_SOCKS);
+
socket( CLIENT, PF_UNIX, SOCK_STREAM, 0 ) or Fatal( "Can't open socket: $!" );
my $saddr = sockaddr_un( SOCK_FILE );
#To be sure, add rights to the /tmp/zm directory
chown www-data:www-data -R /tmp/zm
####################
#Zoneminder Startup#
####################
#In firefox, go to https://YOUR_ZoneMinder.IP.ADDRESS.HERE:10000 to reach the Webmin interface.(Login with Ubuntu username and password)
#In left menu, select System>Bootup and Shutdown. Tick the box next to zm and click StartNow and On Boot.
#In left menu, select Servers>Apache Webserver. Click virtual server under Existing virtual hosts tab. Under Virtual Server Details, change Document Root to /var/www/zm and then save.
#Click apply changes at top left of page.
#Go to http://YOUR_ZoneMinder.IP.ADDRESS.HERE to reach the Zoneminder interface.
# Last edited May 8, 2011