オープンソースの監視カメラシステムと言ったらZoneMinder一択でしょ


まずは[ZoneMinder](https://zoneminder.com/)の機能を確認してみよう
---

参考になる画像や動画が少なくて残念ですが、役立つこと間違いなしです。


Ubuntu 19.10 で ZoneMinder v1.34.1 をインストールする（ログのみ）
---

```shell-session
$ cat /etc/os-release 
NAME="Ubuntu"
VERSION="19.10 (Eoan Ermine)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 19.10"
VERSION_ID="19.10"
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
VERSION_CODENAME=eoan
UBUNTU_CODENAME=eoan

$ sudo su

# apt install tasksel
# tasksel install lamp-server
# mysql_secure_installation

Securing the MySQL server deployment.

Connecting to MySQL using a blank password.

VALIDATE PASSWORD COMPONENT can be used to test passwords
and improve security. It checks the strength of password
and allows the users to set only those passwords which are
secure enough. Would you like to setup VALIDATE PASSWORD component?

Press y|Y for Yes, any other key for No: n
Please set the password for root here.

New password: 【パスワード】 

Re-enter new password: 【パスワード】
By default, a MySQL installation has an anonymous user,
allowing anyone to log into MySQL without having to have
a user account created for them. This is intended only for
testing, and to make the installation go a bit smoother.
You should remove them before moving into a production
environment.

Remove anonymous users? (Press y|Y for Yes, any other key for No) : y
Success.


Normally, root should only be allowed to connect from
'localhost'. This ensures that someone cannot guess at
the root password from the network.

Disallow root login remotely? (Press y|Y for Yes, any other key for No) : y
Success.

By default, MySQL comes with a database named 'test' that
anyone can access. This is also intended only for testing,
and should be removed before moving into a production
environment.


Remove test database and access to it? (Press y|Y for Yes, any other key for No) : y
 - Dropping test database...
Success.

 - Removing privileges on test database...
Success.

Reloading the privilege tables will ensure that all changes
made so far will take effect immediately.

Reload privilege tables now? (Press y|Y for Yes, any other key for No) : y
Success.

All done! 

# cp -p /etc/mysql/mysql.conf.d/mysqld.cnf /etc/mysql/mysql.conf.d/mysqld.cnf.org
# vi /etc/mysql/mysql.conf.d/mysqld.cnf
```

```text
[mysqld]
default_authentication_plugin = mysql_native_password
```


```shell-session
# systemctl restart mysql
# mysql -uroot -p < /usr/share/zoneminder/db/zm_create.sql
Enter password: 【パスワード】
# mysql
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 81
Server version: 8.0.19-0ubuntu0.19.10.3 (Ubuntu)

Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> CREATE USER 'zmuser'@localhost IDENTIFIED WITH mysql_native_password BY 'zmpass'; 
Query OK, 0 rows affected (0.24 sec)

mysql> GRANT ALL PRIVILEGES ON zm.* TO 'zmuser'@'localhost' WITH GRANT OPTION;
Query OK, 0 rows affected (0.15 sec)

mysql> FLUSH PRIVILEGES ;
Query OK, 0 rows affected (0.06 sec)

mysql> \q
Bye

# mysqladmin -uroot -p reload
Enter password: 【パスワード】

# apt install gdebi
# wget https://launchpad.net/~iconnor/+archive/ubuntu/zoneminder-1.34/+build/18611844/+files/zoneminder_1.34.1-disco1_amd64.deb
# wget https://launchpad.net/~iconnor/+archive/ubuntu/zoneminder-1.34/+files/libmp4v2-2_2.0.0~dfsg0-disco2_amd64.deb
# wget http://security.ubuntu.com/ubuntu/pool/main/m/mysql-5.7/libmysqlclient20_5.7.29-0ubuntu0.18.04.1_amd64.deb

# gdebi libmysqlclient20_5.7.29-0ubuntu0.18.04.1_amd64.deb
# gdebi libmp4v2-2_2.0.0~dfsg0-disco2_amd64.deb
# gdebi zoneminder_1.34.1-disco1_amd64.deb

# chmod 740 /etc/zm/zm.conf
# chown root:www-data /etc/zm/zm.conf
# chown -R www-data:www-data /usr/share/zoneminder/

# cp /usr/share/php7.3-mysql/mysql/*.ini /etc/php/7.3/mods-available/

# systemctl enable zoneminder.service
# systemctl start zoneminder 

# a2enconf zoneminder
# a2enmod cgi
# a2enmod rewrite
# service apache2 reload
```

ブラウザで管理コンソールに接続し、タイムゾーンを設定する
---

http://localhost/zm/
http://localhost/zm/index.php?view=options

```text
  TimeZone
    (GMT+09:00) Asia, Tokyo
  SAVE
```

ネットワークカメラを登録する。今回はAndroidアプリ[IP Webcam](https://play.google.com/store/apps/details?id=com.pas.webcam&hl=ja)で試してみる。設定は下記。
---

**General：** 

|変数|値|
|:----|:----|
|Name|IP Webcam|
|Source Type|Remote|
|Function|Monitor|

**Source：**

|変数|値|
|:----|:----|
|Protocol|HTTP|
|Method|Simple|
|Host Name|192.168.3.100|
|Port|8080|
|Path|/video|
|Capture Resolution (pixels)|1920x1080 1080p (一例)| 

あれれ
---

"An update to ZoneMinder is available. The latest release is v1.34.2, you have v1.34.1." のメッセージが出てきます。バージョンアップの方法を調べないと。


参考
---

- [Ubuntu Server 19.10 Zoneminder 1.33.x](https://wiki.zoneminder.com/Ubuntu_Server_19.10_Zoneminder_1.33.x)
- [Ubuntu 18.04にLAMP環境をインストールする。](https://qiita.com/yoshiharu-semachi/items/5f38ce17780ef83b5110)
- [no video on cam on 1.32.3](https://forums.zoneminder.com/viewtopic.php?t=27884)