Zoneminder

Материал из ALT Linux Wiki
Версия для печати больше не поддерживается и может содержать ошибки обработки. Обновите закладки браузера и используйте вместо этого функцию печати браузера по умолчанию.

ZoneMinder — свободное программное обеспечение, для организации видеонаблюдения.

В данной статье описано развёртыванию Zoneminder в ALT Linux.

Обсуждение на форуме: http://forum.altlinux.org/index.php/topic,22677.0.html.

Общая информация

В статье описана работа Zoneminder вместе с Nginx.

Установка Zoneminder

# apt-get install zoneminder nginx spawn-fcgi php8.1-fpm-fcgi fcgiwrap

Zoneminder-install-1.png

Настройка Zoneminder

Настройка БД

1. Устанавливаем Mysql:

$ su -
# apt-get install MySQL-server
# service mysqld enable
# service mysqld start

Zoneminder-install-2.png Zoneminder-install-3.png

3. Создаем пользователя

Где zmuser - имя пользователя, а zmpass - пароль.

# mysql
> CREATE USER 'zmuser'@localhost IDENTIFIED BY 'zmpass';


Zoneminder-install-5.png Zoneminder-install6.png

4. Создание базы данных MySQL

su -
mysql
mysql> create database zm;
mysql> use zm;
mysql> source /usr/share/zoneminder/db/zm_create.sql;
mysql> grant select,insert,update,delete on zm.* to 'zmuser'@localhost;
mysql> exit;
service mysqld restart

5. Настраиваем БД

Zoneminder-install7.pngZoneminder-install8.png

Открываем через редактор /etc/zm/zm.conf и меняем параметры:

ZM_DB_HOST=localhost
ZM_DB_NAME=zm
ZM_DB_USER=zmuser
ZM_DB_PASS=zmpass

Включаем службу:

Zoneminder-install9.png

systemctl enable --now zoneminder

Настройка веб-сервера

1. Редактируем файлы

# mcedit /etc/sysconfig/spawn-fcgi

Меняем значения:

- USERID=_spawn_fcgi
+ USERID=apache

Zoneminder-install10.pngZoneminder-install11.png

# mcedit /etc/sysconfig/spawn-fcgi

Меняем значения:

- FCGIPROGRAM="/usr/bin/fcgiwrap"
+ FCGIPROGRAM="/usr/sbin/fcgiwrap"


Zoneminder-install12.png

# mcedit /etc/nginx/nginx.conf

Zoneminder-install13.png Zoneminder-install14.png

Меняем значения:

- fastcgi_temp_path /var/spool/nginx/tmp/fastcgi
+ #fastcgi_temp_path /var/spool/nginx/tmp/fastcgi


4. Создать файлы

touch /etc/nginx/sites-enabled.d/zoneminder.conf
mcedit /etc/nginx/sites-enabled.d/zoneminder.conf

Zoneminder-install15.png Zoneminder-install16.png

server {
        listen  127.0.0.1:443;
        rewrite ^/(.*)$ http://$host/$1 permanent;
}

server {
        listen  80;
        types_hash_bucket_size 128;
        allow all;

        location / {
            root        /usr/share/zoneminder/www;
            rewrite ^/zm/(.*) /$1 break;
            index       index.php;
        }


        location /cgi-bin/zm {
                root   /usr/lib/zoneminder/cgi-bin;
                autoindex on;
                index  index.cgi;
                        
        }
        
        location ~ nph-zms$ {
                root    /usr/lib/zoneminder/cgi-bin;
                rewrite ^/cgi-bin/zm/(.*) /$1 break;
 
                include /etc/nginx/fastcgi_params;
 
                fastcgi_pass   unix:/var/run/spawn-fcgi/spw-cgi.sock;
                fastcgi_param  SCRIPT_FILENAME  /usr/lib/zoneminder/cgi-bin/$fastcgi_script_name;
        }

        location ~ /\.ht {
            deny all;
        }

        location ~ \.php$ {
            root /usr/share/zoneminder/www;
            rewrite ^/zm/(.*) /$1 break;
            include        fastcgi_params;
            include sites-enabled.d/zm-fcgi.inc;
            fastcgi_param  SCRIPT_FILENAME  /usr/share/zoneminder/www/$fastcgi_script_name;
            fastcgi_param  DOCUMENT_ROOT /usr/share/zoneminder/www;
        }

        access_log  /var/log/nginx/access.log;
}

Zoneminder-install17.png Zoneminder-install18.png

touch /etc/nginx/sites-enabled.d/zm-fcgi.inc
mcedit /etc/nginx/sites-enabled.d/zm-fcgi.inc
fastcgi_param  SERVER_NAME $hostname;
fastcgi_pass   unix:/var/run/php8.1-fpm/php8.1-fpm.sock;
fastcgi_index  index.php;
fastcgi_ignore_headers Cache-Control Expires Set-Cookie;
fastcgi_cache_key "$host$request_method$request_uri$is_args$args|$cookie_phpsessid";
fastcgi_temp_path  /var/spool/nginx/tmp/fastcgi 1 2;
fastcgi_cache_use_stale updating error timeout invalid_header http_500;
fastcgi_cache_valid 200 301 302 304 5m;
fastcgi_connect_timeout 180;
fastcgi_send_timeout 180;
fastcgi_read_timeout 250;
fastcgi_cache_bypass $cookie_phpsessid;
fastcgi_no_cache $cookie_phpsessid;
fastcgi_intercept_errors on;
fastcgi_param  HTTPS off;

5. Добавить пользователя apache в группу video

Zoneminder-install19.png

usermod -a -G video apache

6. Добавить сервисы в автозагрузку

Zoneminder-install20.png

systemctl enable --now  mysqld
systemctl enable --now nginx
systemctl enable --now zoneminder
systemctl enable --now spawn-fcgi
systemctl enable --now php8.1-fpm

Запуск Zoneminder

Чтобы запустить Zoneminder откройте браузер и перейдите по адресу http://localhost/ Zoneminder-install22.png

Смена языка

Zoneminder-install23.png

Чтобы поменять язык сделайте следующее:

  • Options
  • System
  • LANG_DEFAULT
  • ru_ru

Решение проблем

Примечание: Возможно, данные решения устарели


1. Ошибка в /var/log/messages

Jun 11 17:13:55 comp-core2-duo-d82748 zms[6530]: FAT [Can't open memory map file /dev/shm/zm.mmap.26, probably not enough space free: Permission denied]

Решение. Проверить от имени какого пользователя запущен сервис

ps aux|egrep '(apache|zm|php-fpm|fcgiwrap)'

должен быть везде apache, при необходимости поправить конфиги: spawn-fcgi, php5-fpm.conf и zm.conf.

PS. Вообще на любые сообщения с Permission denied лучше сразу смотреть от имени какого пользователя запущен сервис.

2. Ошибка при запуске nginx

Checking configuration sanity for nginx: nginx: [emerg] the same path name "/var/spool/nginx/tmp/fastcgi" in /etc/nginx/nginx.conf:15 has the different levels than in /etc/nginx/sites-enabled.d/zm-fcgi.inc:6

Решение. Закомментировать в файле /etc/nginx/nginx.conf

#fastcgi_temp_path  /var/spool/nginx/tmp/fastcgi;

3. Повторяющееся предупреждение в /var/log/nginx/error.log

PHP message: PHP Warning: strftime(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Asia/Yekaterinburg' for 'YEKT/6.0/no DST' instead in /usr/share/zoneminder/www/includes/functions.php on line 1440

PHP message: PHP Warning: strtotime(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Asia/Yekaterinburg' for 'YEKT/6.0/no DST' instead in /usr/share/zoneminder/www/includes/functions.php on line 1440

Решение. Прописать в конфиге php в /etc/php/5.5/fpm/php.ini таймзону в секции [Date]

date.timezone = Asia/Yekaterinburg

Ссылки

  1. http://www.zoneminder.com/wiki/index.php/Documentation
  2. http://www.lissyara.su/articles/freebsd/programms/zoneminder_2/
  3. http://wiki.rsu.edu.ru/wiki/ZoneMinder