Tag Archives: zoneminder

Zoneminder: video surveillance system

Ubuntu 12.04.2 LTS

apt-get update
apt-get install zoneminder
/etc/init.d/apache2 stop
update-rc.d -f apache2 remove
apt-get install nginx-full
cat > /etc/nginx/sites-available/zm << EOF

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
server {
listen   80;
server_name  zm.lobotomy.me;
access_log  /var/log/nginx/zm.access.log;
root   /usr/share/zoneminder;

location / {
root /usr/share/zoneminder;
index index.php;

auth_basic            "closed site";
auth_basic_user_file  /etc/nginx/passwd;

if (!-e $request_filename) {
rewrite ^/(.*)$ /index.php?q=$1 last;
}

}

location ~* ^.+.(jpg|jpeg|gif|css|png|js|ico)$ {
access_log off;
expires 30d;
}

error_page 404 /index.php;
error_page 500 502 503 504 /50x.html;

location = /50x.html {
root /var/www/nginx-default;
}

location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /usr/share/zoneminder/$fastcgi_script_name;
fastcgi_param QUERY_STRING $query_string;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;
include /etc/nginx/fastcgi_params;
}

location ~ /\.ht {
deny all;
}

location  /cgi-bin/ {
proxy_pass              http://localhost:85;

proxy_set_header        X-Real-IP       $remote_addr;
proxy_set_header        Host            localhost:85;
proxy_set_header        REQUEST_METHOD  $request_method;
proxy_set_header        REMOTE_USER     $remote_user;
proxy_set_header        REMOTE_ADDR     $remote_addr;
proxy_set_header        SERVER_NAME     localhost;
proxy_set_header        SERVER_PORT     85;
proxy_set_header        HTTP_COOKIE     $http_cookie;
}
}
EOF

cd /etc/nginx/sites-enabled/
ln -s .../sites-available/zm
rm default
apt-get install xinetd

1
2
3
4
5
6
7
8
9
10
11
12
cat &gt; /etc/xinetd.d/zms-inetd &lt;&lt; EOF
service zms-inetd
{
disable         = no
id              = zms-inetd
socket_type     = stream
protocol        = tcp
user            = www-data
wait            = no
server          = /usr/local/bin/zms-inetd
}
EOF

cat > /usr/local/bin/zms-inetd << EOF

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#!/bin/bash
#
# Inetd-wrapper for ZMS (Zoneminder Streaming Server)
#
# Version: 2007-09-27
# Author: Kurt Zankl &lt;kz@xon.uni.cc&gt;
# Inspiration: http://www.debian-administration.org/articles/371
# Requirements: bash, inetd
# License: GNU General Public License, Version 2
#
# /etc/services:
# zms-inetd 85/tcp # Zoneminder ZMS inetd-wrapper
#
# /etc/inetd.conf:
# zms-inetd stream tcp nowait www-data /usr/local/bin/zms-inetd zms-inetd
#
# ZM Options / Paths / Web path to zms streaming server:
# ZM_PATH_ZMS = http://:85/
#

# configuration
ZMCONF="/etc/zm/zm.conf"
CGIBIN="zms"

# error handler
function errormsg {
echo "HTTP/1.0 500 Internal Server Error"
echo "Content-Type: text/html"
echo
echo "ERROR
<h1>ERROR</h1>
"
echo -e "
<pre escaped="true">$1"
  exit 1
}</pre>
# get request
read REQUEST
# skip headers
HEADER="nothing"; while [ "$HEADER" != $'\r' -a -n "$HEADER" ]; do read HEADER; done

# read ZM configuration
[ -r $ZMCONF ] || errormsg "Error reading Zoneminder configuration \"$ZMCONF\""
. $ZMCONF
ZMS="$ZM_PATH_CGI/$CGIBIN"
[ -x $ZMS ] || errormsg "Error finding ZMS executable \"$ZMS\""

# check request
[ -z "$REQUEST" ] &amp;&amp; errormsg "Request is empty"

# split request
URL="${REQUEST#GET }"
URL="${URL% HTTP/*}"
QUERY="${URL#*\?}"
URL="${URL%%\?*}"

# check query
[ "$QUERY" == "$URL" ] &amp;&amp; errormsg "Invalid query"

# execute ZMS
# (STDERR output is discarded as this confuses MPEG streaming clients)
export QUERY_STRING="$QUERY"
echo "HTTP/1.0 200 OK"
"$ZMS" 2&gt;/dev/null
echo
exit 0

set right path in option:
ZMCONF="/etc/zm/zm.conf"
/etc/init.d/xinetd restart

apt-get install php-fpm php-mysql php-gd
/etc/init.d/php-fpm restart

cd /usr/share/zoneminder/
ln -s .../javascript/ javascript

/etc/init.d/nginx restart

cat >> /etc/modules << EOF
uvcvideo
pwc
EOF

modprobe uvcvideo
modprobe pwc

Settings for Logitech QuickCam Pro 4000
Source: Local
Type: Modect
Source: /dev/video0
Channel: 0
Format: PAL
Capture type: YUV420
Width: 320
Height: 240