In this How-to I will explain how to install and configure:

  • Cherokee Web Server

  • Zoneminder video camera security and surveillance solution

  • ffmpeg support with mpeg-4 codec (xvid)

  • php and other relevant packages

I have divided this guide in 2 parts: Cherokee + php and Zoneminder installation.

 

So, let's begin!




PART 1 : Installing Cherokee Web Server and PHP on Gentoo Linux

 

First we need to unmask www-servers/cherokee package

# echo "www-servers/cherokee" >> /etc/portage/package.keywords

next we set up our make options for cherokee

Edit /etc/make.conf and add "threads" to the USE variable

finally we use emerge to compile and install the package

# emerge --quiet www-servers/cherokee

TIP: using the --quiet reduces the output produced by emerge, reducing the cpu consumption.

Now we will add php support to Cherokee. This is quite simple as portage do most of the work for us, you just need php compiled with FastCGI support. - This is my usual configuration:

edit /etc/make.conf
add "cgi gd ftp hash mysql opd sockets xml" to the USE variable

cgi - Add support for the cgi / FastCGI interface
gd - Adds support for media-libs/gd (to generate graphics on the fly)
ftp - Adds FTP (File Transfer Protocol) support
mhash - Adds support for the mhash library
mysql - Adds mySQL Database support
pdo – database access libraries sockets – Adds support for tcp/ip sockets
xml - Add support for XML files

Now we are now ready to emerge our package (this will take while to finish):

# emerge --quiet dev-lang/php

and start Cherokee Web Server:

# /etc/init.d/cherokee start

Cherokee + PHP should be working fine now, if you want to test it you follow this simple process:

# echo "<? phpinfo(); ?>" > /var/www/localhost/htdocs/test.php

open http://your_domain_or_ip_address/test.php and you should see a php report.

If everything is ok we remove the file:

# rm /var/www/localhost/htdocs/test.php

TIP: the phpinfo(); function can be a dangerous security issue! it displays sensitive information about our php configuration!

PART 2 : Zoneminder + ffmpeg + mpeg4 (divx) support on Gentoo Linux + Cherokee

Zoneminder is really cool video security and surveillance system, and it's even cooler when you add ffmpeg with mpeg4 codec support!. For this guide I assume you have your video capture device, webcam, or video streaming service already up and running. First we modify our USE variable in make.conf:

edit /etc/make.conf with you favorite editor and add the following values to your USE varible:

"a52 aac encode ieee1394 imlib ogg sdl theora truetype v4l vorbis x264 xvid aalib alsa fbcon flac ggi libcaca bzip2 gif jpeg jpeg2k mp3 png tiff mpeg vhosts"

USE variables for media-video/ffmpeg

a52 - Enables support for decoding ATSC A/52 streams used in DVD
aac - Enables support for MPEG-4 AAC Audio
encode - Adds support for encoding of audio or video files eee1394 - Enable FireWire/iLink IEEE1394 support (dv, camera, ...)
imlib - Adds support for imlib, an image loading and rendering library
ogg - Adds support for the Ogg container format (commonly used by Vorbis, Theora and flac)
sdl - Adds support for Simple Direct Layer (media library)
theora - Adds support for the Theora Video Compression Codec
truetype - Adds support for FreeType and/or FreeType2 fonts
v4l - Enables video4linux support
vorbis - Adds support for the OggVorbis audio codec
x264 - Enable h264 encoding using x264
xvid - Adds support for xvid.org's open-source mpeg-4 codec

USE variables for media-libs/libsdl

aalib - Adds support for media-libs/aalib (ASCII-Graphics Library)
alsa - Adds support for media-libs/alsa-lib (Advanced Linux Sound Architecture)
fbcon - Adds framebuffer support for the console, via the kernel
flac - Adds support for the flac audio codec
cgi - Adds support for media-libs/libggi (non-X video api/drivers)
libcaca - Add support for colored ASCII-art graphics

USE variables for media-libs/imlib2

bzip2 - Use the bzlib compression library
gif - Adds GIF image support
jpeg - Adds JPEG image support
jpeg2k - Support for JPEG 2000, a wavelet-based image compression format
mp3 - Add support for reading mp3 files tiff - Adds support for the tiff image format

USE variables for www-misc/zoneminder

mpeg -Adds libmpeg3 support to various packages
vhosts - Adds support for installing web-based applications into a virtual-hosting environment

We unmask Zoneminder ebuild and it's dependencies:

# echo "www-misc/zoneminder" >> /etc/portage/package.keywords

# echo "dev-perl/X10" >> /etc/portage/package.keywords

Zoneminder ebuild needs apache user/group to finish installing, so we need create them (we will delete them later)

# useradd apache (this will create both user and group)

we are now ready to launch the emerge process for Zoneminder + ffmpeg

# emerge --quiet web-misc/zoneminder media-video/ffmpeg

NOTE: at this point you might see a webapp-config error, this is because you probably didn't use vhosts USE variable, in this cases webapp-config runs automatically for user localhost, showing you this error:

* Fatal error: Your configuration file sets the server type "Apache"

* Fatal error: but the corresponding package does not seem to be installed!

if this happens, just ignore the error, we will copy the files by hand later.

we delete the apache user/group we created earlier

# userdel apache # groudel apache

webapp-config won't work because we don't have Apache installed, so we copy Zoneminder files manually:

# mkdir /var/www/localhost/htdocs/zoneminder/

# cp /usr/share/webapps/zoneminder/1.22.3/htdocs/* /var/www/localhost/htdocs/zoneminder/ -R

# cp /usr/share/webapps/zoneminder/1.22.3/hostroot/cgi-bin/* /var/www/localhost/cgi-bin/ -R

TIP: Gentoo always saves emerged webapps in /usr/share/webapps/

time to modify directory permissions so Zoneminder works with Cherokee:

# chown cherokee:cherokee /var/log/zoneminder/ -R

# chown cherokee:cherokee /var/run/zm -R

# chown cherokee:cherokee /var/www/localhost/ -R

Zoneminder needs a mysql database to store it's data, let's set things up!

We check if our hostname is configured in /etc/hosts

kp_1 ~ # vi /etc/hosts

127.0.0.1 localhost your_hostname

Now we run mysql first installation script

kp_1 ~ # /usr/bin/mysql_install_db

Installing MySQL system tables... OK

Filling help tables... OK

(etc)

time to set our mysql root password

kp_1 ~ # /etc/init.d/mysql start

kp_1 ~ # /usr/bin/mysqladmin -u root password 'your_password'

now we fill our sql data and set up database permissions

kp_1 ~ # mysql -p -u root < /usr/share/zoneminder/db/zm_create.sql

kp_1 ~ # mysql -p -u root zm

mysql> grant all on zm.* to 'zoneminder'@localhost identified by 'password';

setting up our system information in /etc/zm.conf

ZM_PATH_BUILD=/usr/share/zoneminder

ZM_PATH_WEB=/var/www/localhost/htdocs/zoneminder

ZM_PATH_CGI=/var/www/localhost/cgi-bin

ZM_WEB_USER=cherokee

ZM_WEB_GROUP=cherokee

ZM_DB_HOST=localhost

ZM_DB_NAME=zm

ZM_DB_USER=zoneminder

ZM_DB_PASS=you_db_password_for_user_zoneminder

To avoid having low shared memory errors (usually happens) we modify our sysctl.com:

kp_1 ~ # vi /etc/sysctl.conf

kernel.shmmax=200000000

kernel.shmall=200000000

kp_1 ~ # sysctl -p /etc/sysctl.conf

kernel.shmmax = 200000000

kernel.shmall = 200000000

kp_1 ~ #

We set the permissions so user cherokee can read from video devices:

# usermod -G video cherokee

If needed, modify the following line with your video device(s):

# chmod 660 /dev/v4l/video0

restart involved services “just-in-case(tm)”:

# /etc/init.d/mysql restart

# /etc/init.d/cherokee restart

# /etc/init.d/zoneminder restart

Point your browser (preferably firefox, gives better streaming performance) to htpp://yoursite/zoneminder, You should now have a working Zoneminder system!

 

- Feel free to leave any comments, suggestions, bug reports, or any kind of feedback you want
I will try to answer most of your questions - This page will be updated periodically -

-=kp=-

[Slashdot] [Digg] [Reddit] [del.icio.us] [Facebook] [Technorati] [Google] [StumbleUpon]

No Responses to “Cherokee + php + Zoneminder on Gentoo Linux Howto”  

  1. No Comments

Leave a Reply