This guide covers installing ZoneMinder on FreeBSD 15 with:
dbserver)nfsserver)
Assumptions: - You have root or sudo access on all systems - Substitute your preferred editor for edit in commands
CREATE DATABASE zm; CREATE USER 'zmuser'@'192.168.1.%' IDENTIFIED BY 'zmpass'; GRANT ALL PRIVILEGES ON zm.* TO 'zmuser'@'192.168.1.%'; FLUSH PRIVILEGES;
Adjust192.168.1to your subnet as needed.
Create and export the dataset:
zfs create pool/zoneminder zfs set quota=500G atime=off pool/zoneminder echo '/pool/zoneminder -alldirs -maproot=root' >> /etc/exports service mountd reload
mysql -h dbserver -u zmuser -p zm exit;
mount -t nfs nfsserver:/pool/zoneminder /mnt ls /mnt umount /mnt
echo 'tmpfs /tmp tmpfs rw,nosuid,mode=1777 0 0' >> /etc/fstab rm -fR /tmp/* rm -fR /tmp/.* mount /tmp reboot # only if needed
pkg install zoneminder-php85 nginx fcgiwrap
# initialize zm database mysql -h dbserver -u zmuser -p zm < /usr/local/share/zoneminder/db/zm_create.sql # move data to NFS mount nfsserver:/pool/zoneminder /mnt mv /var/db/zoneminder/* /mnt/ # expect errors as not all permissions match on NFS umount /mnt # configure NFS mount echo 'nfsserver:/pool/zoneminder /var/db/zoneminder nfs rw,soft 0 0' >> /etc/fstab mount /var/db/zoneminder chown -fR www:www /var/db/zoneminder
In the following, I tried to set up a copy/paste and also backing up files before changing them.
cd /usr/local/etc/nginx mv nginx.conf nginx.conf.save edit nginx.conf
Paste in:
worker_processes 1; events { worker_connections 1024; } http { include mime.types; default_type application/octet-stream; sendfile on; keepalive_timeout 65; server { listen 80; root /usr/local/www/zoneminder; index index.php; gzip off; location /cgi-bin/nph-zms { include fastcgi_params; fastcgi_param SCRIPT_FILENAME $request_filename; fastcgi_pass unix:/var/run/fcgiwrap/fcgiwrap.sock; } location /zm/cache { alias /var/cache/zoneminder; } location /zm { alias /usr/local/www/zoneminder; location ~ \.php$ { if (!-f $request_filename) { return 404; } include fastcgi_params; fastcgi_param SCRIPT_FILENAME $request_filename; fastcgi_index index.php; fastcgi_pass unix:/var/run/php-fpm.sock; } location ~ \.(jpg|jpeg|gif|png|ico)$ { access_log off; expires 33d; } location /zm/api/ { alias /usr/local/www/zoneminder; rewrite ^/zm/api(.+)$ /zm/api/app/webroot/index.php?p=$1 last; } } } }
cd /usr/local/etc/php-fpm.d/ mv www.conf www.conf.save edit /usr/local/etc/php-fpm.d/www.conf
Paste in (change time zone if needed):
[www] user = www group = www env[PATH] = /usr/local/bin:/usr/bin:/bin pm = dynamic pm.max_children = 5 pm.start_servers = 2 pm.min_spare_servers = 1 pm.max_spare_servers = 3 php_admin_value[date.timezone] = America/Chicago listen.owner = www listen.group = www listen = /var/run/php-fpm.sock
Create /usr/local/etc/zoneminder/03-database.conf (do not edit zm.conf):
edit /usr/local/etc/zoneminder/03-database.conf
Paste in:
ZM_DB_TYPE=mysql ZM_DB_HOST=dbserver ZM_DB_NAME=zm ZM_DB_USER=zmuser ZM_DB_PASS=zmpass
Do each service in turn, troubleshooting if it fails to start
sysrc nginx_enable="YES" service nginx start
sysrc fcgiwrap_enable="YES" sysrc fcgiwrap_user="www" sysrc fcgiwrap_socket_owner="www" sysrc fcgiwrap_flags="-c 4" service fcgiwrap start
echo 'date.timezone = "America/Chicago"' > /usr/local/etc/php/timezone sysrc php_fpm_enable="YES" service php_fpm start
sysrc zoneminder_enable="YES" service zoneminder start
Access ZoneMinder at: http://servername/zm
Recommendation: Reboot and verify all services start automatically.