1Ubuntu 2====== 3 4.. contents:: 5 6Easy Way: Ubuntu 18.04 (Bionic) 7------------------------------- 8These instructions are for a brand new ubuntu 18.04 system which does not have ZM 9installed. 10 11 12It is recommended that you use an Ubuntu Server install and select the LAMP option 13during install to install Apache, MySQL and PHP. If you failed to do this you can 14achieve the same result by running: 15 16:: 17 18 sudo apt-get install tasksel 19 sudo tasksel install lamp-server 20 21Installing LAMP is not ZoneMinder specific so you will find plenty of resources to 22guide you with a quick search. 23 24**Step 1:** Either run commands in this install using sudo or use the below to become root 25:: 26 27 sudo -i 28 29**Step 2:** Update Repos 30 31.. topic :: Latest Release 32 33 ZoneMinder is now part of the current standard Ubuntu repository, but 34 sometimes the official repository can lag behind. To find out check our 35 `releases page <https://github.com/ZoneMinder/zoneminder/releases>`_ for 36 the latest release. 37 38 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 39 following a new release of ZoneMinder. To use this repository instead of the 40 official Ubuntu repository, enter the following from the command line: 41 42 :: 43 44 add-apt-repository ppa:iconnor/zoneminder-1.34 45 46Update repo and upgrade. 47 48:: 49 50 apt-get update 51 apt-get upgrade 52 apt-get dist-upgrade 53 54 55**Step 3:** Configure MySQL 56 57.. sidebar :: Note 58 59 The MySQL default configuration file (/etc/mysql/mysql.cnf) is read through 60 several symbolic links beginning with /etc/mysql/my.cnf as follows: 61 62 | /etc/mysql/my.cnf -> /etc/alternatives/my.cnf 63 | /etc/alternatives/my.cnf -> /etc/mysql/mysql.cnf 64 | /etc/mysql/mysql.cnf is a basic file 65 66Certain new defaults in MySQL 5.7 cause some issues with ZoneMinder < 1.32.0, 67the workaround is to modify the sql_mode setting of MySQL. Please note that these 68changes are NOT required for ZoneMinder 1.32+ and some people have reported them 69causing problems in 1.32.0. 70 71To better manage the MySQL server it is recommended to copy the sample config file and 72replace the default my.cnf symbolic link. 73 74:: 75 76 rm /etc/mysql/my.cnf (this removes the current symbolic link) 77 cp /etc/mysql/mysql.conf.d/mysqld.cnf /etc/mysql/my.cnf 78 79To change MySQL settings: 80 81:: 82 83 nano /etc/mysql/my.cnf 84 85In the [mysqld] section add the following 86 87:: 88 89 sql_mode = NO_ENGINE_SUBSTITUTION 90 91CTRL+o then [Enter] to save 92 93CTRL+x to exit 94 95Restart MySQL 96 97:: 98 99 systemctl restart mysql 100 101 102**Step 4:** Install ZoneMinder 103 104:: 105 106 apt-get install zoneminder 107 108**Step 5:** Configure the ZoneMinder Database 109 110This step should not be required on ZoneMinder 1.32.0. 111 112:: 113 114 mysql -uroot -p < /usr/share/zoneminder/db/zm_create.sql 115 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';" 116 117 118**Step 6:** Set permissions 119 120Set /etc/zm/zm.conf to root:www-data 740 and www-data access to content 121 122:: 123 124 chmod 740 /etc/zm/zm.conf 125 chown root:www-data /etc/zm/zm.conf 126 chown -R www-data:www-data /usr/share/zoneminder/ 127 128**Step 7:** Configure Apache correctly: 129 130:: 131 132 a2enmod cgi 133 a2enmod rewrite 134 a2enconf zoneminder 135 136You may also want to enable to following modules to improve caching performance 137 138:: 139 140 a2enmod expires 141 a2enmod headers 142 143**Step 8:** Enable and start Zoneminder 144 145:: 146 147 systemctl enable zoneminder 148 systemctl start zoneminder 149 150CTRL+o then [Enter] to save 151 152CTRL+x to exit 153 154**Step 10:** Reload Apache service 155 156:: 157 158 systemctl reload apache2 159 160**Step 11:** Making sure ZoneMinder works 161 1621. Open up a browser and go to ``http://hostname_or_ip/zm`` - should bring up ZoneMinder Console 163 1642. (Optional API Check)Open up a tab in the same browser and go to ``http://hostname_or_ip/zm/api/host/getVersion.json`` 165 166 If it is working correctly you should get version information similar to the example below: 167 168 :: 169 170 { 171 "version": "1.34.0", 172 "apiversion": "1.34.0.1" 173 } 174 175**Congratulations** Your installation is complete 176 177PPA install may need some tweaking of ZMS_PATH in ZoneMinder options. `Socket_sendto or no live streaming`_ 178 179Easy Way: Ubuntu 16.04 (Xenial) 180------------------------------- 181These instructions are for a brand new ubuntu 16.04 system which does not have ZM 182installed. 183 184 185It is recommended that you use an Ubuntu Server install and select the LAMP option 186during install to install Apache, MySQL and PHP. If you failed to do this you can 187achieve the same result by running: 188 189:: 190 191 sudo tasksel install lamp-server 192 193During installation it will ask you to set up a master/root password for the MySQL. 194Installing LAMP is not ZoneMinder specific so you will find plenty of resources to 195guide you with a quick search. 196 197**Step 1:** Either run commands in this install using sudo or use the below to become root 198:: 199 200 sudo -i 201 202**Step 2:** Update Repos 203 204.. topic :: Latest Release 205 206 ZoneMinder is now part of the current standard Ubuntu repository, but 207 sometimes the official repository can lag behind. To find out check our 208 `releases page <https://github.com/ZoneMinder/zoneminder/releases>`_ for 209 the latest release. 210 211 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 212 following a new release of ZoneMinder. To use this repository instead of the 213 official Ubuntu repository, enter the following from the command line: 214 215 :: 216 217 add-apt-repository ppa:iconnor/zoneminder 218 add-apt-repository ppa:iconnor/zoneminder-1.32 219 220Update repo and upgrade. 221 222:: 223 224 apt-get update 225 apt-get upgrade 226 apt-get dist-upgrade 227 228 229**Step 3:** Configure MySQL 230 231.. sidebar :: Note 232 233 The MySQL default configuration file (/etc/mysql/mysql.cnf)is read through 234 several symbolic links beginning with /etc/mysql/my.cnf as follows: 235 236 | /etc/mysql/my.cnf -> /etc/alternatives/my.cnf 237 | /etc/alternatives/my.cnf -> /etc/mysql/mysql.cnf 238 | /etc/mysql/mysql.cnf is a basic file 239 240Certain new defaults in MySQL 5.7 cause some issues with ZoneMinder < 1.32.0, 241the workaround is to modify the sql_mode setting of MySQL. Please note that these 242changes are NOT required for ZoneMinder 1.32.0 and some people have reported them 243causing problems in 1.32.0. 244 245To better manage the MySQL server it is recommended to copy the sample config file and 246replace the default my.cnf symbolic link. 247 248:: 249 250 rm /etc/mysql/my.cnf (this removes the current symbolic link) 251 cp /etc/mysql/mysql.conf.d/mysqld.cnf /etc/mysql/my.cnf 252 253To change MySQL settings: 254 255:: 256 257 nano /etc/mysql/my.cnf 258 259In the [mysqld] section add the following 260 261:: 262 263 sql_mode = NO_ENGINE_SUBSTITUTION 264 265CTRL+o then [Enter] to save 266 267CTRL+x to exit 268 269Restart MySQL 270 271:: 272 273 systemctl restart mysql 274 275 276**Step 4:** Install ZoneMinder 277 278:: 279 280 apt-get install zoneminder 281 282**Step 5:** Configure the ZoneMinder Database 283 284This step should not be required on ZoneMinder 1.32.0. 285 286:: 287 288 mysql -uroot -p < /usr/share/zoneminder/db/zm_create.sql 289 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';" 290 291 292**Step 6:** Set permissions 293 294Set /etc/zm/zm.conf to root:www-data 740 and www-data access to content 295 296:: 297 298 chmod 740 /etc/zm/zm.conf 299 chown root:www-data /etc/zm/zm.conf 300 chown -R www-data:www-data /usr/share/zoneminder/ 301 302**Step 7:** Configure Apache correctly: 303 304:: 305 306 a2enmod cgi 307 a2enmod rewrite 308 a2enconf zoneminder 309 310You may also want to enable to following modules to improve caching performance 311 312:: 313 314 a2enmod expires 315 a2enmod headers 316 317**Step 8:** Enable and start Zoneminder 318 319:: 320 321 systemctl enable zoneminder 322 systemctl start zoneminder 323 324**Step 10:** Reload Apache service 325 326:: 327 328 systemctl reload apache2 329 330**Step 11:** Making sure ZoneMinder works 331 3321. Open up a browser and go to ``http://hostname_or_ip/zm`` - should bring up ZoneMinder Console 333 3342. (Optional API Check)Open up a tab in the same browser and go to ``http://hostname_or_ip/zm/api/host/getVersion.json`` 335 336 If it is working correctly you should get version information similar to the example below: 337 338 :: 339 340 { 341 "version": "1.34.0", 342 "apiversion": "1.34.0.1" 343 } 344 345**Congratulations** Your installation is complete 346 347PPA install may need some tweaking of ZMS_PATH in ZoneMinder options. `Socket_sendto or no live streaming`_ 348 349Harder Way: Build Package From Source 350------------------------------------- 351(These instructions assume installation from source on a ubuntu 15.x+ system) 352 353**Step 1:** Grab the package installer script 354 355:: 356 357 wget https://raw.githubusercontent.com/ZoneMinder/ZoneMinder/master/utils/do_debian_package.sh 358 chmod a+x do_debian_package.sh 359 360 361**Step 2:** Update the system 362 363:: 364 365 sudo apt-get update 366 367 368**Step 3** Create the package 369 370To build the latest master snapshot: 371 372:: 373 374 ./do_debian_package.sh --snapshot=NOW --branch=master --type=local 375 376 377To build the latest stable release: 378 379:: 380 381 ./do_debian_package.sh --snapshot=stable --type=local 382 383 384Note that the distribution will be guessed using ``lsb_release -a 2>/dev/null | grep Codename | awk '{print $2}'`` 385which simply extracts your distribution name - like "xenial", "bionic" etc. You 386can always specify it using --distro=your distro name if you know it. As far as the script 387goes, it checks if your distro is "trusty" in which case it pulls in pre-systemd 388release configurations and if its not "trusty" it assumes its based on systemd 389and pulls in systemd related config files. 390 391(At the end the script will ask if you want to retain the checked out version of 392ZoneMinder. If you are a developer and are making local changes, make sure you 393select "y" so that the next time you do the build process mentioned here, it 394keeps your changes. Selecting any other value than "y" or "Y" will delete the 395checked out code and only retain the package) 396 397This should now create a bunch of .deb files 398 399**Step 4:** Install the package 400 401:: 402 403 sudo gdebi zoneminder_<version>_<arch>.deb 404 (example sudo gdebi zoneminder_1.34.0-bionic-2021020801_amd64.deb) 405 406 407**This will report DB errors - ignore - you need to configure the DB and some other stuff** 408 409**Step 5:** Post install configuration 410 411Now that you have installed from your own package you can resume following the 412standard install guide for your version, start at the step after Install Zoneminder. 413 414Hints 415----- 416Make sure ZoneMinder and APIs work with security 417^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 418 4191. Enable OPT_AUTH in ZoneMinder 4202. Log out of ZoneMinder in browser 4213. Open a new tab in the *same browser* (important) and go to 422 ``http://localhost/zm/api/host/getVersion.json`` - should give you "Unauthorized" 423 along with a lot more of text 4244. Go to another tab in the SAME BROWSER (important) and log into ZM 4255. Repeat step 3 and it should give you the ZM and API version 426 427Socket_sendto or no live streaming 428^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 429 430After you have setup your camera make sure you can view Monitor streams, if not 431check some of the common causes: 432 433* Check Apache cgi module is enabled. 434* Check Apache /etc/apache2/conf-enabled/zoneminder.conf ScriptAlias matches PATH_ZMS. 435 436 ScriptAlias **/zm/cgi-bin** /usr/lib/zoneminder/cgi-bin 437 438 From console go to ``Options->Path`` and make sure PATH_ZMS is set to **/zm/cgi-bin/**\ nph-zms. 439 440 441Changed Default DB User 442^^^^^^^^^^^^^^^^^^^^^^^ 443 444If you have changed your DB login/password from zmuser/zmpass, you need to 445update these values in zm.conf. 446 4471. Edit zm.conf to change ZM_DB_USER and ZM_DB_PASS to the values you used. 448