File: ubuntu.rst

package info (click to toggle)
zoneminder 1.36.35%2Bdfsg1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 53,728 kB
  • sloc: php: 219,767; perl: 127,535; javascript: 75,411; cpp: 59,876; sql: 6,635; sh: 2,472; ansic: 1,467; makefile: 534; xml: 240; asm: 157; python: 74
file content (445 lines) | stat: -rw-r--r-- 12,002 bytes parent folder | download
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
Ubuntu
======

.. contents::

Easy Way: Ubuntu 18.04 (Bionic)
-------------------------------
These instructions are for a brand new ubuntu 18.04 system which does not have ZM
installed.


It is recommended that you use an Ubuntu Server install and select the LAMP option
during install to install Apache, MySQL and PHP. If you failed to do this you can
achieve the same result by running:

::

    sudo apt-get install tasksel
    sudo tasksel install lamp-server

Installing LAMP is not ZoneMinder specific so you will find plenty of resources to 
guide you with a quick search.

**Step 1:** Either run commands in this install using sudo or use the below to become root
::

    sudo -i

**Step 2:** Update Repos

.. topic :: Latest Release

    ZoneMinder is now part of the current standard Ubuntu repository, but
    sometimes the official repository can lag behind. To find out check our
    `releases page <https://github.com/ZoneMinder/zoneminder/releases>`_ for
    the latest release.
    
    Alternatively, the ZoneMinder project team maintains a `PPA <https://askubuntu.com/questions/4983/what-are-ppas-and-how-do-i-use-them>`_, which is updated immediately
    following a new release of ZoneMinder. To use this repository instead of the
    official Ubuntu repository, enter the following from the command line:

    ::

        add-apt-repository ppa:iconnor/zoneminder-1.36

Update repo and upgrade.

::

	      apt-get update
        apt-get dist-upgrade


**Step 3:** Configure MySQL

.. sidebar :: Note

    The MySQL default configuration file (/etc/mysql/mysql.cnf) is read through
    several symbolic links beginning with /etc/mysql/my.cnf as follows:

    | /etc/mysql/my.cnf -> /etc/alternatives/my.cnf
    | /etc/alternatives/my.cnf -> /etc/mysql/mysql.cnf
    | /etc/mysql/mysql.cnf is a basic file

Certain new defaults in MySQL 5.7 cause some issues with ZoneMinder < 1.32.0,
the workaround is to modify the sql_mode setting of MySQL. Please note that these 
changes are NOT required for ZoneMinder 1.32+ and some people have reported them 
causing problems in 1.32.0.

To better manage the MySQL server it is recommended to copy the sample config file and
replace the default my.cnf symbolic link.

::

        rm /etc/mysql/my.cnf  (this removes the current symbolic link)
        cp /etc/mysql/mysql.conf.d/mysqld.cnf /etc/mysql/my.cnf

To change MySQL settings:

::

        nano /etc/mysql/my.cnf

In the [mysqld] section add the following

::

        sql_mode = NO_ENGINE_SUBSTITUTION

CTRL+o then [Enter] to save

CTRL+x to exit

Restart MySQL

::

        systemctl restart mysql


**Step 4:** Install ZoneMinder

::

	apt-get install zoneminder

**Step 5:** Configure the ZoneMinder Database

This step should not be required on ZoneMinder 1.32.0.

::

	mysql -uroot -p < /usr/share/zoneminder/db/zm_create.sql
	mysql -uroot -p -e "grant lock tables,alter,drop,select,insert,update,delete,create,index,alter routine,create routine, trigger,execute,references on zm.* to 'zmuser'@localhost identified by 'zmpass';"


**Step 6:** Set permissions

Set /etc/zm/zm.conf to root:www-data 740 and www-data access to content

::

        chmod 740 /etc/zm/zm.conf
        chown root:www-data /etc/zm/zm.conf

**Step 7:** Configure Apache correctly:

::

        a2enmod cgi
        a2enmod rewrite
        a2enconf zoneminder

You may also want to enable to following modules to improve caching performance

::

         a2enmod expires
         a2enmod headers

**Step 8:** Enable and start Zoneminder

::

        systemctl enable zoneminder
        systemctl start zoneminder

CTRL+o then [Enter] to save

CTRL+x to exit

**Step 10:** Reload Apache service

::

	systemctl reload apache2

**Step 11:** Making sure ZoneMinder works

1. Open up a browser and go to ``http://hostname_or_ip/zm`` - should bring up ZoneMinder Console

2. (Optional API Check)Open up a tab in the same browser and go to ``http://hostname_or_ip/zm/api/host/getVersion.json``

    If it is working correctly you should get version information similar to the example below:

    ::

            {
                "version": "1.34.0",
                "apiversion": "1.34.0.1"
            }

**Congratulations**  Your installation is complete

PPA install may need some tweaking of ZMS_PATH in ZoneMinder options. `Socket_sendto or no live streaming`_

Easy Way: Ubuntu 16.04 (Xenial)
-------------------------------
These instructions are for a brand new ubuntu 16.04 system which does not have ZM
installed.


It is recommended that you use an Ubuntu Server install and select the LAMP option
during install to install Apache, MySQL and PHP. If you failed to do this you can
achieve the same result by running:

::

    sudo tasksel install lamp-server

During installation it will ask you to set up a master/root password for the MySQL.
Installing LAMP is not ZoneMinder specific so you will find plenty of resources to 
guide you with a quick search.

**Step 1:** Either run commands in this install using sudo or use the below to become root
::

    sudo -i

**Step 2:** Update Repos

.. topic :: Latest Release

    ZoneMinder is now part of the current standard Ubuntu repository, but
    sometimes the official repository can lag behind. To find out check our
    `releases page <https://github.com/ZoneMinder/zoneminder/releases>`_ for
    the latest release.
    
    Alternatively, the ZoneMinder project team maintains a `PPA <https://askubuntu.com/questions/4983/what-are-ppas-and-how-do-i-use-them>`_, which is updated immediately
    following a new release of ZoneMinder. To use this repository instead of the
    official Ubuntu repository, enter the following from the command line:

    ::

        add-apt-repository ppa:iconnor/zoneminder
        add-apt-repository ppa:iconnor/zoneminder-1.32

Update repo and upgrade.

::

	apt-get update
        apt-get upgrade
        apt-get dist-upgrade


**Step 3:** Configure MySQL

.. sidebar :: Note

    The MySQL default configuration file (/etc/mysql/mysql.cnf)is read through
    several symbolic links beginning with /etc/mysql/my.cnf as follows:

    | /etc/mysql/my.cnf -> /etc/alternatives/my.cnf
    | /etc/alternatives/my.cnf -> /etc/mysql/mysql.cnf
    | /etc/mysql/mysql.cnf is a basic file

Certain new defaults in MySQL 5.7 cause some issues with ZoneMinder < 1.32.0,
the workaround is to modify the sql_mode setting of MySQL. Please note that these 
changes are NOT required for ZoneMinder 1.32.0 and some people have reported them 
causing problems in 1.32.0.

To better manage the MySQL server it is recommended to copy the sample config file and
replace the default my.cnf symbolic link.

::

        rm /etc/mysql/my.cnf  (this removes the current symbolic link)
        cp /etc/mysql/mysql.conf.d/mysqld.cnf /etc/mysql/my.cnf

To change MySQL settings:

::

        nano /etc/mysql/my.cnf

In the [mysqld] section add the following

::

        sql_mode = NO_ENGINE_SUBSTITUTION

CTRL+o then [Enter] to save

CTRL+x to exit

Restart MySQL

::

        systemctl restart mysql


**Step 4:** Install ZoneMinder

::

	apt-get install zoneminder

**Step 5:** Configure the ZoneMinder Database

This step should not be required on ZoneMinder 1.32.0.

::

	mysql -uroot -p < /usr/share/zoneminder/db/zm_create.sql
	mysql -uroot -p -e "grant lock tables,alter,drop,select,insert,update,delete,create,index,alter routine,create routine, trigger,execute on zm.* to 'zmuser'@localhost identified by 'zmpass';"


**Step 6:** Set permissions

Set /etc/zm/zm.conf to root:www-data 740 and www-data access to content

::

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

**Step 7:** Configure Apache correctly:

::

        a2enmod cgi
        a2enmod rewrite
        a2enconf zoneminder

You may also want to enable to following modules to improve caching performance

::

         a2enmod expires
         a2enmod headers

**Step 8:** Enable and start Zoneminder

::

        systemctl enable zoneminder
        systemctl start zoneminder

**Step 10:** Reload Apache service

::

	systemctl reload apache2

**Step 11:** Making sure ZoneMinder works

1. Open up a browser and go to ``http://hostname_or_ip/zm`` - should bring up ZoneMinder Console

2. (Optional API Check)Open up a tab in the same browser and go to ``http://hostname_or_ip/zm/api/host/getVersion.json``

    If it is working correctly you should get version information similar to the example below:

    ::

            {
                "version": "1.34.0",
                "apiversion": "1.34.0.1"
            }

**Congratulations**  Your installation is complete

PPA install may need some tweaking of ZMS_PATH in ZoneMinder options. `Socket_sendto or no live streaming`_

Harder Way: Build Package From Source
-------------------------------------
(These instructions assume installation from source on a ubuntu 15.x+ system)

**Step 1:** Grab the package installer script

::

	wget https://raw.githubusercontent.com/ZoneMinder/ZoneMinder/master/utils/do_debian_package.sh
	chmod a+x do_debian_package.sh


**Step 2:** Update the system

::

	sudo apt-get update


**Step 3** Create the package

To build the latest master snapshot:

::

	./do_debian_package.sh --snapshot=NOW --branch=master --type=local


To build the latest stable release:

::

	./do_debian_package.sh --snapshot=stable --type=local


Note that the distribution will be guessed using ``lsb_release -a 2>/dev/null | grep Codename | awk '{print $2}'``
which simply extracts your distribution name - like "xenial", "bionic" etc. You
can always specify it using --distro=your distro name if you know it. As far as the script
goes, it checks if your distro is "trusty" in which case it pulls in pre-systemd
release configurations and if its not "trusty" it assumes its based on systemd
and pulls in systemd related config files.

(At the end the script will ask if you want to retain the checked out version of
ZoneMinder. If you are a developer and are making local changes, make sure you
select "y" so that the next time you do the build process mentioned here, it
keeps your changes. Selecting any other value than "y" or "Y" will delete the
checked out code and only retain the package)

This should now create a bunch of .deb files

**Step 4:** Install the package

::

	sudo gdebi zoneminder_<version>_<arch>.deb
	(example sudo gdebi zoneminder_1.34.0-bionic-2021020801_amd64.deb)


**This will report DB errors - ignore - you need to configure the DB and some other stuff**

**Step 5:** Post install configuration

Now that you have installed from your own package you can resume following the
standard install guide for your version, start at the step after Install Zoneminder.

Hints
-----
Make sure ZoneMinder and APIs work with security
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

1. Enable OPT_AUTH in ZoneMinder
2. Log out of ZoneMinder in browser
3. Open a new tab in the *same browser* (important) and go to
   ``http://localhost/zm/api/host/getVersion.json`` - should give you "Unauthorized"
   along with a lot more of text
4. Go to another tab in the SAME BROWSER (important) and log into ZM
5. Repeat step 3 and it should give you the ZM and API version

Socket_sendto or no live streaming
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

After you have setup your camera make sure you can view Monitor streams, if not
check some of the common causes:

* Check Apache cgi module is enabled.
* Check Apache /etc/apache2/conf-enabled/zoneminder.conf ScriptAlias matches PATH_ZMS.

        ScriptAlias **/zm/cgi-bin** /usr/lib/zoneminder/cgi-bin

        From console go to ``Options->Path`` and make sure PATH_ZMS is set to **/zm/cgi-bin/**\ nph-zms.


Changed Default DB User
^^^^^^^^^^^^^^^^^^^^^^^

If you have changed your DB login/password from zmuser/zmpass, you need to
update these values in zm.conf.

1. Edit zm.conf to change ZM_DB_USER and ZM_DB_PASS to the values you used.